From patchwork Sun Sep 24 02:53:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiguo Jiang X-Patchwork-Id: 144043 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp499236vqu; Sat, 23 Sep 2023 22:05:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4X0jHJcj5k24SJya67bHkKPZZtmdETsta4vAAAdckyPkrifeIdsmhD7TRhyDg0ovSnm/Z X-Received: by 2002:a05:6a20:4418:b0:142:952d:3e61 with SMTP id ce24-20020a056a20441800b00142952d3e61mr4992798pzb.7.1695531911308; Sat, 23 Sep 2023 22:05:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695531911; cv=pass; d=google.com; s=arc-20160816; b=V8lk4dCkkOFbmahzT2OOcdpWhT3X2tsxFcmVdMcuPH5g3FD6oLCGl6wY6OZPSPXgOd vMoEmTtgrUK9BSzowIIjN8kUMb4FUjIMTbDv6ODp+AzdKXKGNVkebygLA2RbUckszsfV XZFiOAUxKshRgw9K+za5Nb/KUQXvizL0s2h9XW2DaqU+EjXJRDSoEAo299BkmXiNFkld U/+USneZ9z/uNQGg3Rd2oHQz0jMjEywsnyKvSj9bS90PBilW3w+UTBlvLaDm7XGS6hje iv8xWnhpREVrHk9elN3/J+FW/8MzZOyllkb3g8x/xrgHCDVdBE2AbEaEwpB9TLaG1/3H Rl5A== 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 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u125-20020a627983000000b00690f62927casi7226535pfc.178.2023.09.23.22.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 22:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; 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 23.128.96.38 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 D17848111399; Sat, 23 Sep 2023 19:54:02 -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 S229791AbjIXCxj (ORCPT + 30 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 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: aGXEtHL/YQcv6TNby+4y772RvuEO3211ZYoISeEi1FZkONyh8JPt2k1lr0nOs5KJbBBaL3KjUgZbFOEFmBQs+caWx6unvmmshL6S7QbMBQ4237qeIt0PHuDfYIGJ8DacRKk8NxG2d0QZB0eKilq+/OMEXAxxHok9UQoLgiqieso1rMEoLz7CvCHl3jKPAHb66A0vqn49qAH81QKA/MvxONqefn5NqbHiWcRMWyO82GZpn1xZZkmM6ICA4MAxBOawRrz8Bj7hOtsefLmzuSxTxCpid9SkLj3i5b+zfzzEA80v+VWSnD3G8nyt8ztpoDWCycuID8Lb8xL0KJul95PJbYFwtwi9ncUPHZ5mJaJQhuR4x/Q4XBNXQlJGl4Q1Gyl72/IxJ2UgupsPt0fYsR0wdEQInwU/yKccSy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5hOHreyIgegkY5IdsONfYXD3Amg07d7xPoKqomb6no2pgsJVAwGRsahtQgFbrjb7Tn+j1rip1Uu2gCHURpKcmiNKPnEaz+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:54:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777894069459664495 X-GMAIL-MSGID: 1777894069459664495 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);