From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54091C61D97 for ; Wed, 22 Nov 2023 17:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343629AbjKVRmD (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.