From patchwork Mon May 15 11:33:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 94094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6851752vqo; Mon, 15 May 2023 04:41:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5GBztKnzXS3/go4eKmPXLEXmk0iMy0ua4oRzym3G8tKEgo3ERq2o2+vHBhDOzP8D5S6pmE X-Received: by 2002:a17:903:27c3:b0:1ad:c629:2b73 with SMTP id km3-20020a17090327c300b001adc6292b73mr12760024plb.42.1684150903353; Mon, 15 May 2023 04:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684150903; cv=none; d=google.com; s=arc-20160816; b=YBDeJJbHTaTbSM+r+8hv/e/fEZl1GnmFZEnX+zUGJOoU9qrEjr6bNUQueaBIPOqDBY mEiaDEaxDtyyJnaInn/lfVV3SqlCOM6AhRS5xQ8UX3RoeERyph+gXENUsnBAz+xqwnsf f4+2PDb4f+pOiQ6vRoFuZxJJDKwISvyFMrnojWLwEhxi2QxDLtqRU/tOmYcTwZiEv3lh avvvPigHWMOdqiVwOjnIbDPkCpIYTOBc/sRXTbmDTtSUNHkA3+WhuKeHontinhjaQ2hv EXWMc+jj3aDyVVYVXGtlVeOqOyrEHhYUnFU0njUoxEY0g+Kqoj3O3Ri0D0XnXrsNHWaR Odhw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Jz8SIeZM33TCY29BiJtLYJYjb71lbG7QpgZzYM5PrZA=; b=n79sW/tkkkeWcYH82IxAosAF3MQOVFlZRYD+wequSG+7MkeMSeKqE8YiGvye0vhjZB aJPLWH58EPl8akM3LyDKHVLkkzWMFvUqaaqrstyL5Se07BOjrvs5NlNl2Yinu4CAtBFx 4DdK7r261DiEKV8qisth2vfad05+nipXbyJL0uMXR8/dUYV3nyTvibN7gpCcTITmPdl1 hHqw0K83F8symj1or0U2p+I63KLBtPKyfkG2EvK/+GgiAOjBDYgskGatnQnO9w4Gim9C 7Bnd/ntcy3X2eB7qLrRZG/G4eUh+9If11QlG+hvzh6bIDx1qVMzHstKm1QLiNvlMQZno YLtA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a170902988e00b001ac528e3f1bsi15095838plp.154.2023.05.15.04.41.27; Mon, 15 May 2023 04:41:43 -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 S241396AbjEOLhw (ORCPT + 99 others); Mon, 15 May 2023 07:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241308AbjEOLfv (ORCPT ); Mon, 15 May 2023 07:35:51 -0400 Received: from outbound-smtp41.blacknight.com (outbound-smtp41.blacknight.com [46.22.139.224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E154F19A6 for ; Mon, 15 May 2023 04:34:29 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp41.blacknight.com (Postfix) with ESMTPS id 8D811230D for ; Mon, 15 May 2023 12:34:28 +0100 (IST) Received: (qmail 27031 invoked from network); 15 May 2023 11:34:28 -0000 Received: from unknown (HELO localhost.localdomain) (mgorman@techsingularity.net@[193.118.249.27]) by 81.17.254.9 with ESMTPA; 15 May 2023 11:34:28 -0000 From: Mel Gorman To: Vlastimil Babka Cc: Andrew Morton , Jiri Slaby , Maxim Levitsky , Michal Hocko , Pedro Falcato , Paolo Bonzini , Chuyi Zhou , Linux-MM , LKML , Mel Gorman Subject: [PATCH 3/4] mm: compaction: Update pageblock skip when first migration candidate is not at the start Date: Mon, 15 May 2023 12:33:43 +0100 Message-Id: <20230515113344.6869-4-mgorman@techsingularity.net> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230515113344.6869-1-mgorman@techsingularity.net> References: <20230515113344.6869-1-mgorman@techsingularity.net> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765960217931571598?= X-GMAIL-MSGID: =?utf-8?q?1765960217931571598?= isolate_migratepages_block should mark a pageblock as skip if scanning started on an aligned pageblock boundary but it only updates the skip flag if the first migration candidate is also aligned. Tracing during a compaction stress load (mmtests: workload-usemem-stress-numa-compact) that many pageblocks are not marked skip causing excessive scanning of blocks that had been recently checked. Update pageblock skip based on "valid_page" which is set if scanning started on a pageblock boundary. Signed-off-by: Mel Gorman Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/compaction.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index accc6568091a..d7be990b1d60 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -392,18 +392,14 @@ void reset_isolation_suitable(pg_data_t *pgdat) * Sets the pageblock skip bit if it was clear. Note that this is a hint as * locks are not required for read/writers. Returns true if it was already set. */ -static bool test_and_set_skip(struct compact_control *cc, struct page *page, - unsigned long pfn) +static bool test_and_set_skip(struct compact_control *cc, struct page *page) { bool skip; - /* Do no update if skip hint is being ignored */ + /* Do not update if skip hint is being ignored */ if (cc->ignore_skip_hint) return false; - if (!pageblock_aligned(pfn)) - return false; - skip = get_pageblock_skip(page); if (!skip && !cc->no_set_skip_hint) set_pageblock_skip(page); @@ -470,8 +466,7 @@ static void update_cached_migrate(struct compact_control *cc, unsigned long pfn) { } -static bool test_and_set_skip(struct compact_control *cc, struct page *page, - unsigned long pfn) +static bool test_and_set_skip(struct compact_control *cc, struct page *page) { return false; } @@ -1075,9 +1070,9 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, lruvec_memcg_debug(lruvec, page_folio(page)); /* Try get exclusive access under lock */ - if (!skip_updated) { + if (!skip_updated && valid_page) { skip_updated = true; - if (test_and_set_skip(cc, page, low_pfn)) + if (test_and_set_skip(cc, valid_page)) goto isolate_abort; }