From mboxrd@z Thu Jan 1 00:00:00 1970 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 73563C36014 for ; Thu, 3 Apr 2025 22:31:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C1DE280003; Thu, 3 Apr 2025 18:31:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 770B9280001; Thu, 3 Apr 2025 18:31:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6372A280003; Thu, 3 Apr 2025 18:31:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4537B280001 for ; Thu, 3 Apr 2025 18:31:14 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 304FC56803 for ; Thu, 3 Apr 2025 22:31:15 +0000 (UTC) X-FDA: 83294179710.01.04E8A05 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) by imf01.hostedemail.com (Postfix) with ESMTP id C5DBE40013 for ; Thu, 3 Apr 2025 22:31:11 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=GYrDPtC9; spf=pass (imf01.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.179 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743719473; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=I2YMxJLVOxf5Msh8xAVkAPGRaQ5u2VBNP5i6pKAuBnA=; b=KTkYB7/b5+WQ/ZWEHj+jeZs0ipGjlAxgar8frT5mB6DA9KtrR0dCdmm0XfK3MzLHB9gTgK XfOrpHDZq5oZQv22N9mWd8XbPZO5h6wyEY0BZ/3YAInxwt0xYsHyEJEtb5KchR6xSMR69F URfRauaRR1bsEGLylbpRKChnIr4qoS0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=GYrDPtC9; spf=pass (imf01.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.179 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743719473; a=rsa-sha256; cv=none; b=O5qhtLQP/r2TQfLsZ4e8VAXVJQ9rzZD26sOkqthfFkSV20H2qIpwJ/+K9pvh0iLqQKvym7 p30gIASYlXc27UUERq9e7B1Q2q2oLCVgr15TUcwxlrpVqZe8ly3WIde2NXXiRjg6FIi3v2 s5aDAbnKheokduRX1o3fxNSmftfNKM0= Date: Thu, 3 Apr 2025 15:31:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1743719468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=I2YMxJLVOxf5Msh8xAVkAPGRaQ5u2VBNP5i6pKAuBnA=; b=GYrDPtC9HxorWN2ME9LQ7pSdx/YJdj+EQGY3OMRUKYMmgayRquh9gX+r23skWfDktLqlTW tEOBWd18SmZq7OqgJ04y8eC653vvXUof2R7kKPXRLxQHTn6KELScewHN36PTjDt3YuOKBc gu9QIDcMGX+LwnQESFvFY2G2iA34jVY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Andrew Morton Cc: Rik van Riel , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Vinay Banakar , liuye , Hugh Dickins , Mel Gorman , Yu Zhao Subject: Re: [PATCH v2] mm/vmscan: batch TLB flush during memory reclaim Message-ID: <7u3xvh3sz54xg7nii7lakwggpifv3ez7ffgmxjudj54bq463un@iyjjt5zosmup> References: <20250328142055.313916d1@fangorn> <20250403150055.94a38bc7e6e3f618fbc23ddd@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250403150055.94a38bc7e6e3f618fbc23ddd@linux-foundation.org> X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C5DBE40013 X-Stat-Signature: hghqb6u9bry98ihcgmkm3f1bm17ybx8t X-HE-Tag: 1743719471-474103 X-HE-Meta: U2FsdGVkX19zGFzwDUBB4iovKS6NxL0hnUZPaW//RXT7lQ+x3nR0bB1NusrMMgjJqfm/ondL0VrNPozcnMfRUwgKaiAOmFPkl/5/GYMHC5e1gv73E6l1LllqSqRSDtldGygk/82Vo2XXMIXzFXYvF/15bfgVSeQ59pvv1LFxPWm4VSa7FbSFGyrcrU3afBTsRMTagur+WeGHFsYTZ71SxFnFjknvfR4apio55xHB44DUbCGRIgVEt4ctucFzJCm9lUKC1hIY5Om1XdTrb3Nd9XWZSXeetd2E2jlnhlpBhBxTTulE5rkaIQJTWJFulabxS5UPSyDBASWjvJGqf6IlqzZlzS8qWu0NrCfAYXm5gMBo2/ekNghZ3fhlUepu3IIrsMKSjoA6ZOgdIvwXOpqHPL5gvzH5NcA7IXZ8OespfrLEFzyfeoIlhMRHr6FGXFz+bwpzEdD2iyKOKm9E2SD1wVU/0Zb2ebgy8oEzmYeruWJStud+DaYBqIj063ApRDcGFjQoAuNVVx+RYg2zmpPgVhaDMpzFIxA6HaDK6rJiDxUn7PnSO/dgs3qrZij8ZWwh4UvwGRdteTtFoONwryCOkGERCeD1UxrCylJAnF0SaPuFHnJE4X9Gdipxki0YKcpTYu2HDTa2+AniUdPEQGKON9q6JrFe9vsjyVR9Nw4uq5xABO3q8OXswhiQq026YdwKwvjh8YZQJ1EaC2R1OpHYF7xwmyb3ckNAe7nBRg+FIlQK3NMy5pG3vUboTean9U4yPT/cG7I4TbkgK68hwGbR91bC/kmVV8e4SSMe+jlvNVOubFVzxMmNiIHqmPokmHX6bibR6usBFkrhKS96RG3q+lurlCt0fNqnie3hjUXbbB0VkDJ+G/AMi4VctNo+xxbxYoq6RATOiaWXetf7JUEZ/V3XcqoMz5JxzdnXcpYsAnSgwM91x9ombhFGdRlwS/j4DI29S9ycSDc/pZl/Ry/ ejtccp/i +Vk1T9FlCMOYNAed9b2IdNGNbi8krYIF+hbSKA40aK9kEUbHf6CzeFZBEPSFSQj4LsrXykOEe9jEFqSu/lCIP9wTa9wmn8cM9xF3yI4xc9mYrd1gvJWEhK1DEuYuq77bZlSFrwH+1OBd6zpxjZZCXd0P21Z4XRq4N8vs1GxQEZzr2cnPcCX0M2w+5GmGw1VB2hU9aNhjGvsVzZt2CrVvyOeXPenjNBDnvui45BUhi78InOHM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Apr 03, 2025 at 03:00:55PM -0700, Andrew Morton wrote: > On Fri, 28 Mar 2025 14:20:55 -0400 Rik van Riel wrote: > > > The current implementation in shrink_folio_list() performs a full TLB > > flush for every individual folio reclaimed. This causes unnecessary > > overhead during memory reclaim. > > > > The current code: > > 1. Clears PTEs and unmaps each page individually > > 2. Performs a full TLB flush on every CPU the mm is running on > > > > The new code: > > 1. Clears PTEs and unmaps each page individually > > 2. Adds each unmapped page to pageout_folios > > 3. Flushes the TLB once before procesing pageout_folios > > > > This reduces the number of TLB flushes issued by the memory reclaim > > code by 1/N, where N is the number of mapped folios encountered in > > the batch processed by shrink_folio_list. > > Were any runtime benefits observable? Andrew, can you hold off this patch for now? I provided some feedback privately but let me put it here as well. This patch is very very hard to review. shrink_folio_list() has become a beast over the years. This patch is moving a code block within the same function and skipping a lot of stuff happening between the old place and the new place. I still couldn't figure out how the actual freeing of folios are happening as the patch completely skips mem_cgroup_uncharge_folios() & free_unref_folios(). Also the lazyfree counters are skipped. In addition buffer head, swap free, mlocked handling will be skipped as well. I think there is a need to explain why this patch is correct even with skipping all those functionalities.