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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 A5B35C49EA4 for ; Wed, 23 Jun 2021 09:15:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E567601FF for ; Wed, 23 Jun 2021 09:15:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E567601FF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E08E76B0011; Wed, 23 Jun 2021 05:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB94B6B0036; Wed, 23 Jun 2021 05:15:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C80CB6B006C; Wed, 23 Jun 2021 05:15:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 934436B0011 for ; Wed, 23 Jun 2021 05:15:13 -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 CAF77181AF5EA for ; Wed, 23 Jun 2021 09:15:13 +0000 (UTC) X-FDA: 78284429706.24.0BF7422 Received: from outbound-smtp16.blacknight.com (outbound-smtp16.blacknight.com [46.22.139.233]) by imf10.hostedemail.com (Postfix) with ESMTP id 1D8EB4000390 for ; Wed, 23 Jun 2021 09:15:12 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp16.blacknight.com (Postfix) with ESMTPS id 32C8E1C4374 for ; Wed, 23 Jun 2021 10:15:11 +0100 (IST) Received: (qmail 2254 invoked from network); 23 Jun 2021 09:15:11 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.17.255]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 23 Jun 2021 09:15:11 -0000 Date: Wed, 23 Jun 2021 10:15:09 +0100 From: Mel Gorman To: Wonhyuk Yang Cc: linux-mm@kvack.org, Andrew Morton , Vlastimil Babka Subject: Re: [PATCH] mm, compaction: fix 'limit' in fast_isolate_freepages Message-ID: <20210623091509.GV30378@techsingularity.net> References: <20210620145742.54565-1-vvghjk1234@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20210620145742.54565-1-vvghjk1234@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.233 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none X-Stat-Signature: 3q1yi1aa57scmo5nhifwuuetwox7m3z5 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1D8EB4000390 X-HE-Tag: 1624439712-339285 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 Sun, Jun 20, 2021 at 11:57:42PM +0900, Wonhyuk Yang wrote: > Because of 'min(1, ...)', fast_isolate_freepages set 'limit' > to 0 or 1. This takes away the opportunities of find candinate > pages. Also, even if 'limit' reaches zero, it scan once. It is > not consistent. So, modify the minimum value of 'limit' to 1. > The changelog could do with a little polish. In addition, what were the effects of this and what load did you use to evaluate it? While your patch is mostly correct, it has the potential side-effect of increasing system CPU usage in some cases and I'm curious to hear what you observed. Minimally it is worth noting in the changelog that there is a risk of increasing system CPU usage but that there are advantages too. Describe them in the changelog in case a regression bisects to your patch. > Fixes: 5a811889de10f ("mm, compaction: use free lists to quickly locate a migration target") > > Signed-off-by: Wonhyuk Yang > --- > mm/compaction.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index 84fde270ae74..2e41e7ab1f55 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1380,7 +1380,7 @@ static int next_search_order(struct compact_control *cc, int order) > static unsigned long > fast_isolate_freepages(struct compact_control *cc) > { > - unsigned int limit = min(1U, freelist_scan_limit(cc) >> 1); > + unsigned int limit = max(1U, freelist_scan_limit(cc) >> 1); > unsigned int nr_scanned = 0; > unsigned long low_pfn, min_pfn, highest = 0; > unsigned long nr_isolated = 0; Ok. > @@ -1456,7 +1456,7 @@ fast_isolate_freepages(struct compact_control *cc) > high_pfn = pfn; > > /* Shorten the scan if a candidate is found */ > - limit >>= 1; > + limit = max(1U, limit >> 1); > } > > if (order_scanned >= limit) This hunk should be dropped. Once a candidate free page has been identified, it's ok to decay the limit to 0. This hunk introduces a risk of increasing system CPU usage unnecessarily. > @@ -1496,7 +1496,7 @@ fast_isolate_freepages(struct compact_control *cc) > * to freelist_scan_limit. > */ > if (order_scanned >= limit) > - limit = min(1U, limit >> 1); > + limit = max(1U, limit >> 1); > } The change is fine but I have a minor nitpick that you are free to ignore. The comment above this block has a typo. s/scan ig related/scan is related/ Ordinarily patches to fix spelling are ignored but you are altering this area anyway and it's helpful to see the full comment when reviewing this patch. I think it would be harmless to fix the spelling in the context of this patch. Thanks. -- Mel Gorman SUSE Labs