Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4834757rdb; Tue, 12 Dec 2023 10:28:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZltTmxFfQSObW5AN2tO6poyQAnMjH+sss2k4/uhqxrn19Nfo23hhVweNzxMmQ9XyXMenO X-Received: by 2002:a17:902:830c:b0:1d3:47ba:ba48 with SMTP id bd12-20020a170902830c00b001d347baba48mr367332plb.133.1702405700004; Tue, 12 Dec 2023 10:28:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702405699; cv=none; d=google.com; s=arc-20160816; b=tOlrHCQUsSYxTf8NO3iaxyTdhvKUc/mhCvMwxGxZdj++on4QXuAh/VM90foTDBniRs 6BYYhalrZiVq3NGASC3BqxBO1y1BWre1VEPPkoGq3LFLTLmeJRuOyK35Pw8ewZHqFkat gcaOdO3HyI+jgy5kZL4DFc6sNFiK5pujLg4499Q8cMdoaCMy3dU+w1W4TeqzZBXk4L/T Q9QES8DrWSujWPgblhP8tH0P92TeljQSjz//pFFmCPO08/zfMHZiqelHWWdxNjuiZcZ7 6KIUDeH1WB6mCA6kXc9vQyJD15kCFV1Vivac0dgayfRAtiQmLkwrZ5IGFCX0PWXPTtl/ cdOg== 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=ByMLCrgGmGDFrbIZSJUQUarY0bYPrEjGYeN84abVNZM=; fh=zqMjvwQ/d7wXU/3cJ5r5KatpF8Fs6MFrI3zf2HIewrU=; b=eO45zL2uso867SZV7ipbyavGlOOU5UnqoIusovmDPbFcv/Wbi4Hqh3NYrTI8ypH5P4 6gyjYvqK4EerC6aaq3i2uMYpCDiADVbXu8MWP+2STo757qRbylDOzuw4Q4JrgRDZ95NC GJjVUxb45LB/1WB8H/Iu8uqVkNynPZQ9jYZ0aUjr5awj1puQbj+1m0DbpQHU1xAvwNH+ s7kxkwcEI2jTgztIRrDRAdEzVPvDuee0RduK247ReqReksF+l+IzVnCA+LgP29J5UONl pDDpeTEFVRoUJNrBDOCNMBzihEsbJQcveTogkNkiA1LG+wujm7whnJLYS1yxldX7E1Cv AOkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@devkernel.io header.s=fm2 header.b=VBPVgbSF; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Zzv9Fsfk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d4-20020a170902b70400b001cfcf3dd310si8112825pls.505.2023.12.12.10.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 10:28:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@devkernel.io header.s=fm2 header.b=VBPVgbSF; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Zzv9Fsfk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 1890480A5F11; Tue, 12 Dec 2023 10:28:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233000AbjLLS2D (ORCPT + 99 others); Tue, 12 Dec 2023 13:28:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232546AbjLLS2C (ORCPT ); Tue, 12 Dec 2023 13:28:02 -0500 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C77ED3 for ; Tue, 12 Dec 2023 10:28:08 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id F2FB55C03E7; Tue, 12 Dec 2023 13:28:07 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Tue, 12 Dec 2023 13:28:08 -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=1702405687; x=1702492087; bh=ByMLCrgGmG DFrbIZSJUQUarY0bYPrEjGYeN84abVNZM=; b=VBPVgbSF6tXt6d5NnsWb3ygDa5 W2oOSvk32nPFLq2q5dwWDPpY64o8GckAPy6W57r2VJk/XaR2y0OKa9DLDUTjlhUp ZCKgvpeiECRTJTz/1G8YoAlmqiWzjVdq1ZxQWK02N+iSDiFtS7cOQzrzUIFOyvwZ LUF/8YxM7ZwJzyUaK/3Loqpsy+m/9Usuhcjhkd0SVzGeYZnCO3NVftlafy18Dp13 OlEqD0B8Hh4NML7p79ePIUYG9jEhjv1xb1riz1JSWna7kPb7ry89272plSjWi85P +0gcT7cBExKOr8W6P4jePqL5vW6N1JQ0Gom2rQgl2TCdSr21PTNeBNFG9TAQ== 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=1702405687; x=1702492087; bh=ByMLCrgGmGDFrbIZSJUQUarY0bYP rEjGYeN84abVNZM=; b=Zzv9FsfkJoJ6ek7dEdJxF3FSDy8LyHvcTHOO14MTxOU0 VoMRkSzPR6MG8fZRJVEQ1VhL9R4MjlB1wZbN9hCmIoZd+BMX0zFRyKWd9sJX2mtm BcsEeNQcQnBuYoxApnJDJB6UjcxAtSNHE+pZMNgrhe+u71X2+SqwH+sZNrvBM+u6 4mgIfw0xcpwHguO3hw5d86XwABgHZmLI/FaxphfThovDvtjeE6j3j1vEuZkkkYzI JGu8zS3SpZ/+vP/ZmNtcyB3newlgm+xKlma0Mgu+jXXT8UlnNSfAI0ACxHPg4O6u BxgJDGdye1Sq2ZLM35sfvUS7Ks5RI5rw9dWOd0DDuA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudelgedguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdfu thgvfhgrnhcutfhovghstghhfdcuoehshhhrseguvghvkhgvrhhnvghlrdhioheqnecugg ftrfgrthhtvghrnheplefgteffgfejtdelfeekgfetjefftdejgfdvudffiedtueevvdej gfevvdfgleetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshhhrhesuggvvhhkvghrnhgvlhdrihho X-ME-Proxy: Feedback-ID: i84614614:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 23E89B6008D; Tue, 12 Dec 2023 13:28:07 -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: <2ce7945d-a3c0-4bc6-8713-a36281cb793e@app.fastmail.com> In-Reply-To: <2e22fe80-2280-4003-923d-8749fe85b81a@redhat.com> References: <20231204234906.1237478-1-shr@devkernel.io> <20231204234906.1237478-3-shr@devkernel.io> <2e22fe80-2280-4003-923d-8749fe85b81a@redhat.com> Date: Tue, 12 Dec 2023 10:27:46 -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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 10:28:17 -0800 (PST) On Tue, Dec 12, 2023, at 10:07 AM, David Hildenbrand wrote: > On 12.12.23 19:02, Stefan Roesch wrote: >> >> >> 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 > > Can't set_advisor_defaults() handle that? > Yes, I can move the advisor_ctx = (const struct advisor_ctx){ 0 }; into set_advisor_defaults(). > -- > Cheers, > > David / dhildenb