tools/xenstore: set resource limits of xenstored
v2 cover tools/xenstore: set resource limits of xenstored
Set some limits for xenstored in order to avoid it being killed by OOM killer, or to run out of file descriptors.
Changes in V2:
- split into 2 patches
- set limits from start script
Juergen Gross (2):
tools/xenstore: set oom score for xenstore daemon on Linux tools/xenstore: set open file descriptor limit for xenstored
tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 7 +++++++ tools/hotplug/Linux/launch-xenstore.in | 6 ++++++ 2 files changed, 13 insertions(+)
Signature · 1 line
2.26.2
PATCH v2 1/2 tools/xenstore: set oom score for xenstore daemon on Linux
Xenstored is absolutely mandatory for a Xen host and it can't be restarted, so being killed by OOM-killer in case of memory shortage is to be avoided.
Set /proc/$pid/oom_score_adj (if available) to -500 in order to allow xenstored to use large amounts of memory without being killed.
Make sure the pid file isn't a left-over from a previous run delete it before starting xenstored.
---
V2:
- set oom score from launch script (Julien Grall)
- split off open file descriptor limit setting (Julien Grall)
--- tools/hotplug/Linux/launch-xenstore.in | 3 +++ 1 file changed, 3 insertions(+)
tools/hotplug/Linux/launch-xenstore.in +3 -0
@@ -59,11 +59,14 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF echo "No xenstored found" exit 1 } + rm -f @XEN_RUN_DIR@/xenstored.pid echo -n Starting $XENSTORED... $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS systemd-notify --booted 2>/dev/null || timeout_xenstore $XENSTORED || exit 1 + XS_PID=`cat @XEN_RUN_DIR@/xenstored.pid` + echo -500 >/proc/$XS_PID/oom_score_adj exit 0 }
Signature · 1 line
2.26.2
Re: [PATCH v2 1/2] tools/xenstore: set oom score for xenstore daemon on Linux
Hi Juergen,
Quoted 9 lines · Juergen Gross
Xenstored is absolutely mandatory for a Xen host and it can't be restarted, so being killed by OOM-killer in case of memory shortage is to be avoided.
Set
/proc/$pid/oom_score_adj(if available) to -500 in order to allow xenstored to use large amounts of memory without being killed.Make sure the pid file isn't a left-over from a previous run delete it before starting xenstored.
This sentence is a bit confusing to read. Do you mean "*To* make sure....*,* delete it before"?
Quoted 16 lines
Signed-off-by Juergen Gross <[email protected]>---
V2:
- set oom score from launch script (Julien Grall)
- split off open file descriptor limit setting (Julien Grall)--- tools/hotplug/Linux/launch-xenstore.in | 3 +++ 1 file changed, 3 insertions(+)tools/hotplug/Linux/launch-xenstore.in +0
-0@@ -59,11 +59,14 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF echo "No xenstored found"
tools/hotplug/Linux/launch-xenstore.in test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF · line 69
Quoted 10 lines
tools/hotplug/Linux/launch-xenstore.in +3
-0exit 1 } + rm -f @XEN_RUN_DIR@/xenstored.pid echo -n Starting $XENSTORED... $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS systemd-notify --booted 2>/dev/null || timeout_xenstore $XENSTORED || exit 1 + XS_PID=`cat @XEN_RUN_DIR@/xenstored.pid` + echo -500 >/proc/$XS_PID/oom_score_adj
NIT: It would be worth considering to introduce a variable so this can be set from the configuration file.
With or without it:
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 1/2] tools/xenstore: set oom score for xenstore daemon on Linux
Quoted 7 lines · Julien Grall
Hi Juergen,
Quoted 4 lines · Juergen Gross
Xenstored is absolutely mandatory for a Xen host and it can't be restarted, so being killed by OOM-killer in case of memory shortage is to be avoided.
Quoted 7 lines
Quoted 5 lines
Set
/proc/$pid/oom_score_adj(if available) to -500 in order to allow xenstored to use large amounts of memory without being killed.Make sure the pid file isn't a left-over from a previous run delete it before starting xenstored.
This sentence is a bit confusing to read. Do you mean "*To* make sure....*,* delete it before"?
Yes, will change it.
Quoted 20 lines
Quoted 20 lines
Signed-off-by Juergen Gross <[email protected]>---
V2:
- set oom score from launch script (Julien Grall)
- split off open file descriptor limit setting (Julien Grall)
---
tools/hotplug/Linux/launch-xenstore.in| 3 +++1 file changed, 3 insertions(+)tools/hotplug/Linux/launch-xenstore.in +0
-0@@ -59,11 +59,14 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons&& . @CONFIG_DIR@/@CONFIG_LEAF
echo "No xenstored found"
exit 1
}
Quoted 8 lines
Quoted 6 lines
+ rm -f @XEN_RUN_DIR@/xenstored.pid
echo -n Starting $XENSTORED...
$XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS systemd-notify --booted 2>/dev/null ||timeout_xenstore$XENSTORED || exit 1 + XS_PID=cat @XEN_RUN_DIR@/xenstored.pid
+ echo -500 >/proc/$XS_PID/oom_score_adjNIT: It would be worth considering to introduce a variable so this can be set from the configuration file.
Do you have any scenario in mind where this would be beneficial?
I'm not against it, but I'm wondering why anybody would want that to be configurable.
Quoted 4 lines
With or without it:
Acked-by Julien Grall <[email protected]>
Juergen
Re: [PATCH v2 1/2] tools/xenstore: set oom score for xenstore daemon on Linux
Hi Juergen,
Quoted 47 lines · Juergen Gross
Quoted 7 lines · Julien Grall
Hi Juergen,
Quoted 4 lines · Juergen Gross
Xenstored is absolutely mandatory for a Xen host and it can't be restarted, so being killed by OOM-killer in case of memory shortage is to be avoided.
Quoted 7 lines
Quoted 5 lines
Set
/proc/$pid/oom_score_adj(if available) to -500 in order to allow xenstored to use large amounts of memory without being killed.Make sure the pid file isn't a left-over from a previous run delete it before starting xenstored.
This sentence is a bit confusing to read. Do you mean "*To* make sure....*,* delete it before"?
Yes, will change it.
Quoted 20 lines
Quoted 20 lines
Signed-off-by Juergen Gross <[email protected]>---
V2:
- set oom score from launch script (Julien Grall)
- split off open file descriptor limit setting (Julien Grall)
---
tools/hotplug/Linux/launch-xenstore.in| 3 +++1 file changed, 3 insertions(+)tools/hotplug/Linux/launch-xenstore.in +0
-0@@ -59,11 +59,14 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons&& . @CONFIG_DIR@/@CONFIG_LEAF
echo "No xenstored found"
exit 1
}Quoted 8 lines
Quoted 6 lines
+ rm -f @XEN_RUN_DIR@/xenstored.pid
echo -n Starting $XENSTORED...
$XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS systemd-notify --booted 2>/dev/null ||timeout_xenstore$XENSTORED || exit 1 + XS_PID=cat @XEN_RUN_DIR@/xenstored.pid
+ echo -500 >/proc/$XS_PID/oom_score_adjNIT: It would be worth considering to introduce a variable so this can be set from the configuration file.
Quoted 4 lines
Do you have any scenario in mind where this would be beneficial?
I'm not against it, but I'm wondering why anybody would want that to be configurable.
So from the commit message (and browsing a bit), I don't understand how -500 would fit every case. IOW why not -600/-700...?
If it is a random value, then we should consider to allow the user to modify it easily. If the value has a specific meaning, then I think this ought to be written in the commit message and possibly launch-xenstore.in.
Cheers,
Signature · 1 line
Julien Grall
PATCH v2 2/2 tools/xenstore: set open file descriptor limit for xenstored
In reply to Juergen GrossAdd a configuration item for the maximum number of domains xenstored should support and set the limit of open file descriptors accordingly.
For HVM domains there are up to 5 socket connections per domain (2 by the xl daemon process, and 3 by qemu). So set the ulimit for xenstored to 5 * XENSTORED_MAX_DOMAINS + 100 (the "+ 100" is for some headroom, like logging, event channel device, etc.).
---
V2:
- set ulimit form launch script (Julien Grall)
- split off from original patch (Julien Grall)
--- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 7 +++++++ tools/hotplug/Linux/launch-xenstore.in | 3 +++ 2 files changed, 10 insertions(+)
tools/hotplug/Linux/init.d/sysconfig.xencommons.in +7 -0
@@ -32,6 +32,13 @@ # Changing this requires a reboot to take effect. #XENSTORED=@XENSTORED@ +## Type: integer +## Default: 32768 +# +# Select maximum number of domains supported by xenstored. +# Only evaluated if XENSTORETYPE is "daemon". +#XENSTORED_MAX_N_DOMAINS=32768 + ## Type: string ## Default: "" #
tools/hotplug/Linux/launch-xenstore.in +3 -0
@@ -54,12 +54,14 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF [ "$XENSTORETYPE" = "daemon" ] && { [ -z "$XENSTORED_TRACE" ] || XENSTORED_ARGS="$XENSTORED_ARGS -T @XEN_LOG_DIR@/xenstored-trace.log" + [ -z "$XENSTORED_MAX_N_DOMAINS" ] && XENSTORED_MAX_N_DOMAINS=32768 [ -z "$XENSTORED" ] && XENSTORED=@XENSTORED@ [ -x "$XENSTORED" ] || { echo "No xenstored found" exit 1 } rm -f @XEN_RUN_DIR@/xenstored.pid + N_FILES=$(($XENSTORED_MAX_N_DOMAINS * 5 + 100)) echo -n Starting $XENSTORED... $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
@@ -67,6 +69,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF systemd-notify --booted 2>/dev/null || timeout_xenstore $XENSTORED || exit 1 XS_PID=`cat @XEN_RUN_DIR@/xenstored.pid` echo -500 >/proc/$XS_PID/oom_score_adj + prlimit --pid $XS_PID --nofile=$N_FILES exit 0 }
Signature · 1 line
2.26.2
Re: [PATCH v2 2/2] tools/xenstore: set open file descriptor limit for xenstored
Am Tue, 8 Jun 2021 07:58:39 +0200
schrieb Juergen Gross <[email protected]>:
Quoted 1 line
+#XENSTORED_MAX_N_DOMAINS=32768
This will break fillup.
Provide an empty variable like it is done for a few others in that file.
Olaf
Re: [PATCH v2 2/2] tools/xenstore: set open file descriptor limit for xenstored
Quoted 6 lines · Olaf Hering
Am Tue, 8 Jun 2021 07:58:39 +0200
schrieb Juergen Gross <[email protected]>:Quoted 1 line
+#XENSTORED_MAX_N_DOMAINS=32768
This will break fillup.
Why? You realize that above is a comment just documenting the default?
Quoted 1 line
Provide an empty variable like it is done for a few others in that file.
I'm following the pattern of basically all variables in that file, BTW.
Juergen
Re: [PATCH v2 2/2] tools/xenstore: set open file descriptor limit for xenstored
Am Fri, 11 Jun 2021 07:01:31 +0200
schrieb Juergen Gross <[email protected]>:
Quoted 1 line
Why? You realize that above is a comment just documenting the default?
That depends on the context. See https://bugzilla.opensuse.org/show_bug.cgi?id=1185682 for a reason why it should become an empty variable. But yes, we can patch that one too.
Olaf
Re: [PATCH v2 2/2] tools/xenstore: set open file descriptor limit for xenstored
Quoted 6 lines · Olaf Hering
Am Fri, 11 Jun 2021 07:01:31 +0200
schrieb Juergen Gross <[email protected]>:Quoted 1 line
Why? You realize that above is a comment just documenting the default?
That depends on the context. See https://bugzilla.opensuse.org/show_bug.cgi?id=1185682 for a reason why it should become an empty variable. But yes, we can patch that one too.
Isn't that a bug in fillup or the related rpm-macro? A variable set in the existing /etc/sysconfig/xencommons file only should be preserved.
In general I think we should be consistent in the file.
In case there is no downside for other distributions I'd recommend to switch all variables to your suggested pattern.
If there are disadvantages for others we should keep the current pattern as changing it now would break existing installations.
Any thoughts?
Juergen
Re: [PATCH v2 2/2] tools/xenstore: set open file descriptor limit for xenstored
Am Fri, 11 Jun 2021 09:07:24 +0200
schrieb Juergen Gross <[email protected]>:
Quoted 1 line
Isn't that a bug in fillup or the related rpm-macro?
No. Fillup expects a certain pattern: a bunch of comments and a single key=var right after that. With such format it might be able to adjust the comment and leave the key=var as it is. Without key=var it will see it as a stale comment, and removes the entire section of comments during the next package update.
Olaf
Ping?
Quoted 15 lines · Juergen Gross
Set some limits for xenstored in order to avoid it being killed by OOM killer, or to run out of file descriptors.
Changes in V2:
- split into 2 patches
- set limits from start scriptJuergen Gross (2):
tools/xenstore: set oom score for xenstore daemon on Linuxtools/xenstore: set open file descriptor limit for xenstoredtools/hotplug/Linux/init.d/sysconfig.xencommons.in | 7 +++++++ tools/hotplug/Linux/launch-xenstore.in | 6 ++++++ 2 files changed, 13 insertions(+)