Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4816689rdb; Tue, 12 Dec 2023 10:02:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGMpos94SFq0ye4M72Qpg403qfbiScYL6SYTnkPz1xKWzAj0I9yE2psLQmD43IAFCdNUXM X-Received: by 2002:a05:6870:968d:b0:203:1653:fb79 with SMTP id o13-20020a056870968d00b002031653fb79mr109925oaq.53.1702404175046; Tue, 12 Dec 2023 10:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702404175; cv=none; d=google.com; s=arc-20160816; b=X/PzBS6Aha+ZPdsU8vzmMlI2apHMTUSAaMjI6b/BG00U11AqG2rzaJ4QFSZc3Cagbo JdS0F9IxxoJbZz28Sag0yUaa3s6y/EkKWt3fzt9hNb/oTp6y7easxQyoTo4kdYz9rkDo mp79ywKHXSY8xTKgjh1iwINFEJHqnh8PzFSg25tSgMu2xSOKiZM8VgPdES0OHQ53tqpn +nm2/vaiIcOCw9F80/DaSRhlMeaCdP1AkvqRc1a2IuxqJKyU0hJp5in5yESpEpT+X7Lc Rr5dPyOHZSdCFiwTXVRi2x/REYS0Ax9IfihX2fUS/pKc4RVkGeLNYQIBx/DN8RnVWMO5 gufA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=KEjNKWXCWFo0aaGshHfuAhiPFyNmIHyFQZWgfT5pa+Y=; fh=zqMjvwQ/d7wXU/3cJ5r5KatpF8Fs6MFrI3zf2HIewrU=; b=aJgiWvtqkTbRxuM/dCFw4r9IDOrKLI26YJB+y3MD1M9K5THXCYVWrnF5BKXLAJjxga pdDXP6GGYcNz3eyLpaOrGD840JdFSCze77kq/le9v4h7h9wLBePEw2Tk3va3H9WedpV5 8ZvcA61ODzz640UdUjfrb/OfXEDA6zjNtoSaqzblHREStJ9FcTYTSwzWA/Lmxtx8HuJ2 7Hn7GifTv7BXan7AkXOxz5/mSp243LPdSCvPNuRFQofCJ7BCEKxDn2z2t9Mu1OOp3q5s 9aBVlnhyJnIONJMj7cMoPeaCqdHfuQkVd1gUz3z0nc9QVHi/+E0iW75qD6t2GabQcOW5 09yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@devkernel.io header.s=fm2 header.b=f+FUOvrr; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=iu5dDUpU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id a32-20020a056870d62000b001faf5018ea5si3348363oaq.187.2023.12.12.10.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 10:02:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@devkernel.io header.s=fm2 header.b=f+FUOvrr; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=iu5dDUpU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0E83F8050637; Tue, 12 Dec 2023 10:02:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377080AbjLLSCX (ORCPT + 99 others); Tue, 12 Dec 2023 13:02:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377072AbjLLSCV (ORCPT ); Tue, 12 Dec 2023 13:02:21 -0500 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D1FDD3 for ; Tue, 12 Dec 2023 10:02:27 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 3DBEB5C0274; Tue, 12 Dec 2023 13:02:24 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Tue, 12 Dec 2023 13:02:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devkernel.io; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1702404144; x=1702490544; bh=KEjNKWXCWF o0aaGshHfuAhiPFyNmIHyFQZWgfT5pa+Y=; b=f+FUOvrrc9NOMQU1WECMkwiC8p +xCvP3zljcMza/GUnPpVMhQ2+bKL/PMYBxIj74NiXtLXyX2ZlisWjgVmF/tzZzoF byxoQ4B7LRtjPFZ8gKy90OXJa7BlIl3d3utJ+S7KvVBYYyOngFst4ZF26Pb5FYXB uWWAgjQeJjC5HZuCjwAJda9f4zd5Q27EuQlXULnW2nktrvsqtp9CYJ/eqkAB9b+8 nFdl3x01Ex1mUrt/1Tw5zbg46VKpl4OSuBA8FTQInaoOXX4LZW07cACR9uuqBq4U GQUH+CON2BxFUn4QQsNuXDgZ01waM/KlkzSPXmEyLQNLs/Fzs1gCslxS6uIA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1702404144; x=1702490544; bh=KEjNKWXCWFo0aaGshHfuAhiPFyNm IHyFQZWgfT5pa+Y=; b=iu5dDUpUhQT9PNPLgOcTfCFNzjKECP4fwZU+cZTd5VO1 c/XcKROxgn6U3UU1RIZUNatpN8eUECqMuO4Ebd8SubAABIMMvy/ommLaUVC7eFvW o46O+KiZzFuQwiVzBDnzIFMxjQjz596n8PcRsjPjJjm6UkUJb7sISKXmXAY23RO9 GmE9Fn0lrMYirll1fTOyaZTipJPBvvzwXcTBxHNsol5kwpvhHKbb5ga8WJtRi20u x/zM5HgD0HSEBic1eQooLZ34MkZVrTHrdKoBRyPzL+gybB8WL7jWRCqxhnXNviv5 Wn/NAOBnQ+/BVcBiLG72JmZAJVuUKHLLk9PPd24pIA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudelgedguddthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdfu thgvfhgrnhcutfhovghstghhfdcuoehshhhrseguvghvkhgvrhhnvghlrdhioheqnecugg ftrfgrthhtvghrnheplefgteffgfejtdelfeekgfetjefftdejgfdvudffiedtueevvdej gfevvdfgleetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshhhrhesuggvvhhkvghrnhgvlhdrihho X-ME-Proxy: Feedback-ID: i84614614:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 80F88B6008D; Tue, 12 Dec 2023 13:02:22 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1283-g327e3ec917-fm-20231207.002-g327e3ec9 MIME-Version: 1.0 Message-Id: In-Reply-To: References: <20231204234906.1237478-1-shr@devkernel.io> <20231204234906.1237478-3-shr@devkernel.io> Date: Tue, 12 Dec 2023 10:02:02 -0800 From: "Stefan Roesch" To: "David Hildenbrand" , kernel-team@fb.com Cc: "Andrew Morton" , hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3 2/4] mm/ksm: add sysfs knobs for advisor Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 10:02:52 -0800 (PST) On Tue, Dec 12, 2023, at 5:45 AM, David Hildenbrand wrote: > On 05.12.23 00:49, Stefan Roesch wrote: >> This adds four new knobs for the KSM advisor to influence its behaviour. >> >> The knobs are: >> - advisor_mode: >> none: no advisor (default) >> scan-time: scan time advisor >> - advisor_max_cpu: 70 (default, cpu usage percent) >> - advisor_min_pages: 500 (default) >> - advisor_max_pages: 30000 (default) >> - advisor_target_scan_time: 200 (default in seconds) >> >> The new values will take effect on the next scan round. >> >> Signed-off-by: Stefan Roesch >> --- >> mm/ksm.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 127 insertions(+) >> >> diff --git a/mm/ksm.c b/mm/ksm.c >> index b27010fa2e946..18b7185bbc65b 100644 >> --- a/mm/ksm.c >> +++ b/mm/ksm.c >> @@ -3735,6 +3735,128 @@ static ssize_t smart_scan_store(struct kobject *kobj, >> } >> KSM_ATTR(smart_scan); >> >> +static ssize_t advisor_mode_show(struct kobject *kobj, >> + struct kobj_attribute *attr, char *buf) >> +{ >> + const char *output; >> + >> + if (ksm_advisor == KSM_ADVISOR_NONE) >> + output = "[none] scan-time"; >> + else if (ksm_advisor == KSM_ADVISOR_SCAN_TIME) >> + output = "none [scan-time]"; >> + >> + return sysfs_emit(buf, "%s\n", output); >> +} >> + >> +static ssize_t advisor_mode_store(struct kobject *kobj, >> + struct kobj_attribute *attr, const char *buf, >> + size_t count) >> +{ >> + if (sysfs_streq("scan-time", buf)) >> + ksm_advisor = KSM_ADVISOR_SCAN_TIME; >> + else if (sysfs_streq("none", buf)) >> + ksm_advisor = KSM_ADVISOR_NONE; >> + else >> + return -EINVAL; >> + >> + /* Set advisor default values */ >> + init_advisor(); > > Is the "init_advisor()" really required? > The init_advisor is required for the following scenario: - advisor is used - advisor is turned off - pages_to_scan is used and run for some time - advisor is turned on again ==> Advisor would start with two high values for the first calculation >> + set_advisor_defaults(); > > That function should go to this patch. > > > I'll move it to this patch. I'll also look if I can should move init_advisor() to this patch. > -- > Cheers, > > David / dhildenb