Commit 3bfccb74973db10a03d3d4c1d10fc00e77145699

Authored by Linus Torvalds

Merge branches 'stable/balloon.cleanup' and 'stable/general.cleanup' of git://gi…

…t.kernel.org/pub/scm/linux/kernel/git/konrad/xen

* 'stable/balloon.cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen:
  xen/balloon: Move dec_totalhigh_pages() from __balloon_append() to balloon_append()
  xen/balloon: Clarify credit calculation
  xen/balloon: Simplify HVM integration
  xen/balloon: Use PageHighMem() for high memory page detection

* 'stable/general.cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen:
  drivers/xen/sys-hypervisor: Cleanup code/data sections definitions
  arch/x86/xen/smp: Cleanup code/data sections definitions
  arch/x86/xen/time: Cleanup code/data sections definitions
  arch/x86/xen/xen-ops: Cleanup code/data sections definitions
  arch/x86/xen/mmu: Cleanup code/data sections definitions
  arch/x86/xen/setup: Cleanup code/data sections definitions
  arch/x86/xen/enlighten: Cleanup code/data sections definitions
  arch/x86/xen/irq: Cleanup code/data sections definitions
  xen: tidy up whitespace in drivers/xen/Makefile

Showing 10 changed files Side-by-side Diff

arch/x86/xen/enlighten.c
... ... @@ -235,7 +235,7 @@
235 235 *dx &= maskedx;
236 236 }
237 237  
238   -static __init void xen_init_cpuid_mask(void)
  238 +static void __init xen_init_cpuid_mask(void)
239 239 {
240 240 unsigned int ax, bx, cx, dx;
241 241 unsigned int xsave_mask;
... ... @@ -400,7 +400,7 @@
400 400 /*
401 401 * load_gdt for early boot, when the gdt is only mapped once
402 402 */
403   -static __init void xen_load_gdt_boot(const struct desc_ptr *dtr)
  403 +static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
404 404 {
405 405 unsigned long va = dtr->address;
406 406 unsigned int size = dtr->size + 1;
... ... @@ -662,7 +662,7 @@
662 662 * Version of write_gdt_entry for use at early boot-time needed to
663 663 * update an entry as simply as possible.
664 664 */
665   -static __init void xen_write_gdt_entry_boot(struct desc_struct *dt, int entry,
  665 +static void __init xen_write_gdt_entry_boot(struct desc_struct *dt, int entry,
666 666 const void *desc, int type)
667 667 {
668 668 switch (type) {
669 669  
670 670  
... ... @@ -933,18 +933,18 @@
933 933 return ret;
934 934 }
935 935  
936   -static const struct pv_info xen_info __initdata = {
  936 +static const struct pv_info xen_info __initconst = {
937 937 .paravirt_enabled = 1,
938 938 .shared_kernel_pmd = 0,
939 939  
940 940 .name = "Xen",
941 941 };
942 942  
943   -static const struct pv_init_ops xen_init_ops __initdata = {
  943 +static const struct pv_init_ops xen_init_ops __initconst = {
944 944 .patch = xen_patch,
945 945 };
946 946  
947   -static const struct pv_cpu_ops xen_cpu_ops __initdata = {
  947 +static const struct pv_cpu_ops xen_cpu_ops __initconst = {
948 948 .cpuid = xen_cpuid,
949 949  
950 950 .set_debugreg = xen_set_debugreg,
... ... @@ -1004,7 +1004,7 @@
1004 1004 .end_context_switch = xen_end_context_switch,
1005 1005 };
1006 1006  
1007   -static const struct pv_apic_ops xen_apic_ops __initdata = {
  1007 +static const struct pv_apic_ops xen_apic_ops __initconst = {
1008 1008 #ifdef CONFIG_X86_LOCAL_APIC
1009 1009 .startup_ipi_hook = paravirt_nop,
1010 1010 #endif
... ... @@ -1055,7 +1055,7 @@
1055 1055 return 0;
1056 1056 }
1057 1057  
1058   -static const struct machine_ops __initdata xen_machine_ops = {
  1058 +static const struct machine_ops xen_machine_ops __initconst = {
1059 1059 .restart = xen_restart,
1060 1060 .halt = xen_machine_halt,
1061 1061 .power_off = xen_machine_halt,
... ... @@ -1332,7 +1332,7 @@
1332 1332 return NOTIFY_OK;
1333 1333 }
1334 1334  
1335   -static struct notifier_block __cpuinitdata xen_hvm_cpu_notifier = {
  1335 +static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
1336 1336 .notifier_call = xen_hvm_cpu_notify,
1337 1337 };
1338 1338  
... ... @@ -1381,7 +1381,7 @@
1381 1381 }
1382 1382 EXPORT_SYMBOL_GPL(xen_hvm_need_lapic);
1383 1383  
1384   -const __refconst struct hypervisor_x86 x86_hyper_xen_hvm = {
  1384 +const struct hypervisor_x86 x86_hyper_xen_hvm __refconst = {
1385 1385 .name = "Xen HVM",
1386 1386 .detect = xen_hvm_platform,
1387 1387 .init_platform = xen_hvm_guest_init,
... ... @@ -113,7 +113,7 @@
113 113 xen_safe_halt();
114 114 }
115 115  
116   -static const struct pv_irq_ops xen_irq_ops __initdata = {
  116 +static const struct pv_irq_ops xen_irq_ops __initconst = {
117 117 .save_fl = PV_CALLEE_SAVE(xen_save_fl),
118 118 .restore_fl = PV_CALLEE_SAVE(xen_restore_fl),
119 119 .irq_disable = PV_CALLEE_SAVE(xen_irq_disable),
... ... @@ -1054,7 +1054,7 @@
1054 1054 * that's before we have page structures to store the bits. So do all
1055 1055 * the book-keeping now.
1056 1056 */
1057   -static __init int xen_mark_pinned(struct mm_struct *mm, struct page *page,
  1057 +static int __init xen_mark_pinned(struct mm_struct *mm, struct page *page,
1058 1058 enum pt_level level)
1059 1059 {
1060 1060 SetPagePinned(page);
... ... @@ -1271,7 +1271,7 @@
1271 1271 spin_unlock(&mm->page_table_lock);
1272 1272 }
1273 1273  
1274   -static __init void xen_pagetable_setup_start(pgd_t *base)
  1274 +static void __init xen_pagetable_setup_start(pgd_t *base)
1275 1275 {
1276 1276 }
1277 1277  
... ... @@ -1291,7 +1291,7 @@
1291 1291  
1292 1292 static void xen_post_allocator_init(void);
1293 1293  
1294   -static __init void xen_pagetable_setup_done(pgd_t *base)
  1294 +static void __init xen_pagetable_setup_done(pgd_t *base)
1295 1295 {
1296 1296 xen_setup_shared_info();
1297 1297 xen_post_allocator_init();
... ... @@ -1488,7 +1488,7 @@
1488 1488 }
1489 1489  
1490 1490 #ifdef CONFIG_X86_32
1491   -static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
  1491 +static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)
1492 1492 {
1493 1493 /* If there's an existing pte, then don't allow _PAGE_RW to be set */
1494 1494 if (pte_val_ma(*ptep) & _PAGE_PRESENT)
... ... @@ -1498,7 +1498,7 @@
1498 1498 return pte;
1499 1499 }
1500 1500 #else /* CONFIG_X86_64 */
1501   -static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
  1501 +static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)
1502 1502 {
1503 1503 unsigned long pfn = pte_pfn(pte);
1504 1504  
... ... @@ -1519,7 +1519,7 @@
1519 1519  
1520 1520 /* Init-time set_pte while constructing initial pagetables, which
1521 1521 doesn't allow RO pagetable pages to be remapped RW */
1522   -static __init void xen_set_pte_init(pte_t *ptep, pte_t pte)
  1522 +static void __init xen_set_pte_init(pte_t *ptep, pte_t pte)
1523 1523 {
1524 1524 pte = mask_rw_pte(ptep, pte);
1525 1525  
... ... @@ -1537,7 +1537,7 @@
1537 1537  
1538 1538 /* Early in boot, while setting up the initial pagetable, assume
1539 1539 everything is pinned. */
1540   -static __init void xen_alloc_pte_init(struct mm_struct *mm, unsigned long pfn)
  1540 +static void __init xen_alloc_pte_init(struct mm_struct *mm, unsigned long pfn)
1541 1541 {
1542 1542 #ifdef CONFIG_FLATMEM
1543 1543 BUG_ON(mem_map); /* should only be used early */
... ... @@ -1547,7 +1547,7 @@
1547 1547 }
1548 1548  
1549 1549 /* Used for pmd and pud */
1550   -static __init void xen_alloc_pmd_init(struct mm_struct *mm, unsigned long pfn)
  1550 +static void __init xen_alloc_pmd_init(struct mm_struct *mm, unsigned long pfn)
1551 1551 {
1552 1552 #ifdef CONFIG_FLATMEM
1553 1553 BUG_ON(mem_map); /* should only be used early */
1554 1554  
... ... @@ -1557,13 +1557,13 @@
1557 1557  
1558 1558 /* Early release_pte assumes that all pts are pinned, since there's
1559 1559 only init_mm and anything attached to that is pinned. */
1560   -static __init void xen_release_pte_init(unsigned long pfn)
  1560 +static void __init xen_release_pte_init(unsigned long pfn)
1561 1561 {
1562 1562 pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, pfn);
1563 1563 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
1564 1564 }
1565 1565  
1566   -static __init void xen_release_pmd_init(unsigned long pfn)
  1566 +static void __init xen_release_pmd_init(unsigned long pfn)
1567 1567 {
1568 1568 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
1569 1569 }
... ... @@ -1689,7 +1689,7 @@
1689 1689 BUG();
1690 1690 }
1691 1691  
1692   -static __init void xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
  1692 +static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
1693 1693 {
1694 1694 unsigned pmdidx, pteidx;
1695 1695 unsigned ident_pte;
... ... @@ -1772,7 +1772,7 @@
1772 1772 * of the physical mapping once some sort of allocator has been set
1773 1773 * up.
1774 1774 */
1775   -__init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
  1775 +pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
1776 1776 unsigned long max_pfn)
1777 1777 {
1778 1778 pud_t *l3;
... ... @@ -1843,7 +1843,7 @@
1843 1843 static RESERVE_BRK_ARRAY(pmd_t, initial_kernel_pmd, PTRS_PER_PMD);
1844 1844 static RESERVE_BRK_ARRAY(pmd_t, swapper_kernel_pmd, PTRS_PER_PMD);
1845 1845  
1846   -static __init void xen_write_cr3_init(unsigned long cr3)
  1846 +static void __init xen_write_cr3_init(unsigned long cr3)
1847 1847 {
1848 1848 unsigned long pfn = PFN_DOWN(__pa(swapper_pg_dir));
1849 1849  
... ... @@ -1880,7 +1880,7 @@
1880 1880 pv_mmu_ops.write_cr3 = &xen_write_cr3;
1881 1881 }
1882 1882  
1883   -__init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
  1883 +pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
1884 1884 unsigned long max_pfn)
1885 1885 {
1886 1886 pmd_t *kernel_pmd;
... ... @@ -1986,7 +1986,7 @@
1986 1986 #endif
1987 1987 }
1988 1988  
1989   -__init void xen_ident_map_ISA(void)
  1989 +void __init xen_ident_map_ISA(void)
1990 1990 {
1991 1991 unsigned long pa;
1992 1992  
... ... @@ -2009,7 +2009,7 @@
2009 2009 xen_flush_tlb();
2010 2010 }
2011 2011  
2012   -static __init void xen_post_allocator_init(void)
  2012 +static void __init xen_post_allocator_init(void)
2013 2013 {
2014 2014 #ifdef CONFIG_XEN_DEBUG
2015 2015 pv_mmu_ops.make_pte = PV_CALLEE_SAVE(xen_make_pte_debug);
... ... @@ -2046,7 +2046,7 @@
2046 2046 preempt_enable();
2047 2047 }
2048 2048  
2049   -static const struct pv_mmu_ops xen_mmu_ops __initdata = {
  2049 +static const struct pv_mmu_ops xen_mmu_ops __initconst = {
2050 2050 .read_cr2 = xen_read_cr2,
2051 2051 .write_cr2 = xen_write_cr2,
2052 2052  
arch/x86/xen/setup.c
... ... @@ -50,7 +50,7 @@
50 50 */
51 51 #define EXTRA_MEM_RATIO (10)
52 52  
53   -static __init void xen_add_extra_mem(unsigned long pages)
  53 +static void __init xen_add_extra_mem(unsigned long pages)
54 54 {
55 55 unsigned long pfn;
56 56  
... ... @@ -336,7 +336,7 @@
336 336 #endif
337 337 }
338 338  
339   -static __cpuinit int register_callback(unsigned type, const void *func)
  339 +static int __cpuinit register_callback(unsigned type, const void *func)
340 340 {
341 341 struct callback_register callback = {
342 342 .type = type,
... ... @@ -57,7 +57,7 @@
57 57 return IRQ_HANDLED;
58 58 }
59 59  
60   -static __cpuinit void cpu_bringup(void)
  60 +static void __cpuinit cpu_bringup(void)
61 61 {
62 62 int cpu = smp_processor_id();
63 63  
... ... @@ -85,7 +85,7 @@
85 85 wmb(); /* make sure everything is out */
86 86 }
87 87  
88   -static __cpuinit void cpu_bringup_and_idle(void)
  88 +static void __cpuinit cpu_bringup_and_idle(void)
89 89 {
90 90 cpu_bringup();
91 91 cpu_idle();
... ... @@ -242,7 +242,7 @@
242 242 }
243 243 }
244 244  
245   -static __cpuinit int
  245 +static int __cpuinit
246 246 cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
247 247 {
248 248 struct vcpu_guest_context *ctxt;
... ... @@ -486,7 +486,7 @@
486 486 return IRQ_HANDLED;
487 487 }
488 488  
489   -static const struct smp_ops xen_smp_ops __initdata = {
  489 +static const struct smp_ops xen_smp_ops __initconst = {
490 490 .smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu,
491 491 .smp_prepare_cpus = xen_smp_prepare_cpus,
492 492 .smp_cpus_done = xen_smp_cpus_done,
... ... @@ -439,11 +439,11 @@
439 439 }
440 440 }
441 441  
442   -static const struct pv_time_ops xen_time_ops __initdata = {
  442 +static const struct pv_time_ops xen_time_ops __initconst = {
443 443 .sched_clock = xen_clocksource_read,
444 444 };
445 445  
446   -static __init void xen_time_init(void)
  446 +static void __init xen_time_init(void)
447 447 {
448 448 int cpu = smp_processor_id();
449 449 struct timespec tp;
... ... @@ -468,7 +468,7 @@
468 468 xen_setup_cpu_clockevents();
469 469 }
470 470  
471   -__init void xen_init_time_ops(void)
  471 +void __init xen_init_time_ops(void)
472 472 {
473 473 pv_time_ops = xen_time_ops;
474 474  
... ... @@ -490,7 +490,7 @@
490 490 xen_setup_cpu_clockevents();
491 491 }
492 492  
493   -__init void xen_hvm_init_time_ops(void)
  493 +void __init xen_hvm_init_time_ops(void)
494 494 {
495 495 /* vector callback is needed otherwise we cannot receive interrupts
496 496 * on cpu > 0 and at this point we don't know how many cpus are
arch/x86/xen/xen-ops.h
... ... @@ -74,7 +74,7 @@
74 74  
75 75 #ifdef CONFIG_PARAVIRT_SPINLOCKS
76 76 void __init xen_init_spinlocks(void);
77   -__cpuinit void xen_init_lock_cpu(int cpu);
  77 +void __cpuinit xen_init_lock_cpu(int cpu);
78 78 void xen_uninit_lock_cpu(int cpu);
79 79 #else
80 80 static inline void xen_init_spinlocks(void)
drivers/xen/Makefile
... ... @@ -4,22 +4,22 @@
4 4 nostackp := $(call cc-option, -fno-stack-protector)
5 5 CFLAGS_features.o := $(nostackp)
6 6  
7   -obj-$(CONFIG_BLOCK) += biomerge.o
8   -obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
9   -obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
10   -obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o
11   -obj-$(CONFIG_XEN_DEV_EVTCHN) += xen-evtchn.o
12   -obj-$(CONFIG_XEN_GNTDEV) += xen-gntdev.o
  7 +obj-$(CONFIG_BLOCK) += biomerge.o
  8 +obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
  9 +obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
  10 +obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o
  11 +obj-$(CONFIG_XEN_DEV_EVTCHN) += xen-evtchn.o
  12 +obj-$(CONFIG_XEN_GNTDEV) += xen-gntdev.o
13 13 obj-$(CONFIG_XEN_GRANT_DEV_ALLOC) += xen-gntalloc.o
14   -obj-$(CONFIG_XENFS) += xenfs/
  14 +obj-$(CONFIG_XENFS) += xenfs/
15 15 obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o
16   -obj-$(CONFIG_XEN_PLATFORM_PCI) += xen-platform-pci.o
17   -obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
18   -obj-$(CONFIG_XEN_DOM0) += pci.o
  16 +obj-$(CONFIG_XEN_PLATFORM_PCI) += xen-platform-pci.o
  17 +obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
  18 +obj-$(CONFIG_XEN_DOM0) += pci.o
19 19  
20   -xen-evtchn-y := evtchn.o
  20 +xen-evtchn-y := evtchn.o
21 21 xen-gntdev-y := gntdev.o
22 22 xen-gntalloc-y := gntalloc.o
23 23  
24   -xen-platform-pci-y := platform-pci.o
  24 +xen-platform-pci-y := platform-pci.o
drivers/xen/balloon.c
... ... @@ -114,7 +114,6 @@
114 114 if (PageHighMem(page)) {
115 115 list_add_tail(&page->lru, &ballooned_pages);
116 116 balloon_stats.balloon_high++;
117   - dec_totalhigh_pages();
118 117 } else {
119 118 list_add(&page->lru, &ballooned_pages);
120 119 balloon_stats.balloon_low++;
... ... @@ -124,6 +123,8 @@
124 123 static void balloon_append(struct page *page)
125 124 {
126 125 __balloon_append(page);
  126 + if (PageHighMem(page))
  127 + dec_totalhigh_pages();
127 128 totalram_pages--;
128 129 }
129 130  
... ... @@ -193,7 +194,7 @@
193 194 return BP_EAGAIN;
194 195 }
195 196  
196   -static unsigned long current_target(void)
  197 +static long current_credit(void)
197 198 {
198 199 unsigned long target = balloon_stats.target_pages;
199 200  
... ... @@ -202,7 +203,7 @@
202 203 balloon_stats.balloon_low +
203 204 balloon_stats.balloon_high);
204 205  
205   - return target;
  206 + return target - balloon_stats.current_pages;
206 207 }
207 208  
208 209 static enum bp_state increase_reservation(unsigned long nr_pages)
... ... @@ -246,7 +247,7 @@
246 247 set_phys_to_machine(pfn, frame_list[i]);
247 248  
248 249 /* Link back into the page tables if not highmem. */
249   - if (!xen_hvm_domain() && pfn < max_low_pfn) {
  250 + if (xen_pv_domain() && !PageHighMem(page)) {
250 251 int ret;
251 252 ret = HYPERVISOR_update_va_mapping(
252 253 (unsigned long)__va(pfn << PAGE_SHIFT),
... ... @@ -293,7 +294,7 @@
293 294  
294 295 scrub_page(page);
295 296  
296   - if (!xen_hvm_domain() && !PageHighMem(page)) {
  297 + if (xen_pv_domain() && !PageHighMem(page)) {
297 298 ret = HYPERVISOR_update_va_mapping(
298 299 (unsigned long)__va(pfn << PAGE_SHIFT),
299 300 __pte_ma(0), 0);
... ... @@ -337,7 +338,7 @@
337 338 mutex_lock(&balloon_mutex);
338 339  
339 340 do {
340   - credit = current_target() - balloon_stats.current_pages;
  341 + credit = current_credit();
341 342  
342 343 if (credit > 0)
343 344 state = increase_reservation(credit);
... ... @@ -420,7 +421,7 @@
420 421 }
421 422  
422 423 /* The balloon may be too large now. Shrink it if needed. */
423   - if (current_target() != balloon_stats.current_pages)
  424 + if (current_credit())
424 425 schedule_delayed_work(&balloon_worker, 0);
425 426  
426 427 mutex_unlock(&balloon_mutex);
... ... @@ -429,7 +430,7 @@
429 430  
430 431 static int __init balloon_init(void)
431 432 {
432   - unsigned long pfn, nr_pages, extra_pfn_end;
  433 + unsigned long pfn, extra_pfn_end;
433 434 struct page *page;
434 435  
435 436 if (!xen_domain())
... ... @@ -437,11 +438,7 @@
437 438  
438 439 pr_info("xen/balloon: Initialising balloon driver.\n");
439 440  
440   - if (xen_pv_domain())
441   - nr_pages = xen_start_info->nr_pages;
442   - else
443   - nr_pages = max_pfn;
444   - balloon_stats.current_pages = min(nr_pages, max_pfn);
  441 + balloon_stats.current_pages = xen_pv_domain() ? min(xen_start_info->nr_pages, max_pfn) : max_pfn;
445 442 balloon_stats.target_pages = balloon_stats.current_pages;
446 443 balloon_stats.balloon_low = 0;
447 444 balloon_stats.balloon_high = 0;
... ... @@ -466,7 +463,7 @@
466 463 pfn < extra_pfn_end;
467 464 pfn++) {
468 465 page = pfn_to_page(pfn);
469   - /* totalram_pages doesn't include the boot-time
  466 + /* totalram_pages and totalhigh_pages do not include the boot-time
470 467 balloon extension, so don't subtract from it. */
471 468 __balloon_append(page);
472 469 }
drivers/xen/sys-hypervisor.c
... ... @@ -215,7 +215,7 @@
215 215 .attrs = xen_compile_attrs,
216 216 };
217 217  
218   -int __init static xen_compilation_init(void)
  218 +static int __init xen_compilation_init(void)
219 219 {
220 220 return sysfs_create_group(hypervisor_kobj, &xen_compilation_group);
221 221 }