From patchwork Thu Sep 19 09:44:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivank Garg X-Patchwork-Id: 13807608 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 52469CE8D66 for ; Thu, 19 Sep 2024 09:45:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5EAA6B0093; Thu, 19 Sep 2024 05:45:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0B366B0095; Thu, 19 Sep 2024 05:45:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5E526B0096; Thu, 19 Sep 2024 05:45:24 -0400 (EDT) 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 96B766B0093 for ; Thu, 19 Sep 2024 05:45:24 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0F6AA1C297E for ; Thu, 19 Sep 2024 09:45:24 +0000 (UTC) X-FDA: 82581004968.10.7A3456C Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2075.outbound.protection.outlook.com [40.107.92.75]) by imf17.hostedemail.com (Postfix) with ESMTP id 1DA2440006 for ; Thu, 19 Sep 2024 09:45:20 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=lANo6acv; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf17.hostedemail.com: domain of shivankg@amd.com designates 40.107.92.75 as permitted sender) smtp.mailfrom=shivankg@amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1726739110; a=rsa-sha256; cv=pass; b=XE4ZpfVSukKgcul/z5fO3MhgNPelWRmgCkvtVZE4XeCyRkv3g7svnejBoKOvGJ0F6IwuVx wQ9lzL3Nu2aXqxu9wIJWuIiLttJH1BLijaUo5aa2zacVJn8TkAbpe6NPYw5BevTJlsYYly BPLgPQ1fCNv5TyIp+lxoRaCWEGh4UeI= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=lANo6acv; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf17.hostedemail.com: domain of shivankg@amd.com designates 40.107.92.75 as permitted sender) smtp.mailfrom=shivankg@amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726739110; 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=9SNmEP9ffiNaTSzFYP+hIwyVz5gMf9kYO9erAqnd/kk=; b=3syulSoGCa96OCJOrANKr9FiwLEmnZXuAKreiWnZnlB9MAdLp8ySP7hZszLjbTnnPVUkd0 UFqUua0rpqBV8qPwgB6OkgMd4gAL368tHbon2VkFOSZ0Pwu+HVkMmU2nM1AubTT5EWNQ90 WqzwuKLuEG2iJMuC3s6gx1NdPUXOUMY= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LRqUZ6BrEe7UY/a1P8pmGcdvkoxt1WvbAyl3/t974e2bQtwVgS3ZuslsjPsb3Wh9BVBciwqzEcfsCViRjRUzQCE1HHumiqmpU6zg/GhduRKV5gsaNn2pcNXlhTKSPI2D4nzHjvRsywQ9oYMmGlOOAieeWZGz+Teu1/tDdH1gCk9do/zgg8n5JRcFdw8CrBlXWqrl/yCyICSCzo4/17RSMrrgdC5skcLhQVs/xrU2ZFCRPUQaVl5o1aU+H0R24ng0hQo5qdpJ6eKDMTQbDJUsp06ehDakb3DYMFtgP/gn+IVVoL5HRYPnjwMGOQZxGe+qUGTz+rHgbUrCQWEDEKJ7Ig== 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=9SNmEP9ffiNaTSzFYP+hIwyVz5gMf9kYO9erAqnd/kk=; b=dmitq/5JsDFYxtcyAbtQNBUxLBWC/t6zGV3CQieTAMg4sk4n4w1p6DyTk/nlx/bXQhcf/SIMnOAhkPsP8X5okvk0T/Yn0vLo4zeAQDOnetmH5D1PWt9bNEXMbpPxA0ZI9G/YZkuTVFNVjM1SnnA8omZkSrRHk4dNCxbIOROK1ePNHlIvAI6tz6yFbqqZfavci09A/Q8dk6j/P4EJOPODkWyrswYZbyq3CS6GHN6NZLMmvstq4mFKAVlWrQpcYaGs52SxZ/IZD8oOXssAIaqPNmrLsKa1zCbpZwamo0v4Pj9PpN68WQjhkAng5tYxQ9J+aat6CElKlnBqzDbzyeG06A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9SNmEP9ffiNaTSzFYP+hIwyVz5gMf9kYO9erAqnd/kk=; b=lANo6acvFf3wQAq+d1mNdnxs/jVhMSKkQceJknALt8OpdBodY9kxGUOGk5Ix0srL+t2L09RhF59IzkzN+XHgLqkvnZDM+7VMs+pse78kqeNKGbTdlpsIVhDsV2shxd6DRxMEka1sWjSRiksIzuXnBqjMshxzYiT85EIV+60wl0U= Received: from BL1PR13CA0400.namprd13.prod.outlook.com (2603:10b6:208:2c2::15) by MN2PR12MB4287.namprd12.prod.outlook.com (2603:10b6:208:1dd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.21; Thu, 19 Sep 2024 09:45:16 +0000 Received: from BN1PEPF00004682.namprd03.prod.outlook.com (2603:10b6:208:2c2:cafe::af) by BL1PR13CA0400.outlook.office365.com (2603:10b6:208:2c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.7 via Frontend Transport; Thu, 19 Sep 2024 09:45:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00004682.mail.protection.outlook.com (10.167.243.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Thu, 19 Sep 2024 09:45:15 +0000 Received: from kaveri.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 19 Sep 2024 04:45:07 -0500 From: Shivank Garg To: , , , CC: , , , , , , , , , , , , , Shivansh Dhiman Subject: [RFC PATCH V2 2/3] mm: Add mempolicy support to the filemap layer Date: Thu, 19 Sep 2024 09:44:37 +0000 Message-ID: <20240919094438.10987-3-shivankg@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240919094438.10987-1-shivankg@amd.com> References: <20240919094438.10987-1-shivankg@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004682:EE_|MN2PR12MB4287:EE_ X-MS-Office365-Filtering-Correlation-Id: 34a31009-748e-4b5b-42ee-08dcd88fc3f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: HfzqPEcjGx5qNfopDq3cPnfkIhBoSu0aHEKP1GZL0xL9i3LqSE0Opc9+J80KJjffM+BbuhebIjKR/UrghO7aiY8i7vfTORKWW+rrW/Q4hiBEr9cpxLzUTVM2/h6mZks7zTGnWDxftTnlP1/eBhnkinOXAOWABRfzx8Iv7oJdbDDDJpbVG0RhNMRFPGCRRkb5UY1sAJyBW8dXA4AhcZ65iuuCCcbFCBb90qucx5jlGTN3x5ATSuthEx0Gt2nO2a4K6wYwh0Ze4yN+icatQGBtOrO2Z58oroqEwgHDBtRBRjq/6GaW1/cfCK48kRAhnEovofbv4j1baO/7sQynazojpzWVm3XKf6JcDxb11K4rkLzvF/H9nNehvz2pwesPiZvaJ4RCBVxt0933TI88XMbZrLgeI/Ag2LnwmH9qN+mIctWCBrrQfwYsptO6BV2cP4Rv8waJhsS9/FtSQYanbyAehy1CleMGsniTVCretlYb3zn+ME02mEVnfoBP2U5/8mhIxYbjtqArKhKiMIDiRcplE/xWo7FkMuh1ip8pHFdR4VnyjSmflQg1eiDotiqAZxI8D4Jro1/R+JTBxr4bhInE7lSp2fKrcBN0ipw6gNewvUO0rO5cAM5F6iRuqQ1lNHzp319gwyu7n2oyqrCKGdpBHZlsdrifOxD33Q4NH0NqFEQ0hL4MDeihfY/mGQ+IsQvu9Gd6A0bF1MdHnzJ5iHE11ZBJe7EIZcK20DywZqdDsc7VNHW3BDtg0ZTtAh4oV/VrqLhQCZVpeMuDIVz5xEqrx4fUAR4Q68HSUtb+SzES94EPgJP1zftKLM5zhzGbf/h5MflQZe3C9Zw0FiikpC4dOkbuxd8ylpH1Wxl/hCxLcEn2Tm7Dtyrv1vetQZB0XKKAWdBm4Y19+GDbCgGhigWWm84jebVckwZKs+gyHdlTk3E0GOq/GzcxLbqibKm2o+zwNlKv6a7AYyUq+FhyGOfpp112/dhY6eeYaLxPRK4tlinc48l01UGrwJnaURcukae45PFp200CWiADR7XoYzNH6GXUKFIOEr06/jbl4rluf5zvnoom+WfUBmtHsAIJZnL6mCrBzhcRt8bOHtYXYj+aloucy4VzmOtWP2T6/yNGmqr/T/CXggfPujYFbmUdATzrwFfJyuOY9alTDiIPhQrB5htM5Kst83RP+Enp11cgWpkUE35OfVmXgY/HLryMNFaUUO+cw/j0jOCjMPMQ3I6DX7jb5HjEzzl9DoOpdRNfxT3T/ML1DSvoaq+rhdHFaqRO29CvL30nw/DTG/GEZT47eRnqWKVPpziq7yPU+ednwnRHiBsPV+Ocy7HVZPDRQag25pi2mz9fQ+CQEPlnmrOCdhx+0H6C1+QNmEk0eQIe8vqgjCjHnPvwkzPSO17x+hYaTfaGlwBNX2q0jCyJtO+fWPUpxjDNskMemA0dBKrFVTayo2Yj8Kz/NW0zeWv7xfrh X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 09:45:15.8736 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34a31009-748e-4b5b-42ee-08dcd88fc3f8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004682.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4287 X-Rspam-User: X-Stat-Signature: c5oynfsx8cx1cwqsxstcdyjpgx7fksnp X-Rspamd-Queue-Id: 1DA2440006 X-Rspamd-Server: rspam02 X-HE-Tag: 1726739120-178289 X-HE-Meta: U2FsdGVkX1/LtM9vw1ApHB1yRIXuyByPCd0fI3FoZJltfRJd3tuHcobM9vDnArPPGpOI2mrzWAe9DGc5S2BXFbgg5rNNx+GEDZVAuBSP++3V5l7zi4gyXtES8K2qUnYmoKDOwKQ5YGJRzahWnTpYDW0M3aWibKX6eliFkCvcTetfWViQYxtPeS8/3R49gOs7BPosmn6mRSwsqTBnXM/6GQe9TStd+/Yy/DYlmgfRGxqA9RPJ07u+lxiKP0leUo/TAm9RH3tGQxrCBbD4x8PNmFVcgu9qj9RBoKHfJNEbE6rIJXZD9zR4eWiMOACLP0POlVQehmcrHkH+QoGDRQvuDYC1Ftv19bvkO0lRrVhNI3eg/X1bPLF+Vr8+sS+Q8SCB2R1k1NjGPON0cgyrrFw7+ahY1862yowZgi3OPqVdNoCY3L2W5iYSRsVzMn7bUVaUuknjcMt2AeR+fQljwDk6jM7Uc6slBxoRw2bWfiyqajDPTw1HenE7wIYfK/SQB1PnKoI3XNFfvC6wJ0SmWHRX4haxAAzxiBapRjhHdgcrfJGgNM3I2qk1y9xqyClbZFhp456s27mCH42J2byyGoFeS5/kyf6xVsCNM2twWpvR5HS0EWOCoY8KeTz/VeMbSmKhhWjcamsbkuSgFKnBWUK/vNCVWn638eFqT36YOfqxur9KlgnUKPaiuwAmPXghtf4Rr1tPWs5wIv4KurRT9PCuorR/g8vKJCJIv+1imQ5UJ3u5AgfyCqw3F3NZs680RQS7epL4jefepfln3klQmih88kcDXWfFrZno2azF0FXRqNfDuH/BgIq23UeM82pu5gb2WR5aK77FNpMeCrQrsMQ/noYRHnpehh/zv+fpbpd3Hn+RXi3BPnXwRFq3Z1ZMxkIQrK6z6RGpguDVhRViBLM/bJrNscGHoEQ/SRcyB825YhXgolo/j9TUi+4FKgXoyhdpfvV+zoDJC/5DQ7Ltdz1 K0Azh+u4 ekWYKFSX6r8OKTTg7zLxE2xDL+a/vQe5GRVDog+w31UA3rRll2ssJTB7v/kUteQddbKm/lewhT5nV58SlvCpVFk8i0hw4KFNTUkVvpdVq9nmfarT/mA5+9VtP7nlwHjw+Rhp4zEI8DX4v1WDAvI4ro27jW+BVqW7JP37/OPyGOw9NWgLtc9nJ3YM7xPUyl/WdUnZdzZ7TFHJ62oEkV2VGEMu54fRRmRI8T0PckvXIgj49ptnZw2+ks81EtgLHAP/b325aayg4pnnA87LxKyNvMzSxMvf3H5Cb6DIXduIlVaI9L8xdlmjtlSW2aPLqQ9FZnHPgwMRcHJtR6ruAXCBfwSkgEqLiZ0p6dn0muUVNYN80lmwW7FkBCmSQJyZ8atd5hj14739jdc4qMdm6ocmkhgtTigQLFh/Jw59t 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: From: Shivansh Dhiman Introduce mempolicy support to the filemap. Add filemap_grab_folio_mpol, filemap_alloc_folio_mpol_noprof() and __filemap_get_folio_mpol() APIs that take mempolicy struct as an argument. The API is required by VMs using KVM guest-memfd memory backends for NUMA mempolicy aware allocations. Signed-off-by: Shivansh Dhiman Signed-off-by: Shivank Garg --- include/linux/pagemap.h | 40 ++++++++++++++++++++++++++++++++++++++++ mm/filemap.c | 30 +++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index d9c7edb6422b..b05b696f310b 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -564,15 +564,25 @@ static inline void *detach_page_private(struct page *page) #ifdef CONFIG_NUMA struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order); +struct folio *filemap_alloc_folio_mpol_noprof(gfp_t gfp, unsigned int order, + struct mempolicy *mpol); #else static inline struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order) { return folio_alloc_noprof(gfp, order); } +static inline struct folio *filemap_alloc_folio_mpol_noprof(gfp_t gfp, + unsigned int order, + struct mempolicy *mpol) +{ + return filemap_alloc_folio_noprof(gfp, order); +} #endif #define filemap_alloc_folio(...) \ alloc_hooks(filemap_alloc_folio_noprof(__VA_ARGS__)) +#define filemap_alloc_folio_mpol(...) \ + alloc_hooks(filemap_alloc_folio_mpol_noprof(__VA_ARGS__)) static inline struct page *__page_cache_alloc(gfp_t gfp) { @@ -652,6 +662,8 @@ static inline fgf_t fgf_set_order(size_t size) void *filemap_get_entry(struct address_space *mapping, pgoff_t index); struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, fgf_t fgp_flags, gfp_t gfp); +struct folio *__filemap_get_folio_mpol(struct address_space *mapping, + pgoff_t index, fgf_t fgp_flags, gfp_t gfp, struct mempolicy *mpol); struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index, fgf_t fgp_flags, gfp_t gfp); @@ -710,6 +722,34 @@ static inline struct folio *filemap_grab_folio(struct address_space *mapping, mapping_gfp_mask(mapping)); } +/** + * filemap_grab_folio_mpol - grab a folio from the page cache + * @mapping: The address space to search + * @index: The page index + * @mpol: The mempolicy to apply + * + * Same as filemap_grab_folio(), except that it allocates the folio using + * given memory policy. + * + * Return: A found or created folio. ERR_PTR(-ENOMEM) if no folio is found + * and failed to create a folio. + */ +#ifdef CONFIG_NUMA +static inline struct folio *filemap_grab_folio_mpol(struct address_space *mapping, + pgoff_t index, struct mempolicy *mpol) +{ + return __filemap_get_folio_mpol(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + mapping_gfp_mask(mapping), mpol); +} +#else +static inline struct folio *filemap_grab_folio_mpol(struct address_space *mapping, + pgoff_t index, struct mempolicy *mpol) +{ + return filemap_grab_folio(mapping, index); +} +#endif /* CONFIG_NUMA */ + /** * find_get_page - find and get a page reference * @mapping: the address_space to search diff --git a/mm/filemap.c b/mm/filemap.c index d62150418b91..a870a05296c8 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -990,8 +990,13 @@ int filemap_add_folio(struct address_space *mapping, struct folio *folio, EXPORT_SYMBOL_GPL(filemap_add_folio); #ifdef CONFIG_NUMA -struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order) +struct folio *filemap_alloc_folio_mpol_noprof(gfp_t gfp, unsigned int order, + struct mempolicy *mpol) { + if (mpol) + return folio_alloc_mpol_noprof(gfp, order, mpol, + NO_INTERLEAVE_INDEX, numa_node_id()); + int n; struct folio *folio; @@ -1007,6 +1012,12 @@ struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order) } return folio_alloc_noprof(gfp, order); } +EXPORT_SYMBOL(filemap_alloc_folio_mpol_noprof); + +struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order) +{ + return filemap_alloc_folio_mpol_noprof(gfp, order, NULL); +} EXPORT_SYMBOL(filemap_alloc_folio_noprof); #endif @@ -1861,11 +1872,12 @@ void *filemap_get_entry(struct address_space *mapping, pgoff_t index) } /** - * __filemap_get_folio - Find and get a reference to a folio. + * __filemap_get_folio_mpol - Find and get a reference to a folio. * @mapping: The address_space to search. * @index: The page index. * @fgp_flags: %FGP flags modify how the folio is returned. * @gfp: Memory allocation flags to use if %FGP_CREAT is specified. + * @mpol: The mempolicy to apply. * * Looks up the page cache entry at @mapping & @index. * @@ -1876,8 +1888,8 @@ void *filemap_get_entry(struct address_space *mapping, pgoff_t index) * * Return: The found folio or an ERR_PTR() otherwise. */ -struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, - fgf_t fgp_flags, gfp_t gfp) +struct folio *__filemap_get_folio_mpol(struct address_space *mapping, pgoff_t index, + fgf_t fgp_flags, gfp_t gfp, struct mempolicy *mpol) { struct folio *folio; @@ -1947,7 +1959,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, err = -ENOMEM; if (order > 0) alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN; - folio = filemap_alloc_folio(alloc_gfp, order); + folio = filemap_alloc_folio_mpol(alloc_gfp, order, mpol); if (!folio) continue; @@ -1978,6 +1990,14 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, return ERR_PTR(-ENOENT); return folio; } +EXPORT_SYMBOL(__filemap_get_folio_mpol); + +struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, + fgf_t fgp_flags, gfp_t gfp) +{ + return __filemap_get_folio_mpol(mapping, index, + fgp_flags, gfp, NULL); +} EXPORT_SYMBOL(__filemap_get_folio); static inline struct folio *find_get_entry(struct xa_state *xas, pgoff_t max,