Skip to contentSkip to conversation

Fix balloon handling of highmem pages

PATCH In review Mark Williamson 2 participants 3 messages Jun 29, 2007 – Jul 3, 2007 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix balloon handling of highmem pages

I knocked up a quick patch to fix the balloon driver's handling of highmem pages. Should apply cleanly to the Linux dev tree. I can also submit it for 3.1 if wanted.

Without this, LowTotal can go negative (given it's an unsigned integer) and then appears as ~4Gig, which is a bit silly.

I beliee this fixes Anthony Wright's bug #733 in Bugzilla
(http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=733). Credit to Anthony for noticing the problem, and figuring out that he was actually seeing an unsigned int going "negative".

Cheers,
Mark

Signature · 4 lines
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!

# HG changeset patch
# User [email protected]
# Date 1183132109 -3600
# Node ID 64dba2f5f5e1bc219f699ceebf69c73ce993eb3d
# Parent 6433fb4f88d6779073bb527e0ea13814206d3259
Stop low memory from appearing -ve in /proc/meminfo when ballooned.

drivers/xen/balloon/balloon.c +5 -1
diff -r 6433fb4f88d6 -r 64dba2f5f5e1 drivers/xen/balloon/balloon.c
@@ -83,6 +83,7 @@ static unsigned long frame_list[PAGE_SIZ
 
 /* VM /proc information for memory */
 extern unsigned long totalram_pages;
+extern unsigned long totalhigh_pages;
 
 /* List of ballooned pages, threaded through the mem_map array. */
 static LIST_HEAD(ballooned_pages);
@@ -118,6 +119,7 @@ static void balloon_append(struct page *
 	if (PageHighMem(page)) {
 		list_add_tail(PAGE_TO_LIST(page), &ballooned_pages);
 		bs.balloon_high++;
+		totalhigh_pages--;
 	} else {
 		list_add(PAGE_TO_LIST(page), &ballooned_pages);
 		bs.balloon_low++;
@@ -135,8 +137,10 @@ static struct page *balloon_retrieve(voi
 	page = LIST_TO_PAGE(ballooned_pages.next);
 	UNLIST_PAGE(page);
 
-	if (PageHighMem(page))
+	if (PageHighMem(page)) {
 		bs.balloon_high--;
+		totalhigh_pages++;
+	}
 	else
 		bs.balloon_low--;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Applied, but have you tested with 'mem=' on the domain cmdline to give it a memmap bigger than its original allocation of memory? In this case it looks like the code in mm/init-xen.c does the right thing in tandem with this patch (i.e., it increments totalhigh_pages for each not-currently-present page, and you then decrement again when the not-present pages get added to the balloon). But I'm not 100% certain and it could do with being tested.

Thanks,
Keir

Quoted 14 lines · Mark Williamson

I knocked up a quick patch to fix the balloon driver's handling of highmem pages. Should apply cleanly to the Linux dev tree. I can also submit it for 3.1 if wanted.

Without this, LowTotal can go negative (given it's an unsigned integer) and then appears as ~4Gig, which is a bit silly.

I beliee this fixes Anthony Wright's bug #733 in Bugzilla
(http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=733). Credit to Anthony for noticing the problem, and figuring out that he was actually seeing an unsigned int going "negative".

Cheers,
Mark

#2 lore raw
Quoted 6 lines

Applied, but have you tested with 'mem=' on the domain cmdline to give it a memmap bigger than its original allocation of memory? In this case it looks like the code in mm/init-xen.c does the right thing in tandem with this patch (i.e., it increments totalhigh_pages for each not-currently-present page, and you then decrement again when the not-present pages get added to the balloon). But I'm not 100% certain and it could do with being tested.

Good point.

I checked through that code, and agreed with your assessment. Also just tested it, my domain booted successfully with mem=4G and was able to expand (and shrink again) without exploding or doing anything obviously crazy.

Cheers,
Mark

Quoted 18 lines

Thanks,
Keir

Quoted 14 lines · Mark Williamson

I knocked up a quick patch to fix the balloon driver's handling of highmem pages. Should apply cleanly to the Linux dev tree. I can also submit it for 3.1 if wanted.

Without this, LowTotal can go negative (given it's an unsigned integer) and then appears as ~4Gig, which is a bit silly.

I beliee this fixes Anthony Wright's bug #733 in Bugzilla
(http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=733). Credit to Anthony for noticing the problem, and figuring out that he was actually seeing an unsigned int going "negative".

Cheers,
Mark

Signature · 4 lines
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!