From patchwork Sat Oct 28 21:15:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13439603 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1DC8C4167D for ; Sat, 28 Oct 2023 21:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbjJ1VQa (ORCPT ); Sat, 28 Oct 2023 17:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbjJ1VQ0 (ORCPT ); Sat, 28 Oct 2023 17:16:26 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A10F2183 for ; Sat, 28 Oct 2023 14:15:54 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211552euoutp012c604691b5d9524a2a5b55028376695f~SYf3uLjdo2663226632euoutp01I for ; Sat, 28 Oct 2023 21:15:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231028211552euoutp012c604691b5d9524a2a5b55028376695f~SYf3uLjdo2663226632euoutp01I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527752; bh=MryWcICdLJnJIpSQ//VC4hAIbMIw5xNwvvS8lnrY/z4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ePBvv+WznISzR3zoq3qsBn2CBSEJB2wrKIglDYakrXINkRy/NEALAyS/D37Ds0sMW CBZwq1VbMuGTaOih6ybrOyNMlVtrlV0vm2iC1UWGc9UPbkUW/xZJlH7xcOZokOfpAz CCUnB7AMfrF+6pejFOr/f+mUZSEJSVinapl2Zh0g= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211551eucas1p2e50b635ba8eae30317009299b0be2ea3~SYf2kdVsc1224812248eucas1p2E; Sat, 28 Oct 2023 21:15:51 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BE.57.37758.70A7D356; Sat, 28 Oct 2023 22:15:51 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211550eucas1p1dc1d47e413de350deda962c3df5111ef~SYf2GDan11181011810eucas1p1I; Sat, 28 Oct 2023 21:15:50 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211550eusmtrp2373a802e94a6ccdb4bd44f64388a442f~SYf2FekMo1141411414eusmtrp2g; Sat, 28 Oct 2023 21:15:50 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-0b-653d7a071720 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A0.01.25043.60A7D356; Sat, 28 Oct 2023 22:15:50 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231028211550eusmtip29b55570e519e6390a3d01dce2b0ec14a~SYf120roh1182011820eusmtip2p; Sat, 28 Oct 2023 21:15:50 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 28 Oct 2023 22:15:50 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 28 Oct 2023 22:15:50 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [RFC PATCH 09/11] shmem: add order arg to shmem_alloc_folio() Thread-Topic: [RFC PATCH 09/11] shmem: add order arg to shmem_alloc_folio() Thread-Index: AQHaCePsz4j06UKTKkuVsaJRZMX8Ng== Date: Sat, 28 Oct 2023 21:15:49 +0000 Message-ID: <20231028211518.3424020-10-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.103] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFKsWRmVeSWpSXmKPExsWy7djPc7rsVbapBj/nSVjMWb+GzWL13X42 i8tP+Cyefupjsdh7S9tiz96TLBaXd81hs7i35j+rxa4/O9gtbkx4ymix7Ot7dovdGxexWfz+ MYfNgddjdsNFFo8Fm0o9Nq/Q8rh8ttRj06pONo9Nnyaxe5yY8ZvF4/MmuQCOKC6blNSczLLU In27BK6MJdcqC05IVLxtusnYwNgh0sXIySEhYCIx8/ADli5GLg4hgRWMEq9PP4VyvjBKLN61 iQ3C+cwo0fL1PGsXIwdYy+o9DhDx5YwSPXdOsMAVbZ96mB3COcMoMWldGyuEs5JR4u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ulaEMLIz1DSws9IxNLPUNj81grI1MlfTublNSczLLUIn27BL2MJdcqC05IVLxtusnY wNgh0sXIwSEhYCKxeo9DFyMXh5DAUkaJg1uPMXYxcgLFZSQ2frnKCmELS/y51sUGUfSRUeL8 lGZWCOcMo8SUiS2MEM5KRomuHTNYQFrYBDQl9p3cxA6SEBGYzSpxeHEH2FxmgTqJNc9mgRUJ C7hJfFnyECwuIuAt8bpvH5StJ9G0qJ8JxGYRUJWY3TWHDcTmFbCRmHlmOxPI3UICuRL9bZkg YU6g8P1v28FKGAVkJR6t/MUOsUpc4taT+UwQLwhILNlznhnCFpV4+fgf1Gs6EmevP4F62UBi 69J9LBC2ksSfjoVQJ+tJ3Jg6hQ3C1pZYtvA1M8Q5ghInZz5hmcAoPQvJullIWmYhaZmFpGUB I8sqRpHU0uLc9NxiI73ixNzi0rx0veT83E2MwOS07djPLTsYV776qHeIkYmD8RCjBAezkggv s6NNqhBvSmJlVWpRfnxRaU5q8SFGU2AQTWSWEk3OB6bHvJJ4QzMDU0MTM0sDU0szYyVxXs+C jkQhgfTEktTs1NSC1CKYPiYOTqkGJsW1tlf4mY0/XmfZqfDJbrVO5TLJIKtu0z9rHdurnV4k fbq48pFsd4ioXs9PQdnuHAVpTk+v66+NFF6Ev6p6pCbl5C6cFjDhzNpQ4UNiCnZR7Vte7W99 u+ksN3PQiUvL+1mtO+Sbf6+NdPM01rIpuJnhwjJ/1/dd5wUzttRZGebt2naJRf9h0yP2q7/z zqoaFWq9v2pgsJpjd6Ym83e//rS6uwHm6+SPB855Upmfnum7PGERq/6yRxeaY09N9Lr+c0dU cL8WA8/crQfv3/u1jMnRapOW6PtIncf6O2u5GLZLOXpeO14crbpwV1rUrMlqjBXbGJpXxjmX 8xhfWDfzoWvY5CNaKUeDnaT8lR2VWIozEg21mIuKEwHPwMUl1wMAAA== X-CMS-MailID: 20231028211550eucas1p1dc1d47e413de350deda962c3df5111ef X-Msg-Generator: CA X-RootMTR: 20231028211550eucas1p1dc1d47e413de350deda962c3df5111ef X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211550eucas1p1dc1d47e413de350deda962c3df5111ef References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add folio order argument to the shmem_alloc_folio() and merge it with the shmem_alloc_folio_huge(). Return will make use of the new page_rmappable_folio() where order-0 and high order folios are both supported. Signed-off-by: Daniel Gomez --- mm/shmem.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index d8dc2ceaba18..fc7605da4316 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1614,40 +1614,27 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp) return result; } -static struct folio *shmem_alloc_hugefolio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) +static struct folio *shmem_alloc_folio(gfp_t gfp, struct shmem_inode_info *info, + pgoff_t index, unsigned int order) { struct mempolicy *mpol; pgoff_t ilx; struct page *page; - mpol = shmem_get_pgoff_policy(info, index, HPAGE_PMD_ORDER, &ilx); - page = alloc_pages_mpol(gfp, HPAGE_PMD_ORDER, mpol, ilx, numa_node_id()); + mpol = shmem_get_pgoff_policy(info, index, order, &ilx); + page = alloc_pages_mpol(gfp, order, mpol, ilx, numa_node_id()); mpol_cond_put(mpol); return page_rmappable_folio(page); } -static struct folio *shmem_alloc_folio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) -{ - struct mempolicy *mpol; - pgoff_t ilx; - struct page *page; - - mpol = shmem_get_pgoff_policy(info, index, 0, &ilx); - page = alloc_pages_mpol(gfp, 0, mpol, ilx, numa_node_id()); - mpol_cond_put(mpol); - - return (struct folio *)page; -} - static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, struct inode *inode, pgoff_t index, struct mm_struct *fault_mm, size_t len) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); + unsigned int order = 0; struct folio *folio; long pages; int error; @@ -1668,12 +1655,12 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, index + HPAGE_PMD_NR - 1, XA_PRESENT)) return ERR_PTR(-E2BIG); - folio = shmem_alloc_hugefolio(gfp, info, index); + folio = shmem_alloc_folio(gfp, info, index, HPAGE_PMD_ORDER); if (!folio) count_vm_event(THP_FILE_FALLBACK); } else { - pages = 1; - folio = shmem_alloc_folio(gfp, info, index); + pages = 1UL << order; + folio = shmem_alloc_folio(gfp, info, index, order); } if (!folio) return ERR_PTR(-ENOMEM); @@ -1774,7 +1761,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, */ gfp &= ~GFP_CONSTRAINT_MASK; VM_BUG_ON_FOLIO(folio_test_large(old), old); - new = shmem_alloc_folio(gfp, info, index); + new = shmem_alloc_folio(gfp, info, index, 0); if (!new) return -ENOMEM; @@ -2618,7 +2605,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, if (!*foliop) { ret = -ENOMEM; - folio = shmem_alloc_folio(gfp, info, pgoff); + folio = shmem_alloc_folio(gfp, info, pgoff, 0); if (!folio) goto out_unacct_blocks;