Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp304411pxb; Tue, 15 Feb 2022 13:50:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfyjPLA5WDm/9aDcau4uhEpq5r4/oQjy4Wje0JaKIHSjvH56qosyRrtE2zhbppYhx5AADd X-Received: by 2002:a05:6402:518e:: with SMTP id q14mr980295edd.155.1644961825379; Tue, 15 Feb 2022 13:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644961825; cv=none; d=google.com; s=arc-20160816; b=tQrL9Fiv9fWpf0qTjUVYvqIAs/U/VglwJzFRSf69hkMTcZIi7jA3UG4wUaNeoDx5Ml pF/0wqtlnVuU9lQIuYBDtjuDUAcXH72hFcKvnNcVB7VTDu7f2xhdGQLIOsofs77BvxfZ LnFEih3ENkhkNmTuuwke5pFURhjjUlN6uMQa8Q8510hYWF3BE+6SsflgZXrJw1xQDycX vof/gKltPBk70yl7Yd8eJOBXK5gbReeLXklZkMH0GEGxEeWYl02Fl9hexsyH138exa1w 6i9Hn8nB5pfHBbbLCbOaKeuGWNjBFvr+y67QtAvCdNdCOgS9gHJ2/8HinPjHo+sPVage K7Tg== 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=F9C2R7SccAQy+x0eVYi8DXGAFnTOWa4Keka5p2sRaJE=; b=IMdiwL1UsfiPPmojPoi/Sx/FPDc/bCh6KdzNGTqAysH6YokSiio/P0hPzAhCVjzLBU WbAD6pnf9SnBw+13vJFYjZepun5dhYtv78iDdHHBu/TASJuHOf1Q+QHHodoLSeDketTY UXFFfw9vBZTPb06urXDQezbbKm3Gz/jvA4uLz+f+QwPgl1wiH1wlz734SSgZZrP9IQfd sSQuYT1kiWD8SwRnS90mPGKJHQA6Zw6ZT89iYWZAM2PCmj4yOELfng/Rezy8wUrLkOi9 Snil+td3szVLqcilVijee8XiZ5hZ4o7hsVtLEVi0LWD9N7y2tqRPzcy0kqiWyuskJa1P 5E8w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11si704712edq.200.2022.02.15.13.50.02; Tue, 15 Feb 2022 13:50:25 -0800 (PST) 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 S239417AbiBOO7w (ORCPT + 99 others); Tue, 15 Feb 2022 09:59:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235898AbiBOO7t (ORCPT ); Tue, 15 Feb 2022 09:59:49 -0500 Received: from outbound-smtp35.blacknight.com (outbound-smtp35.blacknight.com [46.22.139.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E88382C10D for ; Tue, 15 Feb 2022 06:59:38 -0800 (PST) Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp35.blacknight.com (Postfix) with ESMTPS id 0557E1A7A for ; Tue, 15 Feb 2022 14:51:43 +0000 (GMT) Received: (qmail 14877 invoked from network); 15 Feb 2022 14:51:42 -0000 Received: from unknown (HELO stampy.112glenside.lan) (mgorman@techsingularity.net@[84.203.17.223]) by 81.17.254.9 with ESMTPA; 15 Feb 2022 14:51:42 -0000 From: Mel Gorman To: Andrew Morton Cc: Aaron Lu , Dave Hansen , Vlastimil Babka , Michal Hocko , Jesper Dangaard Brouer , LKML , Linux-MM , Mel Gorman Subject: [PATCH 2/5] mm/page_alloc: Track range of active PCP lists during bulk free Date: Tue, 15 Feb 2022 14:51:08 +0000 Message-Id: <20220215145111.27082-3-mgorman@techsingularity.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220215145111.27082-1-mgorman@techsingularity.net> References: <20220215145111.27082-1-mgorman@techsingularity.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, 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 free_pcppages_bulk() frees pages in a round-robin fashion. Originally, this was dealing only with migratetypes but storing high-order pages means that there can be many more empty lists that are uselessly checked. Track the minimum and maximum active pindex to reduce the search space. Signed-off-by: Mel Gorman --- mm/page_alloc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 08de32cfd9bb..c5110fdeb115 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1450,6 +1450,8 @@ static void free_pcppages_bulk(struct zone *zone, int count, struct per_cpu_pages *pcp) { int pindex = 0; + int min_pindex = 0; + int max_pindex = NR_PCP_LISTS - 1; int batch_free = 0; int nr_freed = 0; unsigned int order; @@ -1478,10 +1480,17 @@ static void free_pcppages_bulk(struct zone *zone, int count, if (++pindex == NR_PCP_LISTS) pindex = 0; list = &pcp->lists[pindex]; - } while (list_empty(list)); + if (!list_empty(list)) + break; + + if (pindex == max_pindex) + max_pindex--; + if (pindex == min_pindex) + min_pindex++; + } while (1); /* This is the only non-empty list. Free them all. */ - if (batch_free == NR_PCP_LISTS) + if (batch_free >= max_pindex - min_pindex) batch_free = count; order = pindex_to_order(pindex); -- 2.31.1