From patchwork Wed Jan 8 16:18:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13931288 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 C26F7E77199 for ; Wed, 8 Jan 2025 16:19:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C62D26B009C; Wed, 8 Jan 2025 11:19:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C11706B009D; Wed, 8 Jan 2025 11:19:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3C3D6B009E; Wed, 8 Jan 2025 11:19:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 830DB6B009C for ; Wed, 8 Jan 2025 11:19:11 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 04440C0CEF for ; Wed, 8 Jan 2025 16:19:10 +0000 (UTC) X-FDA: 82984794102.29.C247E62 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf18.hostedemail.com (Postfix) with ESMTP id AF0DB1C0006 for ; Wed, 8 Jan 2025 16:19:07 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=RWnyotQE; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Eq23ICEQ; spf=pass (imf18.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736353147; 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:in-reply-to:references:references:dkim-signature; bh=TeW/+yJcrglGhUjMtcHmixJQKg4v6rstkAUVUeseIlM=; b=b8CjPDmaUhIchdHW76sSIKh/7sXuyRuxAXrkX8t2Hlou/+CcYz2Kw7YOD7L8WrSIg6IW2o JCNCnNATws61PEZxu9+dFmt6VSW9QhpfNmq1D1iH8cewh031hJxrlene5LbEf9R5/oVATE qMbnDr3XxTVCdkOXfvoH1tC6k6G3F0U= ARC-Authentication-Results: i=2; imf18.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=RWnyotQE; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Eq23ICEQ; spf=pass (imf18.hostedemail.com: domain of lorenzo.stoakes@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=lorenzo.stoakes@oracle.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1736353147; a=rsa-sha256; cv=pass; b=rxMDkgZQks3WKzkfUbIsnM6JvxBpd635Pef5rHYCCic+ZPpTzkwL2n6xTESzvIlIT/glng pU2G7MaOwMY3yWHtNOubPOc8H+c75nJOASXJdM1AMU86syKUqnLSdC8gZcmphVATBDi8pK tFOcXMte8e/JIKBmJJN96gJilC5wJMA= Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 508FNI5V017695; Wed, 8 Jan 2025 16:19:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=TeW/+yJcrglGhUjMtcHmixJQKg4v6rstkAUVUeseIlM=; b= RWnyotQEMtOTg1BGQnAEk/X+3ocXuzxIT1Vys/Gx/Fn5HjbrxWHpx7k7LyieuhZC X2P/VQsxK7cYYdE4aGAPEmtnd6Bm7IXOLNINtfJO3syjUQZBlR4S30sAwyvrkwyW 4xmj6NyKJO4ldMUzrV/vHtt7dcEZMF0wWRglU9+ApceqRxqRqAgsIMgeggZrD00s UhfTGwgYN2hw3pAmOXSN5NZV91vCBgrqyY8IqLqSfzscVI9f5wM9kBP3JhKERiBp 7uEs1RV+cNnrprM8dDBPxqKGdhXNBKq1D1iyhVhloKbRJfwL5AfeRnxW//QMvb7s nrQDc3iisEmc/gbJ9SX2gA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43xus2f7td-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Jan 2025 16:19:02 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 508F5tOj011115; Wed, 8 Jan 2025 16:19:01 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43xue9s9ps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 08 Jan 2025 16:19:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W4gdT+7hwaGcSn/vCeI6geDWnpxrlmiQJeVaVUFccnEOtI86i2J82RY8lzCZZJtFhGZxLys09m5fLb+rBPgIIdjdDUSgVU21yIE5Sr0SWWuHIMHVJodUm1ivzcRvyCUvsWa5Osa8rVocffUfoSGmYzQbf/IcJp1LxQKjy7tGNKX0ZoeMHqFheFJjsMtu/qNe6HfLvLzSx/Xgy1/5BOqCtuBtcnSMRBnIq7k/ylMy4mnzMTG9BTCP7T1a6QUADvKPRHbFe9gS6DkMydxvyUqrntPDbAMiPiE2faixdlg002mVP/oOvxVWeFowJoV64hfPh2BFGVv12rUS8sgfLPeyrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=TeW/+yJcrglGhUjMtcHmixJQKg4v6rstkAUVUeseIlM=; b=WOv/8cTdQTCMh9/qyQJcjNy2e5HqNBnIO3pHxq3qMDMhhuhR7d+PuzeS7S6PZD+VHfoqrNmVXtu8OFwryGwrNh2byOzu4IdVmmQFO+YNiEzklj+VCUr+4piWDVD2IKIJ8tqf2+WIM5nR5EO++2drNHtwXTlra47nXQviXYxk5rjjjg7bOB1PcrlErn10gT2HRkRDfS8GZrhIL854EO/g6IAPb7guGusE+x55cDnYFylJq0sUGwwF2SD8eju6wOxylf6oKCHGNzDeT84iEcBwpTrtxfA8L8+WvOLuLPSI7XNY5WGSorqK2BNU6NcD/s9zJn/3hJW7gSb5hZYOspcg8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TeW/+yJcrglGhUjMtcHmixJQKg4v6rstkAUVUeseIlM=; b=Eq23ICEQuhM7omv1xTKjHAdBW3ZSAKOti/bdCVNa2tZDXhi6agPlUOx61hxzJV/F3OqHXSxvd3mlAopf7Et0uA8qWudNU6Ce/V2oK3SrBWuGKRpwm9TTn7iQJuC6G6oT+x7KRO04CMuQJuUxKGaWvW2m+L9BgT6dcMKkFg7n3Ms= Received: from BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) by CY5PR10MB6046.namprd10.prod.outlook.com (2603:10b6:930:3d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.11; Wed, 8 Jan 2025 16:18:59 +0000 Received: from BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9]) by BYAPR10MB3366.namprd10.prod.outlook.com ([fe80::baf2:dff1:d471:1c9%4]) with mapi id 15.20.8335.010; Wed, 8 Jan 2025 16:18:59 +0000 From: Lorenzo Stoakes To: Andrew Morton Cc: Jaya Kumar , Simona Vetter , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox , David Hildenbrand Subject: [RFC PATCH 1/3] mm: refactor rmap_walk_file() to separate out traversal logic Date: Wed, 8 Jan 2025 16:18:40 +0000 Message-ID: <0c53589f34a6195938eeb58c3a88594fa30cc90a.1736352361.git.lorenzo.stoakes@oracle.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: X-ClientProxiedBy: LO4P265CA0063.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2af::16) To BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR10MB3366:EE_|CY5PR10MB6046:EE_ X-MS-Office365-Filtering-Correlation-Id: cfc8154b-c2a1-4298-b3ec-08dd300027fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: 3ahoROuAXolnvzPpI35353fLbrlSN6EOvisdQ91yODr3/NpPllsrpogegcfzef5FbXYufbUGX56shMt5mumNgBkjCpo494eRyadm+0MY9tQC8Lr76Gscl/rpdpLjQviL8Lu+G3YpmO0Br5BCwW7eDQXEzotGKyW41wvQCUsBm91NOqQZuyr5TROGz5Lk5jG4x5u2WrJja+z3As9wtcGLlIGK9MR+PamHxVmzfZsR23yh6EN9TykFbHsEq4tWcfODRMj1fIONwWtuaP09gaoWG+eUgy4Gb1/UNgB1zQDMlP7JknbjiX9ILltnBxu1sUOjUgH1NMAUmUK2f4nD5u8PWsa/XFTeJy5WguAnhFB4fC5k7nQiPGs2qf3SyScozhkSPZr6PGHVjWLTEr6c3s1hmbE+B8qdLMgHimdi8IhqP6ACGPsgjgGt1Ykx4Skqk2hde5fiKs5mCB2E/1qiiy1KQ7HiPjrs8znROLsC3eqEHEbDQ3TnLyaY9lobN236JxRO0f1D+Jc97clN8KGyn71bhUUVC2Hmtn+8z/Y/4mfs+wflsbRe3cuOyHkWhqWO82voh1HjXTopPrt3xvNAtmOM+I6y4JMFW/RdBNQgQnhcBUvUOFJciMzLPbz8k8EWy1HwkmdtB2x2pmNMqV5JY6PLa609U2hFLt3w7S6lfYOfHlHjaQnmWKO7vwz9zypXr+lW9u0uAdT4MwwIn8/4KV8thNis5SmGNcp4ZtyOk1LpU7k7DCohdtOUJhEIMLtdRrpFaGoIaoouD5jJJWgf0U1JpwIEY/0lUK1gU78JGzzey8RrTcs4wFVl9iDbxMED3P2SX9eKhLUpVsDK61CHNu1wljDHtOL1nH+rsEbaoLwpJ1B9VcQVM/OKAUbv2nNk4dPafGNAVS9DJz4mjvBSfPqVLRxfe8GstszvUr/1bZ5KUSkfzJ1X2BrlChLupc2D79A7rTaH2+Lb4VkAR7mHjBtD69cyra2iF91RLWjtZ6rDsJPDhs8byrUTVsx/AHU5M2i+N++10miWic1w4zOCMOgC/X2hKbepmHkO5h9AFrGuScSMCmbzi2ybeKs3jZXPaJ94KLiP/PLDKDBOWMVprnd3tXNvf1wGgczJFSNpscP5SBSUiJH4utNXDzWf/VSPk1NxB7DDw4qCrO/UrCfTSpHJJCLrY7smVRob7Vefpi9+iOo7EnYXolVF+viA8i3fELr93pJhunzRmuQD9EzSIfDRfB0kJD39ViZESFylm1znsoo+/XmKUSZAqekZubFs8uX/dAzLcmMw63IyJu1NwAqpy+GIadD7da3rP96kqUa1metQ6DdgsGLNfA3BiNGdkTFP5OfsjEgfCVt2UkQZRxkryO0VIvpGLwKn8sEQVMZI2n645JSCgWWBFLwmbHfhDsQG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3366.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ucPBUDtYS6gcp0bQdME2RKnSpyz5JPYE+2hdOcVtN9qLiOJjU2URUvPE/x4CNOlzsiezjdJ0Dgxc9W7UMzKtLUeAVlaZtx6FWWTGqYlOrTrWhyj/PpwL5JBFBosi1sbi5CKMSBg/MNDOxQvCv/za1pvovhwxHFU1XpADIkU2usSRGVu/cIT5QOCA4flE9Y7qxe0o1nETpie9hJkdoMhjSY9mk3n5St4VQrNDDtK/2ejG/8v10zfXmela7AFt4JUBnIbUXGcQNAPVXRqA2QZ6z2ZUT08akr+715SgKJEuAaQTjbpBf7OGPYSFYyODK/+Yt9+pKlLKxBcjrQ4lD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aMCnsxOdwxlTbBlJ+rMFhWaCt8hPxnhi3Cs4URSSAtmIeaxVteTUhhTwZg/TK8PnQqN0HJQoDcCwhb+52fCQxk2wsRz4oM34JgjFSEPUpTDKOQrRChNp2BMWA5Uf1QFRem/fnsSVxnyIYPwsMtN4EVLyfYphUh5VcF19X2mHmxjeNxVS8AikeFWbHpEvdNaUEgAw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: IJ/CAscFtguQFP2nBpc53aGHAdz1SldeIUsowPzXeisjamDPPbefK1/Ggq2D5Y71rP/7Ex5WX0ug78bwafdeh20n8XMZCXBW2Fd87LgMNtWCQH8CyIKGsjHfNGquiQuxwSOHbwhy8zUs6aY2m6XbMVujZAtpx9fsRa+bXmlwv7011m0sFQ3KRk4bmH4rGQt9S2P+EvQpdqPj8WAUEXIk9SUVD2a2g+t1TN4UV/DH6t3Yen7p/20nMMbGc7DQ8OEEKrjgCMyaEm6d+QiZAa5MXtqCcK5NSHYC6j+H7xEDlyZoOfel/6+caTXs0UmRGo3sYNqvcnnKqYYapnffmAVm8l9vX4CX9ctdH7QlLZoFV9gVGyyxdfEURdahebKnj6SPLCDv6+k3llsFyLPntsdvqmOMkZeeDTGVx4ZVZO5tuvn7Sla9yNohsRuKBDrqStywospuJFnOGX+521AtvRfll93GfjnRc68meyvDi6PYIx/kGKc8EkMYUGz+f3MRDfi9jthBVi9mc8L6KaQekyOTFh1erzVn4hYRIGdjEkcoSdS1a3Bq2Op9b2bwWuZ+KNVRIPp+HG1bHPzLe+mhUTta98gnhtl7K0gnN5Yr+hCbmr0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cfc8154b-c2a1-4298-b3ec-08dd300027fe X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3366.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2025 16:18:59.1281 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GP4RvtXxEuGeEXJhRK7KmiMRiYscA+4+/GLZv0JaHeKK9kgLVfmgimlQSqBG2/fJq21g59bVn40hTQIcEm6bJcE5OjJOJ+CTO6R0b4M6Cc8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6046 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-08_04,2025-01-08_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501080135 X-Proofpoint-ORIG-GUID: csesqimgMFh39tn_UcBcPEE2_sOHbexQ X-Proofpoint-GUID: csesqimgMFh39tn_UcBcPEE2_sOHbexQ X-Rspamd-Queue-Id: AF0DB1C0006 X-Rspamd-Server: rspam12 X-Stat-Signature: f15sfe46bu5ib66wtawyym6ax4qhao6o X-Rspam-User: X-HE-Tag: 1736353147-856405 X-HE-Meta: U2FsdGVkX19aoxp1pMYJs+Pe5/by6yUv/YUUGA1EwcHhtlDiwO+sYES9mbsHIXaG5mYNid0QnJZJ/sSAoh7IRTyQVzH5Z1grmEPeKam+qCxrXijB/RGd6XeXz8XjlKQ/5XcH+m2AKopun1FFSxrxGAlbq01fm48Oaj+sjTgW/xins1pDqQckJBKIgIiYJbtKk/VSp6rJX8U/tng1YZlQdMCO+vqjTkagYax/7i8M5kgX6SeVXSGjJwLO8GjHEuXAbq5wKyRUn99wgfttqz9WPNsRO6Rduq1/GHuFrc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rslkzwCtsyoyog2I6zRLtihOI+CLA8UOJvRGiu+TKzX8zW4iCuUstBak5/BHLR6v9I9xwRdHOQqJ57vPM3c1FqWf0+yI8y8k0/wZFqpwTjimgFchqvvCMX6LVeqlCaqlgcD9vJ1zRxwOcb1xoRgQ8U5Jsj+5QNM4fHoxaAy1LXUs3z0Jo67DJXvznjQ2Q4eoAVutUS/wrG4xA86NbxwJgz1ZshESp7dCCdlE3t5GV/f5Q== 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: In order to permit the traversal of the reverse mapping at a specified mapping and offset rather than those specified by an input folio, we need to separate out the portion of the rmap file logic which deals with this traversal from those parts of the logic which interact with the folio. This patch achieves this by adding a new static __rmap_walk_file() function which rmap_walk_file() invokes. This function permits the ability to pass NULL folio, on the assumption that the caller has provided for this correctly in the callbacks specified in the rmap_walk_control object. Though it provides for this, and adds debug asserts to ensure that, should a folio be specified, these are equal to the mapping and offset specified in the folio, there should be no functional change as a result of this patch. The reason for adding this is to enable for future changes to permit users to be able to traverse mappings of userland-mapped kernel memory, write-protecting those mappings to enable page_mkwrite() or pfn_mkwrite() fault handlers to be retriggered on subsequent dirty. Signed-off-by: Lorenzo Stoakes --- mm/rmap.c | 81 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index 227c60e38261..effafdb44365 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2710,35 +2710,37 @@ static void rmap_walk_anon(struct folio *folio, anon_vma_unlock_read(anon_vma); } -/* - * rmap_walk_file - do something to file page using the object-based rmap method - * @folio: the folio to be handled - * @rwc: control variable according to each walk type - * @locked: caller holds relevant rmap lock +/** + * __rmap_walk_file() - Traverse the reverse mapping for a file-backed mapping + * of a page mapped within a specified page cache object at a specified offset. * - * Find all the mappings of a folio using the mapping pointer and the vma chains - * contained in the address_space struct it points to. + * @folio: Either the folio whose mappings to traverse, or if NULL, + * the callbacks specified in @rwc will be configured such + * as to be able to look up mappings correctly. + * @mapping: The page cache object whose mapping VMAs we intend to + * traverse. If @folio is non-NULL, this should be equal to + * folio_mapping(folio). + * @pgoff_start: The offset within @mapping of the page which we are + * looking up. If @folio is non-NULL, this should be equal + * to folio_pgoff(folio). + * @nr_pages: The number of pages mapped by the mapping. If @folio is + * non-NULL, this should be equal to folio_nr_pages(folio). + * @rwc: The reverse mapping walk control object describing how + * the traversal should proceed. + * @locked: Is the @mapping already locked? If not, we acquire the + * lock. */ -static void rmap_walk_file(struct folio *folio, - struct rmap_walk_control *rwc, bool locked) +static void __rmap_walk_file(struct folio *folio, struct address_space *mapping, + pgoff_t pgoff_start, unsigned long nr_pages, + struct rmap_walk_control *rwc, bool locked) { - struct address_space *mapping = folio_mapping(folio); - pgoff_t pgoff_start, pgoff_end; + pgoff_t pgoff_end = pgoff_start + nr_pages - 1; struct vm_area_struct *vma; - /* - * The page lock not only makes sure that page->mapping cannot - * suddenly be NULLified by truncation, it makes sure that the - * structure at mapping cannot be freed and reused yet, - * so we can safely take mapping->i_mmap_rwsem. - */ - VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); + VM_WARN_ON_FOLIO(folio && mapping != folio_mapping(folio), folio); + VM_WARN_ON_FOLIO(folio && pgoff_start != folio_pgoff(folio), folio); + VM_WARN_ON_FOLIO(folio && nr_pages != folio_nr_pages(folio), folio); - if (!mapping) - return; - - pgoff_start = folio_pgoff(folio); - pgoff_end = pgoff_start + folio_nr_pages(folio) - 1; if (!locked) { if (i_mmap_trylock_read(mapping)) goto lookup; @@ -2753,8 +2755,7 @@ static void rmap_walk_file(struct folio *folio, lookup: vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff_start, pgoff_end) { - unsigned long address = vma_address(vma, pgoff_start, - folio_nr_pages(folio)); + unsigned long address = vma_address(vma, pgoff_start, nr_pages); VM_BUG_ON_VMA(address == -EFAULT, vma); cond_resched(); @@ -2767,12 +2768,40 @@ static void rmap_walk_file(struct folio *folio, if (rwc->done && rwc->done(folio)) goto done; } - done: if (!locked) i_mmap_unlock_read(mapping); } +/* + * rmap_walk_file - do something to file page using the object-based rmap method + * @folio: the folio to be handled + * @rwc: control variable according to each walk type + * @locked: caller holds relevant rmap lock + * + * Find all the mappings of a folio using the mapping pointer and the vma chains + * contained in the address_space struct it points to. + */ +static void rmap_walk_file(struct folio *folio, + struct rmap_walk_control *rwc, bool locked) +{ + struct address_space *mapping = folio_mapping(folio); + + /* + * The page lock not only makes sure that page->mapping cannot + * suddenly be NULLified by truncation, it makes sure that the + * structure at mapping cannot be freed and reused yet, + * so we can safely take mapping->i_mmap_rwsem. + */ + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); + + if (!mapping) + return; + + __rmap_walk_file(folio, mapping, folio_pgoff(folio), + folio_nr_pages(folio), rwc, locked); +} + void rmap_walk(struct folio *folio, struct rmap_walk_control *rwc) { if (unlikely(folio_test_ksm(folio)))