From nobody Thu May 2 09:46:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1627648050; cv=none; d=zohomail.com; s=zohoarc; b=KYE8Ao2TKkvfj1IBqVmDd6ptBCTYMLqTdPvMoVh1eFl81b9g4gafD6GHMf5oD1s/mcz1OeNBpaQgfLbBBSetP8IEM3SfShySbyywLvY13BP+stw9Ufw2Xd/hfmpEQuP9g3qgrp9d1pp8ihx24XvsBBJvEZjuU0XSTYhOXlVfKBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627648050; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=STW5H69fSsC13fe3Jx/wYhcL86JL/EDIbDX/LWOUm7g=; b=G8QoDihCBGPn6eZarvogd60+cw/OsrgqvWGGFeBhd/H/0KGVYSXdHSmPQiX3XOqIcuwdiQSkOgI6rmX8BpjlAU9PJtVJCNjV2i4QodDyRzUEN9Cjkjmuq1PMXE1kSlRW6cAEwaFHwyFRhJujxfte8LiAICIA1Loa65c/8FcaVqo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 162764805081295.32423484198785; Fri, 30 Jul 2021 05:27:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.162516.298014 (Exim 4.92) (envelope-from ) id 1m9RbS-0004Pl-AG; Fri, 30 Jul 2021 12:27:02 +0000 Received: by outflank-mailman (output) from mailman id 162516.298014; Fri, 30 Jul 2021 12:27:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m9RbS-0004Pe-7F; Fri, 30 Jul 2021 12:27:02 +0000 Received: by outflank-mailman (input) for mailman id 162516; Fri, 30 Jul 2021 12:27:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m9RbQ-0004PS-A6 for xen-devel@lists.xenproject.org; Fri, 30 Jul 2021 12:27:00 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2157da37-5f3a-42a3-a71f-ebcc43af65db; Fri, 30 Jul 2021 12:26:59 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9DC05222E3; Fri, 30 Jul 2021 12:26:58 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 701DC137FD; Fri, 30 Jul 2021 12:26:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id wK0nGhLwA2FOVgAAGKfGzw (envelope-from ); Fri, 30 Jul 2021 12:26:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2157da37-5f3a-42a3-a71f-ebcc43af65db DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627648018; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=STW5H69fSsC13fe3Jx/wYhcL86JL/EDIbDX/LWOUm7g=; b=Sz7QOrKjl7GYHTYcZ1GmQTkGmt99HIvgUfohUD9TlfBIkxgx9KB5kdVhoqRtssHmGyh72X EMZs87M8SsE3MQ4i4nmW34ipSHm1QzWHbpOEFAyfMVxTodG2rxJupGKsdSrVlHB2c16Ne8 0Qcipzn0ZUowchx3AWS+OojHVkhkFcA= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v3 1/2] tools/xenstore: set oom score for xenstore daemon on Linux Date: Fri, 30 Jul 2021 14:26:42 +0200 Message-Id: <20210730122643.2043-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210730122643.2043-1-jgross@suse.com> References: <20210730122643.2043-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1627648052074100005 Content-Type: text/plain; charset="utf-8" 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) per default to -500 (this translates to 50% of dom0 memory size) in order to allow xenstored to use large amounts of memory without being killed. The percentage of dom0 memory above which the oom killer is allowed to kill xenstored can be set via XENSTORED_OOM_MEM_THRESHOLD in xencommons. Make sure the pid file isn't a left-over from a previous run delete it before starting xenstored. Signed-off-by: Juergen Gross --- V2: - set oom score from launch script (Julien Grall) - split off open file descriptor limit setting (Julien Grall) V3: - make oom killer threshold configurable (Julien Grall) --- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 7 +++++++ tools/hotplug/Linux/launch-xenstore.in | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hot= plug/Linux/init.d/sysconfig.xencommons.in index 00cf7f91d4..5ad4fe0818 100644 --- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in +++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in @@ -48,6 +48,13 @@ XENSTORED_ARGS=3D # Only evaluated if XENSTORETYPE is "daemon". #XENSTORED_TRACE=3D[yes|on|1] =20 +## Type: integer +## Default: 50 +# +# Percentage of dom0 memory size the xenstore daemon can use before the +# OOM killer is allowed to kill it. +#XENSTORED_OOM_MEM_THRESHOLD=3D50 + ## Type: string ## Default: @LIBEXEC@/boot/xenstore-stubdom.gz # diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/l= aunch-xenstore.in index 019f9d6f4d..1747c96065 100644 --- a/tools/hotplug/Linux/launch-xenstore.in +++ b/tools/hotplug/Linux/launch-xenstore.in @@ -59,11 +59,17 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . = @CONFIG_DIR@/@CONFIG_LEAF echo "No xenstored found" exit 1 } + [ -z "$XENSTORED_OOM_MEM_THRESHOLD" ] || XENSTORED_OOM_MEM_THRESHOLD=3D50 + XS_OOM_SCORE=3D-$(($XENSTORED_OOM_MEM_THRESHOLD * 10)) + + rm -f @XEN_RUN_DIR@/xenstored.pid =20 echo -n Starting $XENSTORED... $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS =20 systemd-notify --booted 2>/dev/null || timeout_xenstore $XENSTORED || exi= t 1 + XS_PID=3D`cat @XEN_RUN_DIR@/xenstored.pid` + echo $XS_OOM_SCORE >/proc/$XS_PID/oom_score_adj =20 exit 0 } --=20 2.26.2 From nobody Thu May 2 09:46:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1627648046; cv=none; d=zohomail.com; s=zohoarc; b=CsOw1g5YF2LKkyD8GvZYlhaskTfefDaVpaunvIRuwMxPkSoF5PQNWMlJ+M2dWrAY3y5PNwaSHYA03QCFW9ms/61NY1tmpHvF46dKa0C+wcPZimAnZCiyYVMY5kWCY/+boswdqo+v1PxCnFjVIDMDNtUjqbhSrNPLWuGOXuZUTVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627648046; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aVgd7I4DSuetcgd/27P69oOnpKyUEJbbUJKDnpuahN4=; b=O13xk0jJr+GSpx0xocP1nqt92dBZ3uXyciOP90S4PrzijfBfUhyReHpp/rfw2wqBEDvnUW9zX0TJQoSJb1NIVZq7IWqLL4wh9NSzh6DjIn4V45YleBw54beMD7LwYPEBEMzKZHu4Zr5VS1hmUV/D1p2sYgGpYlJghfQ35cZh+u8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1627648046273964.4226815675642; Fri, 30 Jul 2021 05:27:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.162517.298027 (Exim 4.92) (envelope-from ) id 1m9RbT-0004g1-IZ; Fri, 30 Jul 2021 12:27:03 +0000 Received: by outflank-mailman (output) from mailman id 162517.298027; Fri, 30 Jul 2021 12:27:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m9RbT-0004fu-FQ; Fri, 30 Jul 2021 12:27:03 +0000 Received: by outflank-mailman (input) for mailman id 162517; Fri, 30 Jul 2021 12:27:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m9RbR-0004PY-C1 for xen-devel@lists.xenproject.org; Fri, 30 Jul 2021 12:27:01 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 6f6e3d8e-f131-11eb-98a9-12813bfff9fa; Fri, 30 Jul 2021 12:26:59 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CC4512233F; Fri, 30 Jul 2021 12:26:58 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id A45B4137F9; Fri, 30 Jul 2021 12:26:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id kDLaJhLwA2FOVgAAGKfGzw (envelope-from ); Fri, 30 Jul 2021 12:26:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6f6e3d8e-f131-11eb-98a9-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627648018; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aVgd7I4DSuetcgd/27P69oOnpKyUEJbbUJKDnpuahN4=; b=i6Je2YxDCN0NlWmH4d5F/fOp5+FORTrNZWQMvEhT+aUPXWHYIKZlvYaLQMFfYKWKrWh1UI e/ZCDiVBuPF9GgO78bnrLroXVXM3g1N5lgjTUaDGqPO/soc0y93/uCSWaJR5jRFs1OmmKq ojE83M/GRr85xO4Q8AcVsmHXD4xU9Xc= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v3 2/2] tools/xenstore: set open file descriptor limit for xenstored Date: Fri, 30 Jul 2021 14:26:43 +0200 Message-Id: <20210730122643.2043-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210730122643.2043-1-jgross@suse.com> References: <20210730122643.2043-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1627648048030100001 Content-Type: text/plain; charset="utf-8" Add 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.). Signed-off-by: Juergen Gross --- 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(+) diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hot= plug/Linux/init.d/sysconfig.xencommons.in index 5ad4fe0818..2b682415f4 100644 --- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in +++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in @@ -32,6 +32,13 @@ # Changing this requires a reboot to take effect. #XENSTORED=3D@XENSTORED@ =20 +## Type: integer +## Default: 32768 +# +# Select maximum number of domains supported by xenstored. +# Only evaluated if XENSTORETYPE is "daemon". +#XENSTORED_MAX_N_DOMAINS=3D32768 + ## Type: string ## Default: "" # diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/l= aunch-xenstore.in index 1747c96065..3f8b33dd32 100644 --- a/tools/hotplug/Linux/launch-xenstore.in +++ b/tools/hotplug/Linux/launch-xenstore.in @@ -54,6 +54,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @C= ONFIG_DIR@/@CONFIG_LEAF =20 [ "$XENSTORETYPE" =3D "daemon" ] && { [ -z "$XENSTORED_TRACE" ] || XENSTORED_ARGS=3D"$XENSTORED_ARGS -T @XEN_LO= G_DIR@/xenstored-trace.log" + [ -z "$XENSTORED_MAX_N_DOMAINS" ] && XENSTORED_MAX_N_DOMAINS=3D32768 [ -z "$XENSTORED" ] && XENSTORED=3D@XENSTORED@ [ -x "$XENSTORED" ] || { echo "No xenstored found" @@ -63,6 +64,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @C= ONFIG_DIR@/@CONFIG_LEAF XS_OOM_SCORE=3D-$(($XENSTORED_OOM_MEM_THRESHOLD * 10)) =20 rm -f @XEN_RUN_DIR@/xenstored.pid + N_FILES=3D$(($XENSTORED_MAX_N_DOMAINS * 5 + 100)) =20 echo -n Starting $XENSTORED... $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS @@ -70,6 +72,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @C= ONFIG_DIR@/@CONFIG_LEAF systemd-notify --booted 2>/dev/null || timeout_xenstore $XENSTORED || exi= t 1 XS_PID=3D`cat @XEN_RUN_DIR@/xenstored.pid` echo $XS_OOM_SCORE >/proc/$XS_PID/oom_score_adj + prlimit --pid $XS_PID --nofile=3D$N_FILES =20 exit 0 } --=20 2.26.2