Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1931469rwr; Fri, 28 Apr 2023 04:02:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DjB7UgyXcRD6dAFDosLZxcrno8Gpv/GlH82hNib0xHmb62f906fIOfNDeRO0ebs+BKWIK X-Received: by 2002:a05:6870:424f:b0:187:f933:d308 with SMTP id v15-20020a056870424f00b00187f933d308mr4231735oac.25.1682679721852; Fri, 28 Apr 2023 04:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682679721; cv=none; d=google.com; s=arc-20160816; b=PUM8XKnFQ2VBSSvpBX18Z6Se9x4f24xfYA9u8H0FRvZSzA81RhJEPz+CVYPRFKH9n8 Dah/wvKR2nSWMjPjf+vpYRo2cKrU1WZL7VIsyRtQ3oqbB3x1+ueqCEAA53LE9Eldvnsb /fYnBvvx7PKiQLBZAqiLT2ULMploziMB72Qdi1J6XUcP/ZgWWz5hb+nVcw7vgSXa3zlZ oFDQy2UkJAACuYjYARDiKC8qTPhC+rpEiusJuRV4I33jtbf8zxiBKrlOZo0OGyuYmGrw T5RNUtTZH2R43g8fxC0jZOo+NH+hTIhfkP4TOsQdGBu8FWO40+HJsZ4nOmJVpr9lvwGe mqrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=48pn7ZhvzI5sRbrZjCTna7TtfY9o7gda4KbKyc0VYAA=; b=HaDvTunrV+Bq4SEkdqVhd1kn/XtloCOhbXHtF2Q3tZ6WGB0qOxIu+zQ+Aa+cvpOXS+ jhc8Ah0/m3pqERzfloBFyUk+ladahX5yQKgg7IQ2816pwkq/YiJP1Byy9yePhEOWfQvK 9Rb5ImixgBf/zVfEte3VY/cZqysiKx+WwJTddG0MsY4LsbXBaU04kBLZHWxmOIqDwZNM 9K4lOJe4/eI6DBiCC1viA++eTTViTWjsll1ZLfIGqd9lHyn63oRRChm16ZkPTSx+Rfvp HwuEHCq5020Wyax6w08CmJyznvI5RxRrORWbAibx3d/cqJnVuWIft3XIRJ+qLemdyDZy PzJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a9d4c13000000b006971f4a7165si4269960otf.192.2023.04.28.04.01.46; Fri, 28 Apr 2023 04:02:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbjD1K6z (ORCPT + 99 others); Fri, 28 Apr 2023 06:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjD1K6x (ORCPT ); Fri, 28 Apr 2023 06:58:53 -0400 Received: from outbound-smtp29.blacknight.com (outbound-smtp29.blacknight.com [81.17.249.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24A6E2706 for ; Fri, 28 Apr 2023 03:58:52 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp29.blacknight.com (Postfix) with ESMTPS id AA120BEE95 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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