x86: use 'dom0_mem' to limit the number of pages for dom0
PATCH 1/1 x86: use 'dom0_mem' to limit the number of pages for dom0
# HG changeset patch
# User David Vrabel <[email protected]>
# Date 1313404957 -3600
# Node ID 1ec6c392d40f37032b0c845094c7ee6ba69740fd # Parent 8d6edc3d26d26931f3732a2008fb4818bc7bab2d
x86: use 'dom0_mem' to limit the number of pages for dom0
Use the 'dom0_mem' command line option to set the maximum number of pages for dom0. dom0 can use then use the XENMEM_maximum_reservation memory op to automatically find this limit and reduce the size of any page tables etc.
xen/arch/x86/domain_build.c +2 -0
@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 }#endif + d->max_pages =min (max_pages, avail); +return nr_pages; }
Quoted 11 lines · David Vrabel
# HG changeset patch
# User David Vrabel <[email protected]>
# Date 1313404957 -3600
# Node ID1ec6c392d40f37032b0c845094c7ee6ba69740fd# Parent8d6edc3d26d26931f3732a2008fb4818bc7bab2d
x86: use 'dom0_mem' to limit the number of pages for dom0Use the '
dom0_mem' command line option to set the maximum number of pages for dom0. dom0 can use then use theXENMEM_maximum_reservationmemory op to automatically find this limit and reduce the size of any page tables etc.
So .. I was actually curious about this -how did this use to work with 2.6.18? In there, if you did 'dom0_mem=max:2GB' it would limit the amount of memory - so how does it do that?
xen/arch/x86/domain_build.c static unsigned long __init compute_dom0 · line 258
Quoted 12 lines
Signed-off-by David Vrabel <[email protected]>diff -r
8d6edc3d26d2-r1ec6c392d40fxen/arch/x86/domain_build.cxen/arch/x86/domain_build.c +2
-0@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 }#endif + d->max_pages =min (max_pages, avail); +
don't you need the amount of p2m as well? Or is that all limited by d->max_pages?
Quoted 8 lines
xen/arch/x86/domain_build.c +0
-0return nr_pages; }_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · David Vrabel
x86: use '
dom0_mem' to limit the number of pages for dom0Use the '
dom0_mem' command line option to set the maximum number of pages for dom0. dom0 can use then use theXENMEM_maximum_reservationmemory op to automatically find this limit and reduce the size of any page tables etc.So .. I was actually curious about this -how did this use to work with 2.6.18? In there, if you did 'dom0_mem=max:2GB' it would limit the amount of memory - so how does it do that?
I don't know. I've not really looked at how the older kernels did it.
Quoted 7 lines
Quoted 7 lines
diff -r
8d6edc3d26d2-r1ec6c392d40fxen/arch/x86/domain_build.cxen/arch/x86/domain_build.c +0
-0@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 }#endif
Quoted 5 lines
xen/arch/x86/domain_build.c static unsigned long __init compute_dom0 · line 258
Quoted 2 lines
xen/arch/x86/domain_build.c +2
-0+ d->max_pages =min (max_pages, avail); +don't you need the amount of p2m as well? Or is that all limited by
d->max_pages?
Do you mean the initial p2m supplied by Xen? I think that just covers the initial pages.
The p2m structure maintained by the kernel appears to be dynamically allocated based on what mappings are required.
David
Quoted 9 lines · David Vrabel
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · David Vrabel
x86: use '
dom0_mem' to limit the number of pages for dom0Use the '
dom0_mem' command line option to set the maximum number of pages for dom0. dom0 can use then use theXENMEM_maximum_reservationmemory op to automatically find this limit and reduce the size of any page tables etc.
Quoted 5 lines
Quoted 3 lines
So .. I was actually curious about this -how did this use to work with 2.6.18? In there, if you did 'dom0_mem=max:2GB' it would limit the amount of memory - so how does it do that?
I don't know. I've not really looked at how the older kernels did it.
The classic-Xen kernels didn't try and munge the pseudo-physical (i.e. RAM) address map with the machine (i.e. I/O) address map together in the way pvops does, they just treated them as two orthogonal address spaces (which has it's own issues, /proc/iomem is a complete fiction for example). They don't really suffer from the same issues wrt e.g. tracking where the I/O hole was before you clipped the initial amount of RAM and all that.
The key difference is that classic-Xen kernels called both XENMEM_memory_map and XENMEM_machine_memory_map and dealt with both, whereas pvops (dom0) calls XENMEM_machine_memory_map and tries to figure out how much of the E820_RAM therein it can actually use based on nr_pages and such. You've used XENMEM_maximum_reservation in your followup series which I think is a suitable surrogate for calling XENMEM_memory_map (although I didn't check).
The linkage between mm setup and balloon driver setup in the classic kernels was more explicit too IIRC.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
diff -r
8d6edc3d26d2-r1ec6c392d40fxen/arch/x86/domain_build.cxen/arch/x86/domain_build.c +0
-0@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 }#endif
Quoted 8 lines
Quoted 5 lines
xen/arch/x86/domain_build.c static unsigned long __init compute_dom0 · line 258
Quoted 2 lines
xen/arch/x86/domain_build.c +2
-0+ d->max_pages =min (max_pages, avail); +don't you need the amount of p2m as well? Or is that all limited by
d->max_pages?Do you mean the initial p2m supplied by Xen? I think that just covers the initial pages.
I think so too.
Quoted 2 lines
The p2m structure maintained by the kernel appears to be dynamically allocated based on what mappings are required.
IIRC it is expanded around start of day to cover the start of day max mappings etc (using BRK space) and further expanded later on dynamically.
Quoted 7 lines
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 8 lines · Ian Campbell
The key difference is that classic-Xen kernels called both
XENMEM_memory_mapandXENMEM_machine_memory_mapand dealt with both, whereas pvops (dom0) callsXENMEM_machine_memory_mapand tries to figure out how much of theE820_RAMtherein it can actually use based onnr_pagesand such. You've usedXENMEM_maximum_reservationin your followup series which I think is a suitable surrogate for callingXENMEM_memory_map(although I didn't check).
XENMEM_memory_map for dom0 doesn't work as nothing populates the map.
Classic-Xen kernels appear to invent a memory map based only on nr_pages and it's non-obvious where it gets any other limit from (I didn't look that hard though).
I did originally make XENMEM_memory_map work for dom0 but using XENMEM_maximum_reservation looked more relevant.
David
Keir,
Since Konrad is considering submitting the Linux kernel patch needing this Xen patch to the 3.0 stable tree, I think this should be a candidate for Xen 4.1.2.
Thanks.
David
Quoted 31 lines · David Vrabel
# HG changeset patch
# User David Vrabel <[email protected]>
# Date 1313404957 -3600
# Node ID1ec6c392d40f37032b0c845094c7ee6ba69740fd# Parent8d6edc3d26d26931f3732a2008fb4818bc7bab2d
x86: use 'dom0_mem' to limit the number of pages for dom0Use the '
dom0_mem' command line option to set the maximum number of pages for dom0. dom0 can use then use theXENMEM_maximum_reservationmemory op to automatically find this limit and reduce the size of any page tables etc.Signed-off-by David Vrabel <[email protected]>diff -r
8d6edc3d26d2-r1ec6c392d40fxen/arch/x86/domain_build.cxen/arch/x86/domain_build.c +2
-0@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 }#endif + d->max_pages =min (max_pages, avail); +return nr_pages; }_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 19 lines
Quoted 1 line
Quoted 1 line · David Vrabel
# HG changeset patch
# User David Vrabel <[email protected]>
# Date 1313404957 -3600
# Node ID1ec6c392d40f37032b0c845094c7ee6ba69740fd# Parent8d6edc3d26d26931f3732a2008fb4818bc7bab2d
x86: use 'dom0_mem' to limit the number of pages for dom0Use the '
dom0_mem' command line option to set the maximum number of pages for dom0. dom0 can use then use theXENMEM_maximum_reservationmemory op to automatically find this limit and reduce the size of any page tables etc.Signed-off-by David Vrabel <[email protected]>diff -r
8d6edc3d26d2-r1ec6c392d40fxen/arch/x86/domain_build.c
xen/arch/x86/domain_build.c static unsigned long __init compute_dom0 · line 257
Quoted 4 lines
xen/arch/x86/domain_build.c +1
-0@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 }#endif + d->max_pages =min (max_pages, avail);
Only having noticed this hypervisor side change in the patch set as it now got applied to -unstable already, I have to object to this: It is not memory hotplug compatible (i.e. Dom0, at least with a non-pvops kernel, could have got ballooned up past the original limit once memory got added to the system, whereas now you limit it to what was there at boot time). If anything, this should be set to just max_pages, not considering the amount of available memory at all.
Besides that the assignment needs to be saturating, as struct domain's max_pages member is only "unsigned int", whereas the local variables are all "unsigned long". So in the end this should really be an equivalent of
d->max_pages = min(max_pages, UINT_MAX);
Jan
Quoted 9 lines
xen/arch/x86/domain_build.c +1
-0+return nr_pages; }_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · Jan Beulich
Quoted 7 lines
diff -r
8d6edc3d26d2-r1ec6c392d40fxen/arch/x86/domain_build.cxen/arch/x86/domain_build.c Mon Aug 15 11:42:37 2011 +0100 renamed from xen/arch/x86/domain_build.c Sat Aug 13 10:14:58 2011 +0100 +0
-0@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 } #endif
Quoted 8 lines
xen/arch/x86/domain_build.c Mon Aug 15 11:42:37 2011 +0100 static unsigned long __init compute_dom0 · line 257
Quoted 1 line
xen/arch/x86/domain_build.c Mon Aug 15 11:42:37 2011 +0100 renamed from xen/arch/x86/domain_build.c Sat Aug 13 10:14:58 2011 +0100 +1
-0+ d->max_pages = min(max_pages, avail);Only having noticed this hypervisor side change in the patch set as it now got applied to -unstable already, I have to object to this: It is not memory hotplug compatible (i.e. Dom0, at least with a non-pvops kernel, could have got ballooned up past the original limit once memory got added to the system, whereas now you limit it to what was there at boot time).
That's true for any domain isn't it? Yet we've got by so far. The max-mem can be adjusted after a domain is created, so it's not incompatible.
Quoted 2 lines
If anything, this should be set to just
max_pages, not considering the amount of available memory at all.
I suspect that nullifies the aim of the patch...
Quoted 6 lines
Besides that the assignment needs to be saturating, as struct domain's
max_pagesmember is only "unsigned int", whereas the local variables are all "unsigned long". So in the end this should really be an equivalent ofd->max_pages = min(max_pages, UINT_MAX);
We should make d->max_pages a ulong or u64.
-- Keir
Quoted 19 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 7 lines · Jan Beulich
Quoted 7 lines
diff -r
8d6edc3d26d2-r1ec6c392d40fxen/arch/x86/domain_build.cxen/arch/x86/domain_build.c Mon Aug 15 11:42:37 2011 +0100 renamed from xen/arch/x86/domain_build.c Sat Aug 13 10:14:58 2011 +0100 +0
-0@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 } #endifQuoted 8 lines
xen/arch/x86/domain_build.c Mon Aug 15 11:42:37 2011 +0100 static unsigned long __init compute_dom0 · line 257
Quoted 1 line
xen/arch/x86/domain_build.c Mon Aug 15 11:42:37 2011 +0100 renamed from xen/arch/x86/domain_build.c Sat Aug 13 10:14:58 2011 +0100 +1
-0+ d->max_pages = min(max_pages, avail);Only having noticed this hypervisor side change in the patch set as it now got applied to -unstable already, I have to object to this: It is not memory hotplug compatible (i.e. Dom0, at least with a non-pvops kernel, could have got ballooned up past the original limit once memory got added to the system, whereas now you limit it to what was there at boot time).
Quoted 2 lines
That's true for any domain isn't it? Yet we've got by so far. The max-mem can be adjusted after a domain is created, so it's not incompatible.
For a DomU it's natural that it may need adjustment, but for Dom0 it's not (at least not to me).
Quoted 4 lines
Quoted 2 lines
If anything, this should be set to just
max_pages, not considering the amount of available memory at all.I suspect that nullifies the aim of the patch...
Why - there's still a big difference between using LONG_MAX unconditionally and using whatever was specified via "dom0_mem=max:".
Quoted 8 lines
Quoted 6 lines
Besides that the assignment needs to be saturating, as struct domain's
max_pagesmember is only "unsigned int", whereas the local variables are all "unsigned long". So in the end this should really be an equivalent ofd->max_pages = min(max_pages, UINT_MAX);We should make
d->max_pagesa ulong or u64.
I'd rather not, as for now there's no good reason for this to be a 64-bit variable (as we can't get even close to the 16Tb it would take to overflow this). But then again I expect you to say that the few extra REX prefixes don't matter all that much...
Jan
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 5 lines
Besides that the assignment needs to be saturating, as struct domain's
max_pagesmember is only "unsigned int", whereas the local variables are all "unsigned long". So in the end this should really be an equivalent of
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
d->max_pages = min(max_pages, UINT_MAX);We should make
d->max_pagesa ulong or u64.I'd rather not, as for now there's no good reason for this to be a 64-bit variable (as we can't get even close to the 16Tb it would take to overflow this). But then again I expect you to say that the few extra REX prefixes don't matter all that much...
Ha, you'd be right! :-)
I'll leave it to David to champion his patch. I'll note I added it for 4.1.2 as well, if we decide there is a better way we will need to change it there in advance of that release, and preferably -rc1 as well.
-- Keir
Quoted 27 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · David Vrabel
x86: use '
dom0_mem' to limit the number of pages for dom0Use the '
dom0_mem' command line option to set the maximum number of pages for dom0. dom0 can use then use theXENMEM_maximum_reservationmemory op to automatically find this limit and reduce the size of any page tables etc.Signed-off-by David Vrabel <[email protected]>diff -r
8d6edc3d26d2-r1ec6c392d40fxen/arch/x86/domain_build.cxen/arch/x86/domain_build.c static unsigned long __init compute_dom0 · line 257
Quoted 4 lines
xen/arch/x86/domain_build.c +1
-0@@ -254,6 +254,8 @@ static unsigned long __init compute_dom0 }#endif + d->max_pages =min (max_pages, avail);Only having noticed this hypervisor side change in the patch set as it now got applied to -unstable already, I have to object to this: It is not memory hotplug compatible (i.e. Dom0, at least with a non-pvops kernel, could have got ballooned up past the original limit once memory got added to the system, whereas now you limit it to what was there at boot time). If anything, this should be set to just
max_pages, not considering the amount of available memory at all.
Quoted 6 lines
Besides that the assignment needs to be saturating, as struct domain's
max_pagesmember is only "unsigned int", whereas the local variables are all "unsigned long". So in the end this should really be an equivalent ofd->max_pages = min(max_pages, UINT_MAX);
Yeah, this makes sense. I'll send another patch tomorrow.
David