Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp533521rdh; Sun, 24 Sep 2023 00:20:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwhjM3D0Ae38alHKnEi2lCrZtNzNR3Umjh5oB1Zdkvf2eUlY1TzOyBN+gASxpRjuhXgyyT X-Received: by 2002:a05:6a21:19e:b0:15d:d3b3:1843 with SMTP id le30-20020a056a21019e00b0015dd3b31843mr5856500pzb.3.1695540009914; Sun, 24 Sep 2023 00:20:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695540009; cv=pass; d=google.com; s=arc-20160816; b=jDBgNJfU84CDLNrs7wz46BuVrUgZiTokp4ANxXfzzVDTrUymsn+jDpzKJFF5y5FwK8 HMeFF7RZhLMccrfjRnzE3zIznphEb34WnESpWT+MFiBuLvrCEJGAnIU3SDUnmG4ZB6Y0 HwxyiDrScdcZb3jBnPayBrwIbn7USEsQdMPnGVGqi5z6+W+tWnTbkcWn8d4+qyF4kIV4 1r01Ji+/ye4JRgai1LhJ9Ub9zw+LSvjcnhy+EyuakOrWK4cViV8LpK42ueHDsiXrj7Zt Nl/yqkRoN/TfLDBM5E3meAn11nf0Khn0B9azwr51NqO1VBZxM2NIiBLVhhCJ7TFieLIG 2+AA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=JzysWamZK+9kW6UWVQs3wGfzLoPboH5hnc5SyBpbi3s=; fh=c2eYxmN/YNr2ouhP31X3BrePKjLzNfOQt6lh5667ppQ=; b=V9VxxpW4j4l78ao10rlW4H4XFTF6/7V+7BMLXbHGK/nJDxIEljh1nFXvkv+QSFqC0e xG7S9MvgsC2zB6eOM6Lsgto2Y/2llY44lvfMZokLgSjo4Iyisy6W8hTWte1FqmTQ1FPp SMBQ//4bbf8rFwgCGJv06PaJdAQDpp+9JoFDCC8/CFq2Z4JOtH+9SbjaOEi4UvrirfHl pcx59DD8ooGPOucAYbu50RRY8+o/VoI857eFXUrvpUqiWG7CZpT5VpX87RhZacSfo2uH fpZeTeKVTe43Jrf9gg08Xyzx70bSTbT5FVwEweW63RXHxqLzMYhS1/omciRrhbiK21bN URIw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=O3m2GLuL; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w20-20020a63fb54000000b00557447d5721si7014411pgj.768.2023.09.24.00.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 00:20:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=O3m2GLuL; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id DB9878111389; Sat, 23 Sep 2023 19:53:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbjIXCxj (ORCPT + 99 others); Sat, 23 Sep 2023 22:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjIXCxi (ORCPT ); Sat, 23 Sep 2023 22:53:38 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2099.outbound.protection.outlook.com [40.107.117.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82F06113 for ; Sat, 23 Sep 2023 19:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BGYnuWlAmhCn4usxeYr4WW6xXTgw+yEo3QJQ4oArWT9zJ2zqWgOc076JhRy5cg0lGOAYmpiMDRCG4Rq61yyT30HC46MOuyzukqYnQ7BA2VdO/SCRU5I41oAvJR9bIT2u5xYYU2go/75poVfHvADMuN3JewvgjyqmNZ/vu/o1g2thNGA5GitXuj80moBeEcI0VcIY3IJCoFpCVy05Qexr7DNmx3QKOBqjcwtk+hjxinFquY5JHw1Shk6zy6ApVtOa6yeBhi7IJxjx2W6pz5DASbKd8eMZJCwutgEpgG5Z34fPF7IvotbUq+37kl2ccWxORFo7BXS3DWyv0O4iuZw5tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JzysWamZK+9kW6UWVQs3wGfzLoPboH5hnc5SyBpbi3s=; b=fAnZ14YCNp6XhFD7i4E0m9vjeMlzfFKmeegwJt/g45wfX1Y288DYld7rxe2EIC3Uy7xp3Qk4Owj6WbASOQItK0CqibeBIyVjgiqzZVwzeqpf1pOng9rwDIoVOJ1yBR1IHcQY9p/lHi2xdy0hEmSZqCf4qecZpDd/DRx4sFzIDtJgMgGjR0te44lJ3Mr0gM3F7281JwSJkTmT35cWI8PXQ85qoTWdIq6FrOBU4OjRslIXfPm2Svdy73gV/nKzVqD59P807imDJ8z1gkvFnVvFwNWr0rbwzL24y6ctfv2ngIdXowMH0OyEd7hMRN/gI8bt/4S60ppjfAue72s7u13Xmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JzysWamZK+9kW6UWVQs3wGfzLoPboH5hnc5SyBpbi3s=; b=O3m2GLuLkE58NymbtDLQ74RI26SmS/wEoy6DR6iC7uXbeqI9bx/4tXjGfroLWxL7IJQuQRtKxujcM/H5rAVUdcRv6VbgQMwzcDSlm0hRbc1FxXHv/8K+5T78p1wS7hQw2pAJqL+noac+WFIrfEez13rU3MwAQPXV0a6GwsBH6OIJb3y696e9FzzIzSP6mHLQp3bHWSN1sdPVMyzK4EzUJBVkvbbr15XlU+SQxLoWj8B0iWU2QmshodTTM1OcnOi9I/PB/1JS8RBJHx7ZD5wIWuRdBMCqqHdQeK5312VF1wwIGm/COvQeFJoY0A5RbKL6STmpWGZIsNwX8njnuSOlRQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by SEYPR06MB5326.apcprd06.prod.outlook.com (2603:1096:101:6b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.25; Sun, 24 Sep 2023 02:53:26 +0000 Received: from JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::832:19a2:2f83:1cfc]) by JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::832:19a2:2f83:1cfc%4]) with mapi id 15.20.6813.027; Sun, 24 Sep 2023 02:53:26 +0000 From: Zhiguo Jiang To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Zhiguo Jiang Subject: [PATCH] mm: vmscan: fix kswapd nr_to_reclaim repeated calculation Date: Sun, 24 Sep 2023 10:53:15 +0800 Message-ID: <20230924025315.285-1-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:196::14) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|SEYPR06MB5326:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f5e4e1f-9536-4973-dbd2-08dbbca96c23 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MXlSlhs2ErNGQNG2yP0dmcu70BCB/QTijEn8doJIM4sw6VzM/8GnxNbZDz6uCsFJK/fBC/oji68bnIR3apCWQzbssIYSkOMkK6+jgMJt8nWzhJwKvL/zNS0rel6wEjS1XrgWSE5CetPTHOa30gJ4GPngxovoKbNcKoYq229XpfBY55XqHECzqD4m4e+4C54++pJm7wjFL5HEX1DgVu/d9cYCsoVVI6bq7ik4k0rCUV7PZ96Fd2pJddWV/n3qFCBomRareAyktr3DpZurSrBe/YjwM7+mkkZnlu+AHq7UajdRk6K7bUFeJ14KVRwOn/N3oiM+WLfCDr0m1EG1XsIoR+/jDBUenEd2Y618fy/57Sj5/GbHkTtIURSw+XrYC9yYgJnzEFE9qBzlBsU8aG2o88X+irZEhJwW7jbabtGyIMNCtiB7a7SGV5ztnSpQxUIxeWp/Q3U5gLI8rFSgaifiJVOlsOeiRbekPrsMaszA1bjpDBLvJC+CG8DNCRkC5+tXN/o6AQRB/VfF4llB9mBap8v+OSTpsBrGU9l5FfaHNBuxiZF9+LAXmQz3zt8/+gwjNis2h4DVIjUf2Y+81NCtHgA24/xiCQbVcIu1e9GIiSBEIKZuaaomfmfjhOfRn+SZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:JH0PR06MB6849.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(346002)(366004)(396003)(376002)(230922051799003)(451199024)(186009)(1800799009)(2906002)(8936002)(8676002)(4326008)(5660300002)(66476007)(66556008)(66946007)(6666004)(478600001)(6486002)(6506007)(52116002)(6512007)(26005)(41300700001)(2616005)(1076003)(107886003)(316002)(83380400001)(36756003)(86362001)(38350700002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?aGXEtHL/YQcv6TNby+4y772RvuEO3211ZYoISeEi1FZkONyh8JPt2k1lr0nO?= =?us-ascii?Q?s5KJbBBaL3KjUgZbFOEFmBQs+caWx6unvmmshL6S7QbMBQ4237qeIt0PHuDf?= =?us-ascii?Q?YIGJ8DacRKk8NxG2d0QZB0eKilq+/OMEXAxxHok9UQoLgiqieso1rMEoLz7C?= =?us-ascii?Q?vCHl3jKPAHb66A0vqn49qAH81QKA/MvxONqefn5NqbHiWcRMWyO82GZpn1xZ?= =?us-ascii?Q?ZkmM6ICA4MAxBOawRrz8Bj7hOtsefLmzuSxTxCpid9SkLj3i5b+zfzzEA80v?= =?us-ascii?Q?+VWSnD3G8nyt8ztpoDWCycuID8Lb8xL0KJul95PJbYFwtwi9ncUPHZ5mJaJQ?= =?us-ascii?Q?huR4x/Q4XBNXQlJGl4Q1Gyl72/I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cc2dV?= =?us-ascii?Q?pjJC7j8fdiAPCqSkSYyJXDlXBt/pKfFOdaF9kdmonTAIhgYCpOZT7N4deh9Y?= =?us-ascii?Q?pqd9Z5RGXJrwPwL9Pc5ZC7JGatKrXqTLSirz+xz2KOpjKj/jYc5Y3157RdCz?= =?us-ascii?Q?DiUPHUVOzfNW6GhRo5Yvceh4DimhA3k/ULyVSKbcsUQ0TlEWpzJBWNv3HgUd?= =?us-ascii?Q?TIvM9U9g+ExMCNVfhc1HHIB9jFd3QB71VZX5hOHreyIgegkY5IdsONfYXD3A?= =?us-ascii?Q?mg07d7xPoKqomb6no2pgsJVAwGRsahtQgFbrjb7Tn+j1rip1Uu2gCHURpKcm?= =?us-ascii?Q?iNKPnEaz+06p1PbvNYjH34Jsm/+xDk62zM3KLu0J?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f5e4e1f-9536-4973-dbd2-08dbbca96c23 X-MS-Exchange-CrossTenant-AuthSource: JH0PR06MB6849.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2023 02:53:25.7572 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: H9HpfAgIeaiJ+peRz8KI10S7xrGpSGue0VQdG7jocpRo/o0MxtXQI/U1fIRibJscH2TlzUlteM8Xxmz8ffvIlA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5326 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 23 Sep 2023 19:53:53 -0700 (PDT) In kswapd recycling shrink, high watermark is fixed, meaning the nr_to_reclaim value is fixed, so there is no need to repeatedly calculate the nr_to_reclaim value during each iteraton. Signed-off-by: Zhiguo Jiang --- mm/vmscan.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 mm/vmscan.c diff --git a/mm/vmscan.c b/mm/vmscan.c index a4e44f1c97c1..1aab3549969e --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -6638,7 +6638,9 @@ static bool kswapd_shrink_node(pg_data_t *pgdat, int z; /* Reclaim a number of pages proportional to the number of zones */ - sc->nr_to_reclaim = 0; + if (sc->nr_to_reclaim > 0) + goto shrink; + for (z = 0; z <= sc->reclaim_idx; z++) { zone = pgdat->node_zones + z; if (!managed_zone(zone)) @@ -6647,6 +6649,7 @@ static bool kswapd_shrink_node(pg_data_t *pgdat, sc->nr_to_reclaim += max(high_wmark_pages(zone), SWAP_CLUSTER_MAX); } +shrink: /* * Historically care was taken to put equal pressure on all zones but * now pressure is applied based on node LRU order. @@ -6725,6 +6728,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx) .gfp_mask = GFP_KERNEL, .order = order, .may_unmap = 1, + .nr_to_reclaim = 0, }; set_task_reclaim_state(current, &sc.reclaim_state); -- 2.39.0