Skip to contentSkip to conversation

how mem-set / balloon changes totalram_pages

DISCUSSION weiming 2 participants 2 messages Nov 16, 2007 – Dec 2, 2007

lore
Share & tools
lore

weiming

author
#0 lore raw

Hi,

I find that after I use xm mem-set to change the current memory allocation of a dom, the MemTotal in /proc/meminfo will give the current allocation.

In my understanding, the balloon driver simply alloc / free pages, so the MemTotal should not be changed. Only the free memory will be affected.

In normal linux, the value of MemTotal comes from "totalram_pages" defined in arch/i386/mm/init.c

I tried to located the code in Xen, which changes the variable, but I didn't find such code.

I tried to locate the implementation of HYPERCALL_memory_op, but I can only traced to
"call hypercall_page + STR(...)"

Can someone tell me where I can find the actual implementation of those hypercalls?

Thanks in advance!

weiming

#1 lore raw
Quoted 8 lines

I find that after I use xm mem-set to change the current memory allocation of a dom, the MemTotal in /proc/meminfo will give the current allocation.

In my understanding, the balloon driver simply alloc / free pages, so the MemTotal should not be changed. Only the free memory will be affected.

Quoted 5 lines

In normal linux, the value of MemTotal comes from "totalram_pages" defined in arch/i386/mm/init.c

I tried to located the code in Xen, which changes the variable, but I didn't find such code.

This variable is updated by the balloon driver in XenLinux (drivers/xen/balloon/balloon.c). totalram_pages is declared as an extern there - when the balloon changes size, totalram_pages is updated accordingly.

Quoted 6 lines

I tried to locate the implementation of HYPERCALL_memory_op, but I can only traced to
"call hypercall_page + STR(...)"

Can someone tell me where I can find the actual implementation of those hypercalls?

Well, the code you found implements the call into Xen. It gets handled eventually by do_memory_op in xen/common/memory.c under the Xen repository. This implements the memory ops and then returns to the guest (and thence to the balloon driver).

Hope that helps,

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!