[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] Purpose of mem-max command

On 10/11/2015 08:47 PM, Simon Hobson wrote:
Bear in mind that I'm not even an advanced user ...

On 11 Oct 2015, at 11:45, Marco Guazzone <marco.guazzone@xxxxxxxxx> wrote:

What I don't understand is how to use it effectively.
Could you provide a practical example of how to use it?

I don't know if it works on an already running VM - I've only used it in VM 
config files. For example, this is from one of my VM configs :
memory  = '512'
maxmem  = '2048'

This starts the VM with 512M of memory, but it can be increased to 2G using 
mem-set from the command line. Just starting it with 512M (without the maxmem 
line) means it's configured for 512M max and it can't be increased past that.

AIUI, when a machine (whether virtual or bare metal) starts up, certain memory 
structures (kernal tables) are setup based on the amount of memory installed. I 
assume that this constrains the machine from dynamically adding memory above 
what was present at startup - or in this context, configured by the maxmem 
argument to Xen. I know that in the past there has been some discussion around 
the configuration of Dom0 - and that there is a small memory saving from 
specifying it's max size at boot time as it then allocates these tables 
according to the smaller ram size configured instead of the full machine memory 
which it's never going to use.

That is nearly correct. Just add "initial" at the appropriate place:
The initial memory structures of the kernel are sized according to the
maxmem parameter.

Some operating systems are able to cope with memory hotplug. They are
able to extend their memory structures related to the size of physical
memory. Linux kernels must have been configured with
XEN_BALLOON_MEMORY_HOTPLUG to support this when running as Xen guests.

"xl mem-max" on the command line will just do that. In case the OS
supports memory hotplug it will extend its memory administration data
and a later "xl mem-set" will be able to add memory up to the new

The following is a short description of the feature taken from the
above mentioned kernel configuration option:

 Memory hotplug support for Xen balloon driver allows expanding memory
 available for the system above limit declared at system startup.
 It is very useful on critical systems which require long
 run without rebooting.

 Memory could be hotplugged in following steps:

 1) dom0: xl mem-max <domU> <maxmem>
    where <maxmem> is >= requested memory size,

 2) dom0: xl mem-set <domU> <memory>
    where <memory> is requested memory size; alternatively memory
    could be added by writing proper value to
    /sys/devices/system/xen_memory/xen_memory0/target or
    /sys/devices/system/xen_memory/xen_memory0/target_kb on dumU,

 3) domU: for i in /sys/devices/system/memory/memory*/state; do \
          [ "`cat "$i"`" = offline ] && echo online > "$i"; done

 Memory could be onlined automatically on domU by adding following line
 to udev rules:

SUBSYSTEM=="memory", ACTION=="add", RUN+="/bin/sh -c '[ -f /sys$devpath/state ] && echo online > /sys$devpath/state'"

 In that case step 3 should be omitted.

HTH, Juergen

Xen-users mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.