ia64/linux-2.6.18-xen.hg

view arch/ia64/xen/xencomm.c @ 897:329ea0ccb344

balloon: try harder to balloon up under memory pressure.

Currently if the balloon driver is unable to increase the guest's
reservation it assumes the failure was due to reaching its full
allocation, gives up on the ballooning operation and records the limit
it reached as the "hard limit". The driver will not try again until
the target is set again (even to the same value).

However it is possible that ballooning has in fact failed due to
memory pressure in the host and therefore it is desirable to keep
attempting to reach the target in case memory becomes available. The
most likely scenario is that some guests are ballooning down while
others are ballooning up and therefore there is temporary memory
pressure while things stabilise. You would not expect a well behaved
toolstack to ask a domain to balloon to more than its allocation nor
would you expect it to deliberately over-commit memory by setting
balloon targets which exceed the total host memory.

This patch drops the concept of a hard limit and causes the balloon
driver to retry increasing the reservation on a timer in the same
manner as when decreasing the reservation.

Also if we partially succeed in increasing the reservation
(i.e. receive less pages than we asked for) then we may as well keep
those pages rather than returning them to Xen.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 14:01:20 2009 +0100 (2009-06-05)
parents b5fdf02c38f4
children
line source
1 /*
2 * Copyright (C) 2006 Hollis Blanchard <hollisb@us.ibm.com>, IBM Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
19 #include <linux/gfp.h>
20 #include <linux/mm.h>
21 #include <xen/interface/xen.h>
22 #include <asm/page.h>
24 #ifdef HAVE_XEN_PLATFORM_COMPAT_H
25 #include <xen/platform-compat.h>
26 #endif
28 #include <asm/xen/xencomm.h>
30 static unsigned long kernel_start_pa;
32 void
33 xencomm_initialize (void)
34 {
35 kernel_start_pa = KERNEL_START - ia64_tpa(KERNEL_START);
36 }
38 /* Translate virtual address to physical address. */
39 unsigned long
40 xencomm_vtop(unsigned long vaddr)
41 {
42 #ifndef CONFIG_VMX_GUEST
43 struct page *page;
44 struct vm_area_struct *vma;
45 #endif
47 if (vaddr == 0)
48 return 0;
50 #ifdef __ia64__
51 if (REGION_NUMBER(vaddr) == 5) {
52 pgd_t *pgd;
53 pud_t *pud;
54 pmd_t *pmd;
55 pte_t *ptep;
57 /* On ia64, TASK_SIZE refers to current. It is not initialized
58 during boot.
59 Furthermore the kernel is relocatable and __pa() doesn't
60 work on addresses. */
61 if (vaddr >= KERNEL_START
62 && vaddr < (KERNEL_START + KERNEL_TR_PAGE_SIZE)) {
63 return vaddr - kernel_start_pa;
64 }
66 /* In kernel area -- virtually mapped. */
67 pgd = pgd_offset_k(vaddr);
68 if (pgd_none(*pgd) || pgd_bad(*pgd))
69 return ~0UL;
71 pud = pud_offset(pgd, vaddr);
72 if (pud_none(*pud) || pud_bad(*pud))
73 return ~0UL;
75 pmd = pmd_offset(pud, vaddr);
76 if (pmd_none(*pmd) || pmd_bad(*pmd))
77 return ~0UL;
79 ptep = pte_offset_kernel(pmd, vaddr);
80 if (!ptep)
81 return ~0UL;
83 return (pte_val(*ptep) & _PFN_MASK) | (vaddr & ~PAGE_MASK);
84 }
85 #endif
87 if (vaddr > TASK_SIZE) {
88 /* kernel address */
89 return __pa(vaddr);
90 }
93 #ifdef CONFIG_VMX_GUEST
94 /* No privcmd within vmx guest. */
95 return ~0UL;
96 #else
97 /* XXX double-check (lack of) locking */
98 vma = find_extend_vma(current->mm, vaddr);
99 if (!vma)
100 return ~0UL;
102 /* We assume the page is modified. */
103 page = follow_page(vma, vaddr, FOLL_WRITE | FOLL_TOUCH);
104 if (!page)
105 return ~0UL;
107 return (page_to_pfn(page) << PAGE_SHIFT) | (vaddr & ~PAGE_MASK);
108 #endif
109 }