Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp914361rwd; Thu, 25 May 2023 05:55:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63JMrdIZc+hw88a11f0QgEqaSl9ekkwYJ+hd2pT5bMGCnCiWj824PhQW0lFFhvcN7ulbd0 X-Received: by 2002:a17:902:d509:b0:1ab:7c4:eb24 with SMTP id b9-20020a170902d50900b001ab07c4eb24mr2016267plg.22.1685019355311; Thu, 25 May 2023 05:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685019355; cv=none; d=google.com; s=arc-20160816; b=WDOzoAFBi2XnZ22pyX3bwGTdVXJENI7seHtAByfBCwJ67PTDLKMt6IQh2BUsIRgiLP 6zd12D3q8tg0gvwM6fUSgWBh9jOFah1nRlzlg78I2CCoTL3BFjvkpSXqJ11GQU7UWoiD Rz0FMzFQUluqa2Qs4RjDm6v1nDqJrbHK1DFu3q++GvJN2/ALcggnoLuwFwk2dtGQQH/f LhguP9LCvRGSejTgCAmlZRoaIl5WM66xQKYooOnS0R8VbYdO/JfOlfnj52M1r4YADRWA 5z9L6ICosZIW/oAnAX92uDIWvpLNOiRyypqdBQHUgoEijGjlV93PPN8gTpNs8r25OCsy bkGg== 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=Mn3fhMFcaTYsz7UQ9NrJ1DjTrAq5Xs3DKzZTvyhCQfA=; b=jDku580Va0BgV2jKNnEAGVSV3eo68GXBguUJclU3iWiOe4zm2fj2uudZEXpwBTMZMg eutNU7wcUT2GcwSmDjvaKEHvvU+GgyZBY6PEO/uKRvvxpjExmk22DriOsrfYdI2skULn 99gTbLlDJQJbBc4exu/5Irr/GtIR2412VdRdQ+mVaxDsPMWaTkxzNcQM4La0855sKLpv XCEDWyYezTpAFHoruJzeNZtdfwW4u8tCh5w+e9yefwF/xroGNbTT+WpIC12mkrgr/TA6 +/12gzd8KWqidV5CTIwya7YKovGUHlhEQYIe3OK7ljQAYDoCDFrl8KAiCJWwP0sgYbtM VF6w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a17090274c700b0019cec50618csi1388517plt.159.2023.05.25.05.55.41; Thu, 25 May 2023 05:55:55 -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 S241096AbjEYMyb (ORCPT + 99 others); Thu, 25 May 2023 08:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240536AbjEYMyW (ORCPT ); Thu, 25 May 2023 08:54:22 -0400 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6FB3189 for ; Thu, 25 May 2023 05:54:20 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R711e4;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=6;SR=0;TI=SMTPD_---0VjSJ3iS_1685019256; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VjSJ3iS_1685019256) by smtp.aliyun-inc.com; Thu, 25 May 2023 20:54:17 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, vbabka@suse.cz, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] mm: compaction: skip fast freepages isolation if enough freepages are isolated Date: Thu, 25 May 2023 20:54:01 +0800 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: 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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,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: X-Mailing-List: linux-kernel@vger.kernel.org I've observed that fast isolation often isolates more pages than cc->migratepages, and the excess freepages will be released back to the buddy system. So skip fast freepages isolation if enough freepages are isolated to save some CPU cycles. Signed-off-by: Baolin Wang --- mm/compaction.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index eccec84dae82..3ade4c095ed2 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1550,6 +1550,10 @@ static void fast_isolate_freepages(struct compact_control *cc) spin_unlock_irqrestore(&cc->zone->lock, flags); + /* Skip fast search if enough freepages isolated */ + if (cc->nr_freepages >= cc->nr_migratepages) + break; + /* * Smaller scan on next order so the total scan is related * to freelist_scan_limit. -- 2.27.0