From patchwork Fri Jul 10 11:53:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 1326716 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=citrix.com header.i=@citrix.com header.a=rsa-sha256 header.s=securemail header.b=GYXPL8FC; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B3BKW4TVWz9sRK for ; Fri, 10 Jul 2020 21:54:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 26C86888D1; Fri, 10 Jul 2020 11:54:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ll-9ey74My_c; Fri, 10 Jul 2020 11:54:19 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6C9B786B8C; Fri, 10 Jul 2020 11:54:19 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5AA3CC0890; Fri, 10 Jul 2020 11:54:19 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id B9B27C016F for ; Fri, 10 Jul 2020 11:54:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7A7C7888A8 for ; Fri, 10 Jul 2020 11:53:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ns0aF0AsMBtP for ; Fri, 10 Jul 2020 11:53:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 0A1BA888A6 for ; Fri, 10 Jul 2020 11:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1594382023; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Xp80c/f0aaP4MLMiOPnvu7OpHnZ4kG//CL1rb6mvSGA=; b=GYXPL8FClE5PwtpDflDoGGAHKUz8cw2WABGQilQSH4422PeWCy0SNx07 Be1t0qnon1TTLmdQ7xHQki+gKw1O36wsiiN3NNyi51dmB7K+y5OmC8MrZ JgzqVMgTpH7526iezcTnF1+0q2W+Ntm9bL8uV/KRJVRq3cwc+C728gwLz k=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: o5B5xH9jXwsW6wCmFNxuEepdeBMM/AALI5FZ/kA9yEhQPe9ErNOk7OJs/XBXdwAfGjsY3XyNSS Qo4AWpSbgOfdw8seN0vi0SKyIAQsGUIDiTAl7dp9Cc55G9+gXdgNMCJUmVBic5TbYbkKmnMIbx mBrFSwXhzTTFK5i/CbiMkM/TMTm6YwoJewRuJ0GZoXZdQLBNOpcJYt049v+ObJMiKgQtbOTIvg dNgZ9SA4QiODN8qeAW4rH2nTwWEtnlpP+Pn55JX4JvFh+/KAOserD7ysWZuANONo3cC8v9Qcja aro= X-SBRS: 2.7 X-MesageID: 22062601 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,335,1589256000"; d="scan'208";a="22062601" From: Ross Lagerwall To: Date: Fri, 10 Jul 2020 12:53:13 +0100 Message-ID: <20200710115313.18319-1-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Cc: Ross Lagerwall Subject: [ovs-dev] [PATCH] vswitchd: Pass MCL_ONFAULT to mlockall X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" mlockall locks thread stack pages into memory, even pages which have not yet been demand-paged. As vswitchd has a lot of threads and the default stack size on x86_64 is 8 MiB, this consumes a lot of memory. On two systems I looked at, vswitchd used ~150 MiB of RSS when idle after startup. Use the new MCL_ONFAULT flag to only lock pages into memory once they have been demand-paged in. This still satisfies the requirement that vswitchd is not swapped out but frees up ~144 MiB of unswappable memory (18 threads x 8 MiB). After this, vswitchd uses ~6 MiB when idle after startup. Signed-off-by: Ross Lagerwall --- vswitchd/ovs-vswitchd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c index 1e72b628b..e4d482521 100644 --- a/vswitchd/ovs-vswitchd.c +++ b/vswitchd/ovs-vswitchd.c @@ -92,7 +92,10 @@ main(int argc, char *argv[]) if (want_mlockall) { #ifdef HAVE_MLOCKALL - if (mlockall(MCL_CURRENT | MCL_FUTURE)) { +#ifndef MCL_ONFAULT +#define MCL_ONFAULT 0 +#endif + if (mlockall(MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT)) { VLOG_ERR("mlockall failed: %s", ovs_strerror(errno)); } else { set_memory_locked();