xen/balloon: add late_initcall_sync() for initial ballooning done
Subsystems (3)
Juergen Gross
maintainerPATCH v4 1/1 xen/balloon: add late_initcall_sync() for initial ballooning done
When running as PVH or HVM guest with actual memory < max memory the hypervisor is using "populate on demand" in order to allow the guest to balloon down from its maximum memory size. For this to work correctly the guest must not touch more memory pages than its target memory size as otherwise the PoD cache will be exhausted and the guest is crashed as a result of that.
In extreme cases ballooning down might not be finished today before the init process is started, which can consume lots of memory.
In order to avoid random boot crashes in such cases, add a late init call to wait for ballooning down having finished for PVH/HVM guests.
Warn on console if initial ballooning fails, panic() after stalling for more than 3 minutes per default. Add a module parameter for changing this timeout.
---
V2:
- add warning and panic() when stalling (Marek Marczykowski-Górecki)
- don't wait if credit > 0
V3:
- issue warning only after ballooning failed (Marek Marczykowski-Górecki)
- make panic() timeout configurable via parameter
V4:
- fix boot parameter (Boris Ostrovsky)
- set new state directly in update_schedule() (Boris Ostrovsky)
--- .../admin-guide/kernel-parameters.txt | 7 ++ drivers/xen/balloon.c | 86 ++++++++++++++----- 2 files changed, 70 insertions(+), 23 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +7 -0
@@ -6349,6 +6349,13 @@ improve timer resolution at the expense of processing more timer interrupts. + xen.balloon_boot_timeout= [XEN] + The time (in seconds) to wait before giving up to boot + in case initial ballooning fails to free enough memory. + Applies only when running as HVM or PVH guest and + started with less memory configured than allowed at + max. Default is 180. + xen.event_eoi_delay= [XEN] How long to delay EOI handling in case of event storms (jiffies). Default is 10.
drivers/xen/balloon.c +63 -23
173 lines not on this page · raw message
Signature · 1 line
2.26.2
Quoted 13 lines · Juergen Gross
When running as PVH or HVM guest with actual memory < max memory the hypervisor is using "populate on demand" in order to allow the guest to balloon down from its maximum memory size. For this to work correctly the guest must not touch more memory pages than its target memory size as otherwise the PoD cache will be exhausted and the guest is crashed as a result of that.
In extreme cases ballooning down might not be finished today before the init process is started, which can consume lots of memory.
In order to avoid random boot crashes in such cases, add a late init call to wait for ballooning down having finished for PVH/HVM guests.
Quoted 7 lines
Warn on console if initial ballooning fails,
panic()after stalling for more than 3 minutes per default. Add a module parameter for changing this timeout.Cc <[email protected]>Reported-by Marek Marczykowski-Górecki <[email protected]>Signed-off-by Juergen Gross <[email protected]>
Quoted 19 lines · Boris Ostrovsky
Quoted 17 lines · Juergen Gross
When running as PVH or HVM guest with actual memory < max memory the hypervisor is using "populate on demand" in order to allow the guest to balloon down from its maximum memory size. For this to work correctly the guest must not touch more memory pages than its target memory size as otherwise the PoD cache will be exhausted and the guest is crashed as a result of that.
In extreme cases ballooning down might not be finished today before the init process is started, which can consume lots of memory.
In order to avoid random boot crashes in such cases, add a late init call to wait for ballooning down having finished for PVH/HVM guests.
Warn on console if initial ballooning fails,
panic()after stalling for more than 3 minutes per default. Add a module parameter for changing this timeout.
Quoted 7 lines
Quoted 3 lines
Cc <[email protected]>Reported-by Marek Marczykowski-Górecki <[email protected]>Signed-off-by Juergen Gross <[email protected]>Reviewed-by Boris Ostrovsky <[email protected]>
This appears to have noticeable effect on boot time (and boot experience in general).
I have
memory=1024
maxmem=8192
And my boot time (on an admittedly slow box) went from 33 to 45 seconds. And boot pauses in the middle while it is waiting for ballooning to complete.
[ 5.062714] xen:balloon: Waiting for initial ballooning down having finished. [ 5.449696] random: crng init done
[ 34.613050] xen:balloon: Initial ballooning down finished.
So at least I think we should consider bumping log level down from info.
-boris
Juergen Gross
maintainerQuoted 40 lines · Boris Ostrovsky
Quoted 19 lines · Boris Ostrovsky
Quoted 17 lines · Juergen Gross
When running as PVH or HVM guest with actual memory < max memory the hypervisor is using "populate on demand" in order to allow the guest to balloon down from its maximum memory size. For this to work correctly the guest must not touch more memory pages than its target memory size as otherwise the PoD cache will be exhausted and the guest is crashed as a result of that.
In extreme cases ballooning down might not be finished today before the init process is started, which can consume lots of memory.
In order to avoid random boot crashes in such cases, add a late init call to wait for ballooning down having finished for PVH/HVM guests.
Warn on console if initial ballooning fails,
panic()after stalling for more than 3 minutes per default. Add a module parameter for changing this timeout.Quoted 7 lines
Quoted 3 lines
Cc <[email protected]>Reported-by Marek Marczykowski-Górecki <[email protected]>Signed-off-by Juergen Gross <[email protected]>Reviewed-by Boris Ostrovsky <[email protected]>This appears to have noticeable effect on boot time (and boot experience in general).
I have
memory=1024
maxmem=8192
Quoted 6 lines
And my boot time (on an admittedly slow box) went from 33 to 45 seconds. And boot pauses in the middle while it is waiting for ballooning to complete.
[ 5.062714] xen:balloon: Waiting for initial ballooning down having finished. [ 5.449696] random: crng init done
[ 34.613050] xen:balloon: Initial ballooning down finished.
This shows that before it was just by chance that the PoD cache wasn't exhausted.
Quoted 1 line
So at least I think we should consider bumping log level down from info.
Which level would you prefer? warn?
And if so, would you mind doing this while committing (I have one day off tomorrow)?
Juergen
Quoted 44 lines · Juergen Gross
Quoted 43 lines · Boris Ostrovsky
Quoted 19 lines · Boris Ostrovsky
Quoted 17 lines · Juergen Gross
When running as PVH or HVM guest with actual memory < max memory the hypervisor is using "populate on demand" in order to allow the guest to balloon down from its maximum memory size. For this to work correctly the guest must not touch more memory pages than its target memory size as otherwise the PoD cache will be exhausted and the guest is crashed as a result of that.
In extreme cases ballooning down might not be finished today before the init process is started, which can consume lots of memory.
In order to avoid random boot crashes in such cases, add a late init call to wait for ballooning down having finished for PVH/HVM guests.
Warn on console if initial ballooning fails,
panic()after stalling for more than 3 minutes per default. Add a module parameter for changing this timeout.Quoted 7 lines
Quoted 3 lines
Cc <[email protected]>Reported-by Marek Marczykowski-Górecki <[email protected]>Signed-off-by Juergen Gross <[email protected]>Reviewed-by Boris Ostrovsky <[email protected]>This appears to have noticeable effect on boot time (and boot experience in general).
I have
memory=1024
maxmem=8192And my boot time (on an admittedly slow box) went from 33 to 45 seconds. And boot pauses in the middle while it is waiting for ballooning to complete.
Quoted 6 lines
Quoted 3 lines
[ 5.062714] xen:balloon: Waiting for initial ballooning down having finished. [ 5.449696] random: crng init done
[ 34.613050] xen:balloon: Initial ballooning down finished.This shows that before it was just by chance that the PoD cache wasn't exhausted.
True.
Quoted 5 lines
Quoted 2 lines
So at least I think we should consider bumping log level down from info.
Which level would you prefer? warn?
Notice? Although that won't make much difference as WARN is the default level.
I suppose we can't turn scrubbing off at this point?
Quoted 2 lines
And if so, would you mind doing this while committing (I have one day off tomorrow)?
Yes, of course.
-boris
Juergen Gross
maintainerQuoted 58 lines · Boris Ostrovsky
Quoted 44 lines · Juergen Gross
Quoted 43 lines · Boris Ostrovsky
Quoted 19 lines · Boris Ostrovsky
Quoted 17 lines · Juergen Gross
When running as PVH or HVM guest with actual memory < max memory the hypervisor is using "populate on demand" in order to allow the guest to balloon down from its maximum memory size. For this to work correctly the guest must not touch more memory pages than its target memory size as otherwise the PoD cache will be exhausted and the guest is crashed as a result of that.
In extreme cases ballooning down might not be finished today before the init process is started, which can consume lots of memory.
In order to avoid random boot crashes in such cases, add a late init call to wait for ballooning down having finished for PVH/HVM guests.
Warn on console if initial ballooning fails,
panic()after stalling for more than 3 minutes per default. Add a module parameter for changing this timeout.Quoted 7 lines
Quoted 3 lines
Cc <[email protected]>Reported-by Marek Marczykowski-Górecki <[email protected]>Signed-off-by Juergen Gross <[email protected]>Reviewed-by Boris Ostrovsky <[email protected]>This appears to have noticeable effect on boot time (and boot experience in general).
I have
memory=1024
maxmem=8192And my boot time (on an admittedly slow box) went from 33 to 45 seconds. And boot pauses in the middle while it is waiting for ballooning to complete.
Quoted 6 lines
Quoted 3 lines
[ 5.062714] xen:balloon: Waiting for initial ballooning down having finished. [ 5.449696] random: crng init done
[ 34.613050] xen:balloon: Initial ballooning down finished.This shows that before it was just by chance that the PoD cache wasn't exhausted.
True.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
So at least I think we should consider bumping log level down from info.
Which level would you prefer? warn?
Notice? Although that won't make much difference as WARN is the default level.
Right. That was my thinking.
Quoted 1 line
I suppose we can't turn scrubbing off at this point?
I don't think we can be sure a ballooned page wasn't in use before. And it could contain some data e.g. from the loaded initrd, maybe even put there by the boot loader. So no, I wouldn't want to do that by default.
We could add another value to the xen_scrub_pages boot parameter, like xen_scrub_pages=not-at-boot or some such. But this should be another patch. And it should be documented that initrd or kernel data might leak.
Quoted 5 lines
Quoted 2 lines
And if so, would you mind doing this while committing (I have one day off tomorrow)?
Yes, of course.
Thanks.
Juergen
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
And if so, would you mind doing this while committing (I have one day off tomorrow)?
Yes, of course.
Thanks.
So I'll change this to pr_notice, even though it's not the best solution.
-boris
Quoted 1 line · Boris Ostrovsky
This appears to have noticeable effect on boot time (and boot experience in general).
Yes, this is kind of intentional. It avoids killing the domain ("out of PoD memory") for the price of increased boot time. I still wonder why it wasn't an issue before, although it could just be a race that was less likely to loose before.
You can find some analysis of mine here:
https://lore.kernel.org/xen-devel/YXFxKC4shCATB913@mail-itl/
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Boris Ostrovsky
AppliedQuoted 13 lines · Juergen Gross
When running as PVH or HVM guest with actual memory < max memory the hypervisor is using "populate on demand" in order to allow the guest to balloon down from its maximum memory size. For this to work correctly the guest must not touch more memory pages than its target memory size as otherwise the PoD cache will be exhausted and the guest is crashed as a result of that.
In extreme cases ballooning down might not be finished today before the init process is started, which can consume lots of memory.
In order to avoid random boot crashes in such cases, add a late init call to wait for ballooning down having finished for PVH/HVM guests.
Quoted 7 lines
Warn on console if initial ballooning fails,
panic()after stalling for more than 3 minutes per default. Add a module parameter for changing this timeout.Cc <[email protected]>Reported-by Marek Marczykowski-Górecki <[email protected]>Signed-off-by Juergen Gross <[email protected]>
Applied to for-linus-5-16b.
-boris