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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F682C77B61 for ; Fri, 28 Apr 2023 10:58:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF1146B0071; Fri, 28 Apr 2023 06:58:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA14A6B0072; Fri, 28 Apr 2023 06:58:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B902F6B0074; Fri, 28 Apr 2023 06:58:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A94CC6B0071 for ; Fri, 28 Apr 2023 06:58:54 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 744151603CE for ; Fri, 28 Apr 2023 10:58:54 +0000 (UTC) X-FDA: 80730502188.14.280C6E8 Received: from outbound-smtp02.blacknight.com (outbound-smtp02.blacknight.com [81.17.249.8]) by imf07.hostedemail.com (Postfix) with ESMTP id 90F484001E for ; Fri, 28 Apr 2023 10:58:52 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of mgorman@techsingularity.net designates 81.17.249.8 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682679532; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=48pn7ZhvzI5sRbrZjCTna7TtfY9o7gda4KbKyc0VYAA=; b=yu3cydBzfeBtDxYlu1ydGcl/VXjjCwFa+tGgdg2YkiDuXuq2Fdn0W6+PMB32iAqTZWattm nP6LtXbcayb60DCZNynCIhHlWv13LtIrfLG9+VajmRXrsG6YB5YAOjAZFLiPxAgFYmFgZD KVhJJYSiEIcDrW0k9hEP3TefprRLVfI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of mgorman@techsingularity.net designates 81.17.249.8 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682679532; a=rsa-sha256; cv=none; b=TpTBE9uxFn19sqoAS+EXxZyDWCi4fQWJ5Jp6pkyN0W5opJ+vs3hOzfYKiP+bXalsZgNIlX XKoWS+YVaVoUHfDG75qIOSFQ9nM/QEOu9MJTtbN9bO5RtFnf/u60SElm9UzUazSc09BFP5 6svQ+1v+MzLYoFjXP5bAm6PNY7ylQHY= Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp02.blacknight.com (Postfix) with ESMTPS id A9597BAB51 for ; Fri, 28 Apr 2023 11:58:50 +0100 (IST) Received: (qmail 12660 invoked from network); 28 Apr 2023 10:58:50 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.21.103]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 28 Apr 2023 10:58:50 -0000 Date: Fri, 28 Apr 2023 11:58:48 +0100 From: Mel Gorman To: wenyang.linux@foxmail.com Cc: Andrew Morton , Oscar Salvador , William Lam , Pintu Kumar , Fu Wei , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: compaction: optimize compact_memory to comply with the admin-guide Message-ID: <20230428105848.ghtz5v3q6mug4hiw@techsingularity.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 90F484001E X-Stat-Signature: rjrn1cf9ibn6sqww39ts6eph4b79b476 X-Rspam-User: X-HE-Tag: 1682679532-389965 X-HE-Meta: U2FsdGVkX1/AZ2Xw+xB9NkGcVp8gkRoL6ODywbw7k08HJGWnPQ2caeoUGtf742uWGD57CR7PuAuDNzm/QHAS1WXiGhiGMlG1lob/N8caRpJIDx18MnkCIUGJL79r2Lsa/bInVDNIq8DBkBtGM7pvRBD77e3Hs6KZ0XwG23kTjpojJBXXpFUpBHgjcsMdId5ibf10yvtaBx8RTZI96h2wtm7Xl5DQ678lIYr0BHy30f2zjBqcZCsWN9dTReqxO8K0pdleeV6RSSn6AosGzxiTnc0HRFsW50BMIZS5OMhvoDhKMRo0pXgQNGS40iExaQPMXmOFSps3k07ps73iS972P2BaIbkpIczBcDEkczdbLjwxvH69BZqCmIe9mNqCWt1plvsMgGrPe4cWyif44OHa7NK4L6YPYnrXsYWvmJ1Al7BaNCuhXsMYRjzpQpdZcd1YfzPhDK5nBOA+/ipa5M+JAoIrJG1XPWhKiQGokZArM7cuNGGDgPTxlBNB5OrveNDyud626Q4uP4Z1n+UmgWcjnzgmA6y3rpH2iUREZOqzkBqTlXtb2C7UxMBGuWrylKWSvam0olUBzmk3TeQjHExFRdsX5t9Zuu3dhhCNsHfjn9GeVcJu9/RrGDN8Jdh05RYE1PdrcJoX8yocvTfWnkrzGQa7VoqxsdYX/q3QV0/4TgG8jbL0oyPRts+57l35BDXl6oP8mHKCt9bXR7solrX/oNYO9l3QFlxi61wkCNn4z80E/gjbthD7g1DPhiULQUPxsUpS3S1KCJYLekVybjKqlo8uQeS7qGQURbt//GHfX8tj1Kn6zjVOGH+8bj0Mj8VxHWPKu2VZXJVqMS6PiUIZQHSmEMysxLzXnZEtz5+sSc65Lnt3jbgVeY6OnahRaSfLKrBq3f7dctCbpUnkzshNf4QlezIZfgXWCG32K+LG+KOZtyEujfimV0qQFo1fppqujtG+jtcYWUHjcR57gjs A0mbrc6b r9lAqsdQL0UBc011EM94BxSsY0KOCMDzKsJbQ+htKGY2zFuRqX+nKMIBtJ1JbtWLbSXEp+X8JVh9C717goxI9thdQf4ERdLRB9TmtbWvIcPEL0fspkSLgLcFZAHXHHJWnz7tWmTuiQxb94hmy0IJ3sygTzp+fMsxEd7U/WlQfP3GR6tmecqRjo8EycRm9VwJzdfK144pYTK+9GRm+qDg60msE7QrqKJ7VNcO9G/SQXvKc9rw4YDbNS1Pxt0a6kvo1ZciS6iuImx++PKeJty82xcHIa1ojauM4jZONKt+dujUtU9BLRlKS0vQbu+IeJKzuWaZAK9h+jUhiXQBej1A2M4ooPpN6IpjLlpN9x8jkIorFExhO6sk23dVwbETYNrg6VGQBn4mjKNGeTaGR+edJmcuCGQEhk4Ixy3XKvMXFvLJfddTbxGH6Db0I2oofQtHeTLh81PEmTuG4ore3X2slif/94re9pFixdZUh8a2OJ++7+zXASG64XrRTjD74RKVZQrZ9/mJJazfy1Uzp9JxF/ZxV9l0wkagfOkcRzQVwKtV00AWEBOJpxGc8zxF5qZNBpaWe8RRWHUSDwMfky1c5F+gjDtLS0O72B6dUKFmIdKacA34pvReUzlBok50vK3Tm4DPiGYoIZI4fJ4KKma1nYOhEkg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 25, 2023 at 11:52:35PM +0800, wenyang.linux@foxmail.com wrote: > From: Wen Yang > > For the /proc/sys/vm/compact_memory file, the admin-guide states: > When 1 is written to the file, all zones are compacted such that free > memory is available in contiguous blocks where possible. This can be > important for example in the allocation of huge pages although processes > will also directly compact memory as required > > But it was not strictly followed, writing any value would cause all > zones to be compacted. > It has been slightly optimized to comply with the admin-guide. > Enforce the 1 on the unlikely chance that the sysctl handler is ever > extended to do something different. > > Commit ef4984384172 ("mm/compaction: remove unused variable sysctl_compact_memory") > has also been optimized a bit here, as the declaration in the external header > file has been eliminated, and sysctl_compact_memory also needs to be verified. > > Signed-off-by: Wen Yang > Cc: Andrew Morton > Cc: Mel Gorman > Cc: Oscar Salvador > Cc: William Lam > Cc: Pintu Kumar > Cc: Fu Wei > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > --- > mm/compaction.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index c8bcdea15f5f..ba57d4178866 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1736,6 +1736,7 @@ static int sysctl_compact_unevictable_allowed __read_mostly = CONFIG_COMPACT_UNE > */ > static unsigned int __read_mostly sysctl_compaction_proactiveness = 20; > static int sysctl_extfrag_threshold = 500; > +static int sysctl_compact_memory; > __read_mostly but that aside, it's only used in sysctl_compaction_handler so could also be declared as static within that function. That way if CONFIG_SYSCTL is not set, it should be guaranteed that the compiler does not save storage for it. It's minor enough that With or without another version; Acked-by: Mel Gorman -- Mel Gorman SUSE Labs