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 X-Spam-Level: X-Spam-Status: No, score=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, PDS_TONAME_EQ_TOLOCAL_HDRS_LCASE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C697C433B4 for ; Mon, 12 Apr 2021 18:26:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A89F6109E for ; Mon, 12 Apr 2021 18:26:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A89F6109E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 66EA26B006C; Mon, 12 Apr 2021 14:26:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 645236B006E; Mon, 12 Apr 2021 14:26:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BED06B0070; Mon, 12 Apr 2021 14:26:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id 2A8536B006C for ; Mon, 12 Apr 2021 14:26:31 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DED53180ACF8B for ; Mon, 12 Apr 2021 18:26:30 +0000 (UTC) X-FDA: 78024545340.24.44622FD Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 1BFD0200026C for ; Mon, 12 Apr 2021 18:26:30 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id n38so9747770pfv.2 for ; Mon, 12 Apr 2021 11:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=04YF3M1vfRP/894Mkgtm7cFlhBMi621lrF3NTwGcvuo=; b=BwVBTRBsJxDqmmlOtB8bmKlBhQXbtnALtN8305m2UQPPu7O8SOqsfety1GQWN46GdQ Mk199hVidSasf6I9HMs7rUz40Jhhrnlca20rU38slO3ihLmxc0yUwI5l3Bo4WtT35NxC ggJ56+58XC1xnByQLAY087TVb4iG7ep1bHi+ZAwHlBUSEiexv9COfEJDIybuRifwqc0h vPfZqT4DFdjV6LTSrPvKzvDzN/LYaLY7NtvzBFLqS4zvKwlDoCUWPcBWEfSgQdUuoFYz QgoVVY5nnFStxxLDQN29Yc84m/Il7lckWG30UR70JawzZ0SlKX1qPWjzIyUxOzbBII7p FJGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=04YF3M1vfRP/894Mkgtm7cFlhBMi621lrF3NTwGcvuo=; b=RS115sAHCCucKn/GD+UyBBlELWroDDDL8UngbqYsef0dVYaHakFJm5UY4HTCM+pTkL Su66ZvScnPutHUuUjFrn2DdUpL0jWRDSt4fzmA+iCp4P60fKS9oMC+LkITUW2dVO4Ogm jtf866cvVMnH7Qt0tPfkeyj1sYFEpMlGIlzrSt8uiP1+VjwC4tO8FNzcKiIkPHVCX6id LcrxYfWQRYh8ixcB39JRTJEemE7LbKxeuBvvZ2OsbdUHO1yQfge02IQiWIJYIlt+5r/d xoDS0HAk1e/D6BwABOzMD2qOefBd51shrHXWwsKUZZ7mnt/mfb05S+1JkkFzaDupspEX JlXA== X-Gm-Message-State: AOAM5312Pu5+4myGKSnvlnQY25T0yl+mi8iaO3XSmlp7MfqPDMbWgifs 9xEdNWt2n4IVVPeY+hp/h/3ISw== X-Google-Smtp-Source: ABdhPJwHnUtr4YGb6WMKANB8mpeGESvy7nopkF745LSGgBg5SipI+mqZd1NXLZQTEZYkbp3D1i+FlQ== X-Received: by 2002:aa7:8389:0:b029:209:da1c:17b5 with SMTP id u9-20020aa783890000b0290209da1c17b5mr26072167pfm.29.1618251989325; Mon, 12 Apr 2021 11:26:29 -0700 (PDT) Received: from [2620:15c:17:3:7835:226e:b31b:6f48] ([2620:15c:17:3:7835:226e:b31b:6f48]) by smtp.gmail.com with ESMTPSA id n4sm10676856pfu.45.2021.04.12.11.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 11:26:28 -0700 (PDT) Date: Mon, 12 Apr 2021 11:26:27 -0700 (PDT) From: David Rientjes To: chukaiping cc: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm/compaction:let proactive compaction order configurable In-Reply-To: <1618218330-50591-1-git-send-email-chukaiping@baidu.com> Message-ID: References: <1618218330-50591-1-git-send-email-chukaiping@baidu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1BFD0200026C X-Stat-Signature: 8iw4y4au7i16dnu17u493kwyfurdedxd Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf18; identity=mailfrom; envelope-from=""; helo=mail-pf1-f172.google.com; client-ip=209.85.210.172 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618251990-666010 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 Mon, 12 Apr 2021, chukaiping wrote: > Currently the proactive compaction order is fixed to > COMPACTION_HPAGE_ORDER(9), it's OK in most machines with lots of > normal 4KB memory, but it's too high for the machines with small > normal memory, for example the machines with most memory configured > as 1GB hugetlbfs huge pages. In these machines the max order of > free pages is often below 9, and it's always below 9 even with hard > compaction. This will lead to proactive compaction be triggered very > frequently. In these machines we only care about order of 3 or 4. > This patch export the oder to proc and let it configurable > by user, and the default value is still COMPACTION_HPAGE_ORDER. > I'm curious why you have proactive compaction enabled at all in this case? The order-9 threshold is likely to optimize for hugepage availability, but in your setup it appears that's not a goal. So what benefit does proactive compaction provide if only done for order-3 or order-4? > Signed-off-by: chukaiping > --- > include/linux/compaction.h | 1 + > kernel/sysctl.c | 10 ++++++++++ > mm/compaction.c | 7 ++++--- > 3 files changed, 15 insertions(+), 3 deletions(-) > > diff --git a/include/linux/compaction.h b/include/linux/compaction.h > index ed4070e..151ccd1 100644 > --- a/include/linux/compaction.h > +++ b/include/linux/compaction.h > @@ -83,6 +83,7 @@ static inline unsigned long compact_gap(unsigned int order) > #ifdef CONFIG_COMPACTION > extern int sysctl_compact_memory; > extern unsigned int sysctl_compaction_proactiveness; > +extern unsigned int sysctl_compaction_order; > extern int sysctl_compaction_handler(struct ctl_table *table, int write, > void *buffer, size_t *length, loff_t *ppos); > extern int sysctl_extfrag_threshold; > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > index 62fbd09..277df31 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -114,6 +114,7 @@ > static int __maybe_unused neg_one = -1; > static int __maybe_unused two = 2; > static int __maybe_unused four = 4; > +static int __maybe_unused ten = 10; > static unsigned long zero_ul; > static unsigned long one_ul = 1; > static unsigned long long_max = LONG_MAX; > @@ -2871,6 +2872,15 @@ int proc_do_static_key(struct ctl_table *table, int write, > .extra2 = &one_hundred, > }, > { > + .procname = "compaction_order", > + .data = &sysctl_compaction_order, > + .maxlen = sizeof(sysctl_compaction_order), > + .mode = 0644, > + .proc_handler = proc_dointvec_minmax, > + .extra1 = SYSCTL_ZERO, > + .extra2 = &ten, > + }, > + { > .procname = "extfrag_threshold", > .data = &sysctl_extfrag_threshold, > .maxlen = sizeof(int), > diff --git a/mm/compaction.c b/mm/compaction.c > index e04f447..a192996 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1925,16 +1925,16 @@ static bool kswapd_is_running(pg_data_t *pgdat) > > /* > * A zone's fragmentation score is the external fragmentation wrt to the > - * COMPACTION_HPAGE_ORDER. It returns a value in the range [0, 100]. > + * sysctl_compaction_order. It returns a value in the range [0, 100]. > */ > static unsigned int fragmentation_score_zone(struct zone *zone) > { > - return extfrag_for_order(zone, COMPACTION_HPAGE_ORDER); > + return extfrag_for_order(zone, sysctl_compaction_order); > } > > /* > * A weighted zone's fragmentation score is the external fragmentation > - * wrt to the COMPACTION_HPAGE_ORDER scaled by the zone's size. It > + * wrt to the sysctl_compaction_order scaled by the zone's size. It > * returns a value in the range [0, 100]. > * > * The scaling factor ensures that proactive compaction focuses on larger > @@ -2666,6 +2666,7 @@ static void compact_nodes(void) > * background. It takes values in the range [0, 100]. > */ > unsigned int __read_mostly sysctl_compaction_proactiveness = 20; > +unsigned int __read_mostly sysctl_compaction_order = COMPACTION_HPAGE_ORDER; > > /* > * This is the entry point for compacting all nodes via > -- > 1.7.1 > >