[1/2] mm: compaction: consider the number of scanning compound pages in isolate fail path
Message ID | 1bc1c955b03603c4e14f56dfbbef9f637f18dbbd.1678703534.git.baolin.wang@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1112719wrd; Mon, 13 Mar 2023 03:59:09 -0700 (PDT) X-Google-Smtp-Source: AK7set+MrvuQ+eysC4ofVzBH+4SRVkbqBx2z0/hDbakdh4+FZE6bn6pAHxpKATrQ4/hwQbShW2sp X-Received: by 2002:a17:902:c20c:b0:19f:2dff:219b with SMTP id 12-20020a170902c20c00b0019f2dff219bmr5651862pll.5.1678705148762; Mon, 13 Mar 2023 03:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678705148; cv=none; d=google.com; s=arc-20160816; b=Exrw8JsNpdAj69uUlUlLqG88Q6HRQW/t5Xn9XCm5WPCtT8x8jVgzNSTmCAOH4GXNch sZkmrAcK1nnbsnO0KhjVJWaIVCx3KuXGEx4GZCcCVBV22ct8IDXUlRbpS4HaxEZ8D5K9 M6lTTfWRfRsKdydgL+6UmnoVM8cSwGPBMbRsCWBWT8dPm28c1f/YqKm/Nv3bVKehK/yP lAn8gWlqnPq546uqyRI9Iw7CV77q6eLoWj+DHX8p22zTvXMtPvYM0P3sOgn9JdgKa2h9 Flk4eBpOsDeVtxRAJIDnQdcQCDNH89+eAuvMSXVAjHzg4QJR0fMEjUpECjfBZFwLZjvM 29ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=JUJdIdlfoH2aAktXgHePaZ5e3iXrsTzhsI+cC+hM6+o=; b=wcUXCyYEVy21+EtsQ+vLHxslykC/1+D4L+L5ukTlyc1vFM+xj1/QrlDG8Q/o5f42Go l8qoQJ/ZPodz/OqrfyBVfgYyYJAIcXVCvRGemnjUZtECO0AUblydXLk9yCoueie9Jqmx FQ7GMIvX02y4oYRGSIbkc7M2CoViEuH72ZzPOcBGGvW6KhaKhZxSudh8M4/2CGXqrPkH gSWfMXR9SKENXaj15mu0KjWT1M5Zq3Mkt23aPvwn/BodBqfgimhlz3A6aJcJFGgpDAck SK8+FnLGNMPCkYTQiHCAVAjEeIUlpV4D339lXTFqD98nFsq6gdcg3nCqko7JKq1V6Gaa qcaw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x11-20020a170902b40b00b0019a9834bb23si6258081plr.192.2023.03.13.03.58.53; Mon, 13 Mar 2023 03:59:08 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230055AbjCMKhy (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Mon, 13 Mar 2023 06:37:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbjCMKhv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 13 Mar 2023 06:37:51 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A8B5FA46 for <linux-kernel@vger.kernel.org>; Mon, 13 Mar 2023 03:37:29 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R921e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vdl6q9P_1678703846; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vdl6q9P_1678703846) by smtp.aliyun-inc.com; Mon, 13 Mar 2023 18:37:26 +0800 From: Baolin Wang <baolin.wang@linux.alibaba.com> To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, osalvador@suse.de, vbabka@suse.cz, william.lam@bytedance.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: compaction: consider the number of scanning compound pages in isolate fail path Date: Mon, 13 Mar 2023 18:37:16 +0800 Message-Id: <1bc1c955b03603c4e14f56dfbbef9f637f18dbbd.1678703534.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760249930219650806?= X-GMAIL-MSGID: =?utf-8?q?1760249930219650806?= |
Series |
[1/2] mm: compaction: consider the number of scanning compound pages in isolate fail path
|
|
Commit Message
Baolin Wang
March 13, 2023, 10:37 a.m. UTC
The commit b717d6b93b54 ("mm: compaction: include compound page count
for scanning in pageblock isolation") had added compound page statistics
for scanning in pageblock isolation, to make sure the number of scanned
pages are always larger than the number of isolated pages when isolating
mirgratable or free pageblock.
However, when failed to isolate the pages when scanning the mirgratable or
free pageblock, the isolation failure path did not consider the scanning
statistics of the compound pages, which can show the incorrect number of
scanned pages in tracepoints or the vmstats to make people confusing about
the page scanning pressure in memory compaction.
Thus we should take into account the number of scanning pages when failed
to isolate the compound pages to make the statistics accurate.
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
mm/compaction.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On 3/13/23 11:37, Baolin Wang wrote: > The commit b717d6b93b54 ("mm: compaction: include compound page count > for scanning in pageblock isolation") had added compound page statistics > for scanning in pageblock isolation, to make sure the number of scanned > pages are always larger than the number of isolated pages when isolating > mirgratable or free pageblock. > > However, when failed to isolate the pages when scanning the mirgratable or > free pageblock, the isolation failure path did not consider the scanning > statistics of the compound pages, which can show the incorrect number of > scanned pages in tracepoints or the vmstats to make people confusing about > the page scanning pressure in memory compaction. > > Thus we should take into account the number of scanning pages when failed > to isolate the compound pages to make the statistics accurate. > > Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> > --- > mm/compaction.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index 5a9501e0ae01..c9d9ad958e2a 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -587,6 +587,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, > blockpfn += (1UL << order) - 1; > cursor += (1UL << order) - 1; > } > + nr_scanned += (1UL << order) - 1; I'd rather put it in the block above that tests order < MAX_ORDER. Otherwise as the comments say, the value can be bogus as it's racy. > goto isolate_fail; > } > > @@ -873,9 +874,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, > cond_resched(); > } > > - nr_scanned++; > - > page = pfn_to_page(low_pfn); > + nr_scanned += compound_nr(page); For the same reason, I'd rather leave the nr_scanned adjustment by order in the specific code blocks where we know/think we have a compound or huge page and have sanity checked the order/nr_pages, and not add an unchecked compound_nr() here. Thanks. > > /* > * Check if the pageblock has already been marked skipped. > @@ -1077,6 +1077,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, > */ > if (unlikely(PageCompound(page) && !cc->alloc_contig)) { > low_pfn += compound_nr(page) - 1; > + nr_scanned += compound_nr(page) - 1; > SetPageLRU(page); > goto isolate_fail_put; > } > @@ -1097,7 +1098,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, > isolate_success_no_list: > cc->nr_migratepages += compound_nr(page); > nr_isolated += compound_nr(page); > - nr_scanned += compound_nr(page) - 1; > > /* > * Avoid isolating too much unless this block is being
On 3/15/2023 11:54 PM, Vlastimil Babka wrote: > On 3/13/23 11:37, Baolin Wang wrote: >> The commit b717d6b93b54 ("mm: compaction: include compound page count >> for scanning in pageblock isolation") had added compound page statistics >> for scanning in pageblock isolation, to make sure the number of scanned >> pages are always larger than the number of isolated pages when isolating >> mirgratable or free pageblock. >> >> However, when failed to isolate the pages when scanning the mirgratable or >> free pageblock, the isolation failure path did not consider the scanning >> statistics of the compound pages, which can show the incorrect number of >> scanned pages in tracepoints or the vmstats to make people confusing about >> the page scanning pressure in memory compaction. >> >> Thus we should take into account the number of scanning pages when failed >> to isolate the compound pages to make the statistics accurate. >> >> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> >> --- >> mm/compaction.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/mm/compaction.c b/mm/compaction.c >> index 5a9501e0ae01..c9d9ad958e2a 100644 >> --- a/mm/compaction.c >> +++ b/mm/compaction.c >> @@ -587,6 +587,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, >> blockpfn += (1UL << order) - 1; >> cursor += (1UL << order) - 1; >> } >> + nr_scanned += (1UL << order) - 1; > > I'd rather put it in the block above that tests order < MAX_ORDER. Otherwise > as the comments say, the value can be bogus as it's racy. Right, thanks for pointing it out. Will do in next version. > >> goto isolate_fail; >> } >> >> @@ -873,9 +874,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, >> cond_resched(); >> } >> >> - nr_scanned++; >> - >> page = pfn_to_page(low_pfn); >> + nr_scanned += compound_nr(page); > > For the same reason, I'd rather leave the nr_scanned adjustment by order in > the specific code blocks where we know/think we have a compound or huge page > and have sanity checked the order/nr_pages, and not add an unchecked > compound_nr() here. OK. Sound reasonable to me. Thanks for your input. >> /* >> * Check if the pageblock has already been marked skipped. >> @@ -1077,6 +1077,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, >> */ >> if (unlikely(PageCompound(page) && !cc->alloc_contig)) { >> low_pfn += compound_nr(page) - 1; >> + nr_scanned += compound_nr(page) - 1; >> SetPageLRU(page); >> goto isolate_fail_put; >> } >> @@ -1097,7 +1098,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, >> isolate_success_no_list: >> cc->nr_migratepages += compound_nr(page); >> nr_isolated += compound_nr(page); >> - nr_scanned += compound_nr(page) - 1; >> >> /* >> * Avoid isolating too much unless this block is being
diff --git a/mm/compaction.c b/mm/compaction.c index 5a9501e0ae01..c9d9ad958e2a 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -587,6 +587,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, blockpfn += (1UL << order) - 1; cursor += (1UL << order) - 1; } + nr_scanned += (1UL << order) - 1; goto isolate_fail; } @@ -873,9 +874,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, cond_resched(); } - nr_scanned++; - page = pfn_to_page(low_pfn); + nr_scanned += compound_nr(page); /* * Check if the pageblock has already been marked skipped. @@ -1077,6 +1077,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, */ if (unlikely(PageCompound(page) && !cc->alloc_contig)) { low_pfn += compound_nr(page) - 1; + nr_scanned += compound_nr(page) - 1; SetPageLRU(page); goto isolate_fail_put; } @@ -1097,7 +1098,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, isolate_success_no_list: cc->nr_migratepages += compound_nr(page); nr_isolated += compound_nr(page); - nr_scanned += compound_nr(page) - 1; /* * Avoid isolating too much unless this block is being