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: 159299 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1401384vqb; Sat, 28 Oct 2023 14:17:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmprmQDXJaQyEwyFsK6URyH/YlIF4xAtxaPD5iiiXBFN8cN+CAe3UuU11+NfGY1BpeN9/c X-Received: by 2002:a17:903:32c1:b0:1cc:1e0d:6ff1 with SMTP id i1-20020a17090332c100b001cc1e0d6ff1mr6042138plr.66.1698527855372; Sat, 28 Oct 2023 14:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698527855; cv=none; d=google.com; s=arc-20160816; b=KqAss93jfPexQZUdcOtMOdoxZxUtgdFciZ5HY4EsZ10Xv5FnVWq1JR4TgRDDlME41Y SDEUr9vhw40j2BCFCYMfUKm6IvryNtogP1K78D1WZMgLSzbhQMas5SGkte95OBK+8Ys7 1DxntsBhXBVSnsU3QyxWTSymyUAfdLzvecliHRQ7XEdcyOVj7/R8Z56JsDsaTn+sUnTA b71uXT2qybnqs0oTB+fRoi/RBr+p+45OUz7RbbEkv9Rk/Mm9F1jTwDSMpmbSoP+JEKDr aDBfK2dG96jQz80NdVuogFS//nO9k6UpJzvnkQqYTCXdcikfxxtWfLkPo1wTp6atIPd+ Xxig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=MryWcICdLJnJIpSQ//VC4hAIbMIw5xNwvvS8lnrY/z4=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=SnzoRIppnvoKvf7zsQdKMYPITBcVhd5HHzMY5z3MmwGGgyf7PcnPXL17OxqeECT/aB EMSNI6LWEl8IDLq0RKSdbeEWhYMAsWmOYvyl8L9GAhZ01Q9LzQNMfxVFGtGUt9ZZj+sI B4kob7Z2Nc462KOyHoFWkjxGvIJHHvpzZky8rESTNTSyhqVlUHLTEYAezqzqPWL44KW0 r2q4X3uLIexp7pD/wIWd6iGL9Hdu9vmwLKpqY8PX8znyUxnM4UGCpm6MZ+1tQr+vTsDt 14oUpQumfobFFKP2ovSwKE0+tuGMnGuAjsSThscZovS9wLsq9huUHQscWW7VGVv3jAgR FlBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ePBvv+Wz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m5-20020a170902db0500b001cc2bb98bdasi2019587plx.448.2023.10.28.14.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 14:17:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ePBvv+Wz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 90D7E804E730; Sat, 28 Oct 2023 14:16:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbjJ1VQv (ORCPT + 29 others); Sat, 28 Oct 2023 17:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbjJ1VQ0 (ORCPT ); Sat, 28 Oct 2023 17:16:26 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24460121 for ; Sat, 28 Oct 2023 14:15:54 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211552euoutp022323be4f7624652c18dcb01dcb7f547b~SYf3uGQPs0879208792euoutp02R for ; Sat, 28 Oct 2023 21:15:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231028211552euoutp022323be4f7624652c18dcb01dcb7f547b~SYf3uGQPs0879208792euoutp02R 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+o9DhDx5YwSPXdOsMAVbZ96mB3COcMoMWldGyuEs5JR4uKfLawg G9kENCX2ndwEViUiMJtV4vDiDkaQBLNAncSaZ7NYQGxhATeJL0segsVFBLwlXvftg7L1JJoW 9TOB2CwCqhKzu+awgdi8AjYSM89sB4tzAtn3v20HizMKyEo8WvmLHWK+uMStJ/OZIN4WlFg0 ew8zhC0m8W/XQzYIW0fi7PUnjBC2gcTWpftYIGwliT8dC6Hu1JO4MXUKG4StLbFs4WtmiBsE JU7OfAIOCwmBf5wSd/5OY4VodpHY924Z1CBhiVfHt7BD2DIS/3f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UICuRL9bZkg 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> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 28 Oct 2023 14:16:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781035544674120613 X-GMAIL-MSGID: 1781035544674120613 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;