From: Chris Lalancette <clalance@redhat.com> Date: Thu, 5 Mar 2009 14:13:05 +0100 Subject: [xen] xen reports bogus LowTotal Message-id: 49AFCFE1.9050501@redhat.com O-Subject: [RHEL5.4 PATCH]: Xen reports bogus LowTotal Bugzilla: 428892 RH-Acked-by: Don Dutile <ddutile@redhat.com> RH-Acked-by: Rik van Riel <riel@redhat.com> All, The xen kernel can report a LowTotal of 4Tb on a system, even though the system only has 3.5Gb of memory. That's obviously totally bogus. The problem is that the balloon driver wasn't properly accounting for totalhigh_pages in it's calculations, which screws up the rest of the reporting in the system. This is a straightforward backport of linux-2.6.18-xen.hg c/s 79 and 128, and seems to fix the problem for the reporter. This will fix BZ 428892. Please review and ACK -- Chris Lalancette diff --git a/drivers/xen/balloon/balloon.c b/drivers/xen/balloon/balloon.c index 39d7185..e8ce44f 100644 --- a/drivers/xen/balloon/balloon.c +++ b/drivers/xen/balloon/balloon.c @@ -93,6 +93,15 @@ static unsigned long frame_list[PAGE_SIZE / sizeof(unsigned long)]; /* VM /proc information for memory */ extern unsigned long totalram_pages; +#ifndef MODULE +extern unsigned long totalhigh_pages; +#define inc_totalhigh_pages() (totalhigh_pages++) +#define dec_totalhigh_pages() (totalhigh_pages--) +#else +#define inc_totalhigh_pages() ((void)0) +#define dec_totalhigh_pages() ((void)0) +#endif + /* We may hit the hard limit in Xen. If we do then we remember it. */ static unsigned long hard_limit; @@ -137,6 +146,7 @@ static void balloon_append(struct page *page) if (PageHighMem(page)) { list_add_tail(PAGE_TO_LIST(page), &ballooned_pages); balloon_high++; + dec_totalhigh_pages(); } else { list_add(PAGE_TO_LIST(page), &ballooned_pages); balloon_low++; @@ -154,8 +164,10 @@ static struct page *balloon_retrieve(void) page = LIST_TO_PAGE(ballooned_pages.next); UNLIST_PAGE(page); - if (PageHighMem(page)) + if (PageHighMem(page)) { balloon_high--; + inc_totalhigh_pages(); + } else balloon_low--;