Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp73610rdd; Wed, 22 Nov 2023 09:42:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlni4ohOk0t2dEfYeVbzV/zXJ9W9sWUqLo8DQNzhT9z5f+Ps3p7vQbrQ7743ZFW+U7i+Hr X-Received: by 2002:a17:903:244e:b0:1c5:cf7c:4d50 with SMTP id l14-20020a170903244e00b001c5cf7c4d50mr187482pls.18.1700674935017; Wed, 22 Nov 2023 09:42:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700674935; cv=none; d=google.com; s=arc-20160816; b=E3kihuhV4iOLjznPulH74Hnz9TPCX/xIjHRvOwFCqlSvLFU1FWfeopDhuza0x7g5UI F+YtCt5groSXPqlOaVyFE16/WT6I9Y+E9WriZwpqJUBbaRcaFoW7O8jAubWKBWEd3Swp GUMecyM4Llc15stF547eFm/u9J0qE5md8fbSSIKp6WhXu66L9rkxNizieOIGEFWH4Bjb Apxvkl6zxsgLRpB2WpeZ40Y+kawFM9yvUrciG67X6Dwx75sDx64TZMbtJls/IVnp1/Wp AY5FT+3HfNsDDFPPXSkXMG40FSoUWsG17MSjd6FOTb3xST5BTM9mAdNDTJy9JoKQOjpq Vxmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:feedback-id:dkim-signature :dkim-signature; bh=ySFRnjVXIn+mbgngaY9ZSCV315yJK2CgStdUpd2vf9c=; fh=bfQiakWAvDNKtrSkzJPjktKQf8cBmdZZtJcoO52Y1KQ=; b=BfKEimeQvKQtcatrsU5AuADf9yyVwfE+1ZTsF+0fPQYU+aUGDMBTNlIH8MHOsbu2c7 VutPT61o85BgHtWzj26cFMQzXq34bYfl64qkFuHQ5XnqNRIp3Gspb2L4h7oVgm3OI70h NfG5rhUeVZVsZPw4XEcXeCTr6BSzWWWk7BYPeHYM0aBGBXL1t4TvGj7Mw2H+zIJK9IDk eCRJM8UrABAW6CZ3Ic58x77g6b8vNKVX09GgWG6f1onShHatyDJRkbvnXFY2/IAx4J8F eIrHDawK7B1ZK+n44C33WRuQ/T7gzEqXMe1C5vH496CXVrbbV+rCdcnmkTrm8ZTnNd3L Tqbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@devkernel.io header.s=fm2 header.b=mecjN16j; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=1ahuRQDZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u7-20020a17090341c700b001cf576043fbsi9552753ple.575.2023.11.22.09.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 09:42:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@devkernel.io header.s=fm2 header.b=mecjN16j; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=1ahuRQDZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 73AFD81DDBF2; Wed, 22 Nov 2023 09:42:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231771AbjKVRmD (ORCPT + 99 others); Wed, 22 Nov 2023 12:42:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbjKVRmC (ORCPT ); Wed, 22 Nov 2023 12:42:02 -0500 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964EDDD for ; Wed, 22 Nov 2023 09:41:58 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 81ED03200AAB; Wed, 22 Nov 2023 12:41:57 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 22 Nov 2023 12:41:58 -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:sender :subject:subject:to:to; s=fm2; t=1700674917; x=1700761317; bh=yS FRnjVXIn+mbgngaY9ZSCV315yJK2CgStdUpd2vf9c=; b=mecjN16jsUyEDNK8LN YJLDmsYwT0YrpMgokzQbmPzkdtogNjHbqHYSmZlFtbHd3Rt69TskDvXyDTcEruIp /cds067BfaGr5e9CXiJs9EvgojAdzJmpNQgFU5wCFB35ravobaEtpF2pMgFd64Ab oq1lsoYhPESycURCNiwDRUmZF70Y46rbzPHsN03pBwzOJLud5NHzPhcsIoc+qxP2 xW0fRe0InPoN3yJAMwNtivIYw2TOKdVwZn0jkCuG1zwi0G6enAPOysOX9grJTC3f We3i8HZIDI1YGxu5wE3XXGRNDz9MW17zcyJvHKkcTReLUuq/wYstxjYhcD1/qF8m Jphw== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1700674917; x=1700761317; bh=ySFRnjVXIn+mb gngaY9ZSCV315yJK2CgStdUpd2vf9c=; b=1ahuRQDZnBXsgsS05WBrfYgD7IJWe fu2h/8MRZM/gsebqOGAbh4xlxttUHZOgPkepUpzN7p+gDkZqTOEBxAg1z1rgPxgf 1KE6ZEPG3i3TJZaclmgdOr4a9CzndeMSadQAAveZTngHtKUc1187HwylFmTACd5i OBlQyz4kToABKZD0LYMifnvxsTkUtHEgJuqZ0WighKuRydvtCZ8k1EGNHcVwFMgM i2D8S+3z58xcPFMRcMkoc5FuY+ICr+dxZPSyD1DihAXJPSpPG+N/sXi+B5euRPs3 Gjyh8e9wia+PGLq2vKJ8ueTMkeAktQh1tgeiAUPk+CCAxAMLDLqQJ6fgg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvfevufffjgfkgggtsehttdertddtredtnecuhfhrohhmpefuthgv fhgrnhcutfhovghstghhuceoshhhrhesuggvvhhkvghrnhgvlhdrihhoqeenucggtffrrg htthgvrhhnpeevlefggffhheduiedtheejveehtdfhtedvhfeludetvdegieekgeeggfdu geeutdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hshhhrseguvghvkhgvrhhnvghlrdhioh X-ME-Proxy: Feedback-ID: i84614614:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 12:41:53 -0500 (EST) References: <20231028000945.2428830-1-shr@devkernel.io> <20231028000945.2428830-3-shr@devkernel.io> User-agent: mu4e 1.10.3; emacs 29.1 From: Stefan Roesch To: David Hildenbrand Cc: kernel-team@fb.com, akpm@linux-foundation.org, hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 2/4] mm/ksm: add sysfs knobs for advisor Date: Wed, 22 Nov 2023 09:41:16 -0800 In-reply-to: Message-ID: <87y1epr8gx.fsf@devkernel.io> MIME-Version: 1.0 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 09:42:12 -0800 (PST) David Hildenbrand writes: > On 28.10.23 02:09, Stefan Roesch wrote: >> This adds four new knobs for the KSM advisor to influence its behaviour. >> The knobs are: >> - advisor_mode: >> 0: no advisor (default) >> 1: scan time advisor >> - advisor_min_cpu: 15 (default, cpu usage percent) >> - 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 | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 154 insertions(+) >> diff --git a/mm/ksm.c b/mm/ksm.c >> index e18fecfb359d..042ecaeb0beb 100644 >> --- a/mm/ksm.c >> +++ b/mm/ksm.c >> @@ -351,6 +351,14 @@ static void init_advisor(void) >> advisor_ctx.cpu_time = 0; >> } > > > [...] > >> * Use previous scan time if available, otherwise use current scan time as an >> * approximation for the previous scan time. >> @@ -3719,6 +3727,146 @@ 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) >> +{ >> + return sysfs_emit(buf, "%u\n", ksm_advisor); >> +} >> + >> +static ssize_t advisor_mode_store(struct kobject *kobj, >> + struct kobj_attribute *attr, const char *buf, >> + size_t count) >> +{ >> + unsigned int mode; >> + int err; >> + >> + err = kstrtouint(buf, 10, &mode); >> + if (err) >> + return -EINVAL; >> + if (mode > KSM_ADVISOR_LAST) >> + return -EINVAL; >> + >> + /* Set advisor default values */ >> + ksm_advisor = mode; >> + init_advisor(); >> + set_advisor_defaults(); >> + >> + return count; > > Can we instead use human-readable strings? > > "none" and "scan-time" should be clearer. > I'll change the interface to use strings instead of numbers.