From patchwork Wed Nov 29 13:01:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhiguojiang X-Patchwork-Id: 13472827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19E6EC4167B for ; Wed, 29 Nov 2023 13:01:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 937E46B03D4; Wed, 29 Nov 2023 08:01:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E76D6B03D5; Wed, 29 Nov 2023 08:01:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 788836B03D6; Wed, 29 Nov 2023 08:01:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 676376B03D4 for ; Wed, 29 Nov 2023 08:01:54 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1C7821C0409 for ; Wed, 29 Nov 2023 13:01:54 +0000 (UTC) X-FDA: 81511004148.12.86528DE Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2133.outbound.protection.outlook.com [40.107.215.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 62354A0065 for ; Wed, 29 Nov 2023 13:01:43 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=kbv0u1pG; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf25.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.215.133 as permitted sender) smtp.mailfrom=justinjiang@vivo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701262904; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=Cvm/ujxTwXGNHT39TGAcjZCTuY6kyPGesTONZlmbL/k=; b=SLnB1Bft+LtOuZOnAF8CV5eF7EAP/1F0y0zgorOxGJtwLQ+D/8EQzWcXSynZnPkXZR5s9a 6N4ZG1G1KYplNDQY6WhmwY39OjEj6En8OGhrMI9+oaP2mJwaG475CcKvs2D7D9MOgGkGci Z1nClQCz1FlXbkfdmIaAcE7SUXoIfHs= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=kbv0u1pG; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf25.hostedemail.com: domain of justinjiang@vivo.com designates 40.107.215.133 as permitted sender) smtp.mailfrom=justinjiang@vivo.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1701262904; a=rsa-sha256; cv=pass; b=FeoTttNqfn7J+vbWjMqdX7WFNgq0PyfZeYLm/YJDg7hz9XfvJosaSS8q9QyFWEwgCGgud9 +0/mEUgNsqQ4DEok8UISudbuLxnNw04Y/oxlNrH0s2w/uqYoTXA8s8RTPGLh0GlR1OYdPV f6evcn/Xh074FEFOgK9U39c1oRhyQgQ= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfTvXOz0t/J9qagO8Whe1qUVv3Lim7NHSkOClBxZx0nKeQcIEpomAetJYcWSW5AaARhZ/vJYVV70UjFeCbnMEokxIxPStHYmhj8rWqdQMloGjvkRFZFhcaOli82RffWiliIeByS5UdvBetOJTebSK4Kog+VEXxxse16oqV0dQXBHl2QdZRU0w8ikOYYI0UhfvrH4sS3O8dgv5lKxwX9+9rAXH+7l43fNNxZU7zQ0VVZpkD68n7FcXU3jAMO71c+tTCe3Y0req0Vp7gk1/uJgRoafHf7DWGqDpfTrivR92SBitt7d7phLUzFXJcbhxiYtbZ+GLKiNzz8e9lcBA2WCOA== 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=Cvm/ujxTwXGNHT39TGAcjZCTuY6kyPGesTONZlmbL/k=; b=YdY2fVmYb+4EZCkAZvJ2MJnqNQCjgKkrwH2r/PJIJo+JfothO7LTB4N5S1qajzvY/EokKWTCHA1SiyWnV8eaCTUUneFAt6BEnoRCyXLonFBJBF9XpuPu6QZi+tfuEnuTusrqrABfXL5fYHBZ2o6w5mfhr/cbfYC8X8rKyXPOxa2AwtHLHR8c5TIziPCHo4UcZawiVVhiqZ5QjrN2G6iWX/oufOFmm25UY6NzgRaM75RFa17nrPHDShNiReM5u4K6UeV50AFjCHry1cFoW/edHKSQBUwiHUsMbASmdDlPblVhGBU+39DfTJaLeQKLo6EEXPJIswofWi+NVRN2Pm6/SQ== 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=Cvm/ujxTwXGNHT39TGAcjZCTuY6kyPGesTONZlmbL/k=; b=kbv0u1pGsZgmQ9K9xqfpWSfKhLr6NbFPFUe9IL96FJY1Xx/gec+CmCGbmZMn+PWRhpWXFv9CInK3667YFx3IyKxxb5u707DdVxK/UrcvXkvm+sJ6qCaZ6Dkj0N8QA6v4eGbtHKJoRO4TAtqSylPD+rs7DcO9Fkmgbt3rbkJyz8sjQmFGIpUqIA6GoEoa7jmlRG/VdUQOzvzpq6T/1thZo4xKda99uyYlN/gxEtB6+WzOVnXA5GYAYax506w9Zv+M8lGnyeX74WQW+8GO5OIyh1DM/wmUWnBOSpXo12wOxlK4UOyyiifEP+p6coQVprjRs9nO23rDcQxre7tCYMMugQ== Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by JH0PR06MB6850.apcprd06.prod.outlook.com (2603:1096:990:4d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Wed, 29 Nov 2023 13:01:35 +0000 Received: from JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::1be0:ebf0:eb04:6bd3]) by JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::1be0:ebf0:eb04:6bd3%4]) with mapi id 15.20.7046.015; Wed, 29 Nov 2023 13:01:35 +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 shrink sc->nr counter values issue Date: Wed, 29 Nov 2023 21:01:26 +0800 Message-ID: <20231129130126.2130-1-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 X-ClientProxiedBy: SI2PR02CA0017.apcprd02.prod.outlook.com (2603:1096:4:194::17) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|JH0PR06MB6850:EE_ X-MS-Office365-Filtering-Correlation-Id: cff08565-5a1e-4c42-584d-08dbf0db50b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sCgwqDNBlrDPF7IjORd248yOKjvF4wR4ZTXnFzSlEQbHha0B+Tg+rKGDnap9fP0Z8gseipc6d4C5entAiUKfQNJYWZHhDheQG/6R08kMA8Vaa5/ZZupSDgc70zzUM58fCqJUe8GxOy3XK4din/PslOLsvsbeRHJylEvaNaAXogyce/7UQq3D8iGv5RDQybEVo55q/zeE81nmo6uLubs9zpELrFNFifUd7Ho6novFBgpfaI1eYY5r1lQTW5sugE00h8E5oWqyAD4JicFSnzKI2bSWAgVSLoLsvOcOc2YloboEQqhW45NESyRlYZ9Yh8V4ikAi9inl9qNXinXVZbaq1zyk9l98TTOo9hIRJFJbbZX9Xl5w7Rx3pGE8f75zJZDP5WFTdzgrMkklSmjm4Fa6zwnkwynTGi6zFyzLuRMEdhGReQhSIFYmTS/sSuuYBGgk/Tv32aVYfheIU4JaPE8ih+2sW/SnSSafT8sIOhsPXIEufc2mC94Oa37fCk33fwLdgeCkf0y3WYgeIBDoSArB2l6DYDAMVp14deqAO0v7wbzY0nWSd4S8IkEG7A1VA3N0n3m+/Q5R0vrZIp+huL57cpz3mLWzhowfO2bYqmxZ/YiKmPf5IpgvJl26heoElbGY 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)(366004)(136003)(39860400002)(376002)(346002)(396003)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(38100700002)(83380400001)(4326008)(8936002)(6506007)(8676002)(66946007)(66476007)(316002)(66556008)(5660300002)(86362001)(478600001)(6486002)(2906002)(36756003)(41300700001)(38350700005)(52116002)(6512007)(6666004)(1076003)(107886003)(2616005)(26005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fq9IPqsy7Gsmpjp4z7baQtUHspAplg3LAYIBt1d02S7Cew5/vZOe3mNyMdX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D6A0x5PwdHDzw+LpngLTWGEJf7l4eSMfKdyco+QpLIaIYBfU6hcE/Fi6XKr7DLSZVpYMyhoUI18TzQDCAEaByu273CN4HfFgCZgA7LApb/cPxmBke/SizbphEDQ1KuRcQSRHpS+9uJiR+EqoPf3ZzXQrZaB3fyGWTHWSXdhe8p2tP83QTUYLzCOWkJntBLWyCj2WNWVrJ8AWUO8ODrglKfWZ4SFaO24MqDXdiktG/AB2QGIDpu30NUQvMudYi2PTrWgWOeneu8umFM8r+T9HmMsEp2XVv3t1gR6uOpS6+b4U3x0FYcebGArwKNUPq6kLdxNu/jkG9360ztwYFDADtVdDxt/+1v0GL/CWY1vMQhbFwvqAX1cu6tU6aGtz7Gk8QgkzpMbyH9llyskUy5X9x1UZxYT6An2Pz6uODRpVd6WME+XgN13cqKNQcI1xo7r30JGy00SxDFxq X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cff08565-5a1e-4c42-584d-08dbf0db50b8 X-MS-Exchange-CrossTenant-AuthSource: JH0PR06MB6849.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 13:01:34.7044 (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: CKNs+wwByg0UKvMcDYEzE6sKq23/QOTu2mCVBA6jKRfShKJ7sTWfIhawpWdStMW/fNW2a5e9GnBACh5WR9I4QA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: JH0PR06MB6850 X-Rspam-User: X-Stat-Signature: 4utqrw5eqn83bzfjx9auuy3isggoi68g X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 62354A0065 X-HE-Tag: 1701262903-564119 X-HE-Meta: U2FsdGVkX1/toG9eLbolCdqtPbFRn4Cwow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j0Ye44GBF0nvpB2h2uEfOiKS6mVnBeozhQ2jq6FRjYrIf+bu6bfT0HcnJNJcLFHkk3nLfW67l4q6rKGTAaT1Kv7Bl2aGQQ9fVUlVGwpZ++6+nCls17mUjG2Xi3rhOzDGBR7x4QD1FUUs8NefTu8Dq94PCbUgyoAY5NchUIsmdIAtLY54wJ4gflsv2r2Jp+Agr/iTCOjHDI3njdlekHmLL1ES8LQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: It is needed to ensure sc->nr.unqueued_dirty > 0, which can avoid to set PGDAT_DIRTY flag when sc->nr.unqueued_dirty and sc->nr.file_taken are both zero at the same time. It can't be guaranteed for the PGDAT_WRITEBACK flag that only pages marked for immediate reclaim are on evictable LRUs in other following shrink processes of the same kswapd shrink recycling. So when both a small amount of pages marked for immediate reclaim and a large amount of pages marked for non-immediate reclaim are on evictable LRUs at the same time, if it's only determined that there is at least a page marked for immediate reclaim on evictable LRUs, kswapd shrink is throttled to sleep, which will increase kswapd process consumption. It can be fixed to throttle kswapd shrink when sc->nr.immediate is equal to sc->nr.file_taken. Signed-off-by: Zhiguo Jiang --- mm/vmscan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 mm/vmscan.c diff --git a/mm/vmscan.c b/mm/vmscan.c index d8c3338fee0f..5723672bbdc2 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -5915,17 +5915,17 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc) set_bit(PGDAT_WRITEBACK, &pgdat->flags); /* Allow kswapd to start writing pages during reclaim.*/ - if (sc->nr.unqueued_dirty == sc->nr.file_taken) + if (sc->nr.unqueued_dirty && sc->nr.unqueued_dirty == sc->nr.file_taken) set_bit(PGDAT_DIRTY, &pgdat->flags); /* - * If kswapd scans pages marked for immediate + * If kswapd scans massive pages marked for immediate * reclaim and under writeback (nr_immediate), it * implies that pages are cycling through the LRU * faster than they are written so forcibly stall * until some pages complete writeback. */ - if (sc->nr.immediate) + if (sc->nr.immediate && sc->nr.immediate == sc->nr.file_taken) reclaim_throttle(pgdat, VMSCAN_THROTTLE_WRITEBACK); }