Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3019252lqo; Tue, 21 May 2024 04:42:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHqWhU1kYTZ6z0QNH/OzlcankieUSHimA93/Na8b7WVY3lEl7WrGZCkGQzEg/9x4XA8PzIEnJQ4prH3LJxNDOw/AatMmwnmbdrnNtNbQ== X-Google-Smtp-Source: AGHT+IHNORFPqp4NbWQNQnn1IDj7Dpiktt8BPsWM7J/YyegOLk9w2EjMpM4zxcb1U0Il1rJpf4ld X-Received: by 2002:a05:6a20:5607:b0:1af:d206:e572 with SMTP id adf61e73a8af0-1afde0a9cb3mr30975015637.9.1716291721055; Tue, 21 May 2024 04:42:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716291721; cv=pass; d=google.com; s=arc-20160816; b=gvElkewLu7aGrQFjegm/95Qb0CTnRWcKGNfV/VN4i/ecdzUvUJTM6XbrCUslzQ9QEB v+M6+Lu8qOzmgB4VV+CzQAvb4wqIM6oSc7lOpf5pR8RVO4PkIimgfjUldsRaFx0E9Ly5 ud3n4cqS7JYos8JdaGt92d2uMGXbVMzIikYbbyg4NY9Wv7XC3PJM91CgCTnTCZhCizX6 TpOB0P08Y/lVcivCCa5cVLpi/qSb7EIgUV7BzUFJyUmHbHkw3C6Vv8hmiwKwUvkgzm7e NbjOgr4aWlQWo2p+APvgYT2Oek5W6BZ6X+WJTDFji7t4AM0a7oopzk8sNSly2GaDi/ng 6fUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-id :content-language:accept-language:in-reply-to:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-filter; bh=/yWTkcNkIb+Uasg8OKBsKRx4DqCw/pjgipTunEEbc20=; fh=PAMjqmX7SV/MUaPn9VoiIw2uhL5TmHfFwnYVTigUlsc=; b=WyflQv8m2leDo1IrFhkpfAMEFzBCTG7forZxnaZ7ByRK5LNcwhJ2eXzAJ2wsdu8CER kBRnHSJAgYjhRPXZg8fJgwdJLLJH2++zOI5GoxTKv/oY4hTpMSIWATyZYRWCQNcdZPff IWs1iQPwr47+ogcpaXbRaYt/szbrVzH3saMZ3kZ6Yb0Uxfrm8I1KHIqAt0r03rhin7Ng TQKEtdRM2eHztgaO68yvdrVQjKP5veqv30o7IFlStynSiyiCJXwMVmIOxTR+JnX3dmtH PNVXZg7UIpBmdFuz8UTf6I3n9OA1HKnCLMSyVb8eEsACdrubjhQDBqpQY3vNiZucRfVw YQJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=AUrpF+zG; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-184886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-63409e824f3si324161a12.111.2024.05.21.04.42.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 04:42:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=AUrpF+zG; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-184886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 380BAB2354E for ; Tue, 21 May 2024 11:38:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9DD3757ED; Tue, 21 May 2024 11:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="AUrpF+zG" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A81EF6CDA9 for ; Tue, 21 May 2024 11:38:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716291523; cv=none; b=GA9C+qUmbdTJ5cQOfw2VRG4SusXCEWzB8LToviKWP3RbTPHMnLzqDo6ZZBHiMfotjwBBb20LwsXOtdw0u+SNHkOe3jUkKwBB1N39Dv+IAVzD60mA+bjPSNLiUqqO2iqosS/VtybkVLartdYqoqhUmWUIPeMcyW9FuCg/R7Dut8A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716291523; c=relaxed/simple; bh=i7RUFQ0OvW6yBTZbgzgjzKGToEQQuJmlSUjkVrhfnds=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=kOjAw3Q8M3u7NyCi0Cpz3pVILjJuBfGyAVLoBHB7ldEbPM4ehFrMR975CHuRV56fDfkegVFV52iKbENnlDVIe143lco9nOcjU4k661KG609qfSlXR9VmG3BnaxgxKal+EiZ/PLlsxlZNQeOVGLRXQLgsNt7atgyhH2Swdl9d7ic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=AUrpF+zG; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240521113836euoutp015e8d5f5456fa2825a4f4c85f334ecd53~RfgqISURA2612526125euoutp01k for ; Tue, 21 May 2024 11:38:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240521113836euoutp015e8d5f5456fa2825a4f4c85f334ecd53~RfgqISURA2612526125euoutp01k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1716291516; bh=/yWTkcNkIb+Uasg8OKBsKRx4DqCw/pjgipTunEEbc20=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=AUrpF+zGo5MCPoD+2+J3cdvWlkKWLRwomGUUsT46bC7auCe3i1r5PCSLmSofjwo81 kLP7amK8or+N26QvmVUYwcoB/g1FRBKLAMCFHqVAcmTugJtATY22yxBplZhZLbyrBy paNnWJqReEPTiTMQDj8kPbbqAr5fSnw9/JqVDJhk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20240521113836eucas1p198e54d163364d8beda1ff21a127bef87~RfgpttPTc1267012670eucas1p1Q; Tue, 21 May 2024 11:38:36 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id F3.4F.09620.CB78C466; Tue, 21 May 2024 12:38:36 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240521113835eucas1p101f04327871b69cf06ff40a59366a656~RfgpRSoLI1132011320eucas1p1G; Tue, 21 May 2024 11:38:35 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240521113835eusmtrp2faf7a8adf691d03e2126412adf1cd10f~RfgpQMvBL2864328643eusmtrp2Q; Tue, 21 May 2024 11:38:35 +0000 (GMT) X-AuditID: cbfec7f5-d1bff70000002594-96-664c87bc39c7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 32.BE.08810.BB78C466; Tue, 21 May 2024 12:38:35 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240521113835eusmtip1ffd007125d034350263b223a37ba8cc5~RfgpA_OZK1617516175eusmtip1h; Tue, 21 May 2024 11:38:35 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 21 May 2024 12:38:34 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Tue, 21 May 2024 12:38:34 +0100 From: Daniel Gomez To: "Darrick J. Wong" CC: "hughd@google.com" , "akpm@linux-foundation.org" , "willy@infradead.org" , "jack@suse.cz" , "mcgrof@kernel.org" , "linux-mm@kvack.org" , "linux-xfs@vger.kernel.org" , Pankaj Raghav , "dagmcr@gmail.com" , "yosryahmed@google.com" , "baolin.wang@linux.alibaba.com" , "ritesh.list@gmail.com" , "lsf-pc@lists.linux-foundation.org" , "david@redhat.com" , "chandan.babu@oracle.com" , "linux-kernel@vger.kernel.org" , "brauner@kernel.org" Subject: Re: [PATCH 11/12] shmem: add file length arg in shmem_get_folio() path Thread-Topic: [PATCH 11/12] shmem: add file length arg in shmem_get_folio() path Thread-Index: AQHapozJF6Lbb0RRX0KKO162vQDDlLGbjZ6AgAX7VQA= Date: Tue, 21 May 2024 11:38:33 +0000 Message-ID: <65qj4iqgdzebrg5cqwaocjzswenzzgoifdnewrhoipieqi3d5v@bxxupemsgsbs> In-Reply-To: <20240517161741.GY360919@frogsfrogsfrogs> 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 Content-Type: text/plain; charset="us-ascii" Content-ID: <51A92AAB4390BC48AEED40182889A759@scsc.local> Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNKsWRmVeSWpSXmKPExsWy7djPc7p72n3SDBpWsFvMWb+GzeL/3mOM Fq8Pf2K0uHRUzuJs3282i6/rfzFbXH7CZ/H0Ux+LxezpzUwWl3fNYbO4t+Y/q8WuPzvYLfa9 3stscWPCU0aLg6c62C1+/wDKbt8V6SDosXPWXXaPBZtKPTav0PLYtKqTzWPTp0nsHidm/Gbx 2PnQ0mPyjeWMHh+f3mLxeL/vKpvHmQVH2D0+b5IL4InisklJzcksSy3St0vgynj1oomtYEVq xe93y5gbGKf6dDFyckgImEhsPX2WpYuRi0NIYAWjxKnvpxkhnC+MEiv7lzKBVAkJfGaUONei 1cXIAdbR0hkBUbOcUeLRzi+scDU7F/pC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21mIuKEwF/4OiiFgQAAA== X-CMS-MailID: 20240521113835eucas1p101f04327871b69cf06ff40a59366a656 X-Msg-Generator: CA X-RootMTR: 20240515055738eucas1p15335a32c790b731aa5857193bbddf92d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240515055738eucas1p15335a32c790b731aa5857193bbddf92d References: <20240515055719.32577-1-da.gomez@samsung.com> <20240515055719.32577-12-da.gomez@samsung.com> <20240517161741.GY360919@frogsfrogsfrogs> On Fri, May 17, 2024 at 09:17:41AM -0700, Darrick J. Wong wrote: > On Wed, May 15, 2024 at 05:57:36AM +0000, Daniel Gomez wrote: > > In preparation for large folio in the write and fallocate paths, add > > file length argument in shmem_get_folio() path to be able to calculate > > the folio order based on the file size. Use of order-0 (PAGE_SIZE) for > > read, page cache read, and vm fault. > >=20 > > This enables high order folios in the write and fallocate path once the > > folio order is calculated based on the length. > >=20 > > Signed-off-by: Daniel Gomez > > --- > > fs/xfs/scrub/xfile.c | 6 +++--- > > fs/xfs/xfs_buf_mem.c | 3 ++- > > include/linux/shmem_fs.h | 2 +- > > mm/khugepaged.c | 3 ++- > > mm/shmem.c | 35 ++++++++++++++++++++--------------- > > mm/userfaultfd.c | 2 +- > > 6 files changed, 29 insertions(+), 22 deletions(-) > >=20 > > diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c > > index 8cdd863db585..4905f5e4cb5d 100644 > > --- a/fs/xfs/scrub/xfile.c > > +++ b/fs/xfs/scrub/xfile.c > > @@ -127,7 +127,7 @@ xfile_load( > > unsigned int offset; > > =20 > > if (shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, > > - SGP_READ) < 0) > > + SGP_READ, PAGE_SIZE) < 0) >=20 > I suppose I /did/ say during LSFMM that for the current users of xfile.c > and xfs_buf_mem.c the order of the folio being returned doesn't really I not sure if I understood you well. Could you please elaborate on this? > matter, but why wouldn't the last argument here be "roundup_64(count, > PAGE_SIZE)" ? Shouldn't we at least hint to the page cache about the > folio order that we actually want instead of limiting it to order-0? For v2, I'll include your suggestions. I think we can also enable large fol= ios in xfile_get_folio(), please check below: diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 8cdd863db585..df8b495b4939 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -127,7 +127,7 @@ xfile_load( unsigned int offset; if (shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, - SGP_READ) < 0) + SGP_READ, roundup_64(count, PAGE_SIZE)) < 0= ) break; if (!folio) { /* @@ -197,7 +197,7 @@ xfile_store( unsigned int offset; if (shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, - SGP_CACHE) < 0) + SGP_CACHE, roundup_64(count, PAGE_SIZE)) < = 0) break; if (filemap_check_wb_err(inode->i_mapping, 0)) { folio_unlock(folio); @@ -268,7 +268,8 @@ xfile_get_folio( pflags =3D memalloc_nofs_save(); error =3D shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, - (flags & XFILE_ALLOC) ? SGP_CACHE : SGP_READ); + (flags & XFILE_ALLOC) ? SGP_CACHE : SGP_READ, + roundup_64(i_size_read(inode), PAGE_SIZE)); memalloc_nofs_restore(pflags); if (error) return ERR_PTR(error); >=20 > (Also it seems a little odd to me that the @index is in units of pgoff_t > but @len is in bytes.) I extended the shmem_get_folio() with @len to calculate folio order based o= n size (bytes). This is sent to ilog2() although I'm planning to use get_orde= r() instead (after fixing the issues mentioned during the discussion). @index i= s used for __ffs() (same as in filemap). Would you use lofft for @len instead? Or what's your suggestion? Thanks, Daniel >=20 > > break; > > if (!folio) { > > /* > > @@ -197,7 +197,7 @@ xfile_store( > > unsigned int offset; > > =20 > > if (shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, > > - SGP_CACHE) < 0) > > + SGP_CACHE, PAGE_SIZE) < 0) > > break; > > if (filemap_check_wb_err(inode->i_mapping, 0)) { > > folio_unlock(folio); > > @@ -268,7 +268,7 @@ xfile_get_folio( > > =20 > > pflags =3D memalloc_nofs_save(); > > error =3D shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, > > - (flags & XFILE_ALLOC) ? SGP_CACHE : SGP_READ); > > + (flags & XFILE_ALLOC) ? SGP_CACHE : SGP_READ, PAGE_SIZE); > > memalloc_nofs_restore(pflags); > > if (error) > > return ERR_PTR(error); > > diff --git a/fs/xfs/xfs_buf_mem.c b/fs/xfs/xfs_buf_mem.c > > index 9bb2d24de709..784c81d35a1f 100644 > > --- a/fs/xfs/xfs_buf_mem.c > > +++ b/fs/xfs/xfs_buf_mem.c > > @@ -149,7 +149,8 @@ xmbuf_map_page( > > return -ENOMEM; > > } > > =20 > > - error =3D shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, SGP_CACHE= ); > > + error =3D shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, SGP_CACHE= , > > + PAGE_SIZE); >=20 > This is ok unless someone wants to use a different XMBUF_BLOCKSIZE. >=20 > --D >=20 > > if (error) > > return error; > > =20 > > diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h > > index 3fb18f7eb73e..bc59b4a00228 100644 > > --- a/include/linux/shmem_fs.h > > +++ b/include/linux/shmem_fs.h > > @@ -142,7 +142,7 @@ enum sgp_type { > > }; > > =20 > > int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio *= *foliop, > > - enum sgp_type sgp); > > + enum sgp_type sgp, size_t len); > > struct folio *shmem_read_folio_gfp(struct address_space *mapping, > > pgoff_t index, gfp_t gfp); > > =20 > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > index 38830174608f..947770ded68c 100644 > > --- a/mm/khugepaged.c > > +++ b/mm/khugepaged.c > > @@ -1863,7 +1863,8 @@ static int collapse_file(struct mm_struct *mm, un= signed long addr, > > xas_unlock_irq(&xas); > > /* swap in or instantiate fallocated page */ > > if (shmem_get_folio(mapping->host, index, > > - &folio, SGP_NOALLOC)) { > > + &folio, SGP_NOALLOC, > > + PAGE_SIZE)) { > > result =3D SCAN_FAIL; > > goto xa_unlocked; > > } > > diff --git a/mm/shmem.c b/mm/shmem.c > > index d531018ffece..fcd2c9befe19 100644 > > --- a/mm/shmem.c > > +++ b/mm/shmem.c > > @@ -1134,7 +1134,7 @@ static struct folio *shmem_get_partial_folio(stru= ct inode *inode, pgoff_t index) > > * (although in some cases this is just a waste of time). > > */ > > folio =3D NULL; > > - shmem_get_folio(inode, index, &folio, SGP_READ); > > + shmem_get_folio(inode, index, &folio, SGP_READ, PAGE_SIZE); > > return folio; > > } > > =20 > > @@ -1844,7 +1844,7 @@ static struct folio *shmem_alloc_folio(gfp_t gfp,= struct shmem_inode_info *info, > > =20 > > static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, > > struct inode *inode, pgoff_t index, > > - struct mm_struct *fault_mm, bool huge) > > + struct mm_struct *fault_mm, bool huge, size_t len) > > { > > struct address_space *mapping =3D inode->i_mapping; > > struct shmem_inode_info *info =3D SHMEM_I(inode); > > @@ -2173,7 +2173,7 @@ static int shmem_swapin_folio(struct inode *inode= , pgoff_t index, > > */ > > static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, > > struct folio **foliop, enum sgp_type sgp, gfp_t gfp, > > - struct vm_fault *vmf, vm_fault_t *fault_type) > > + struct vm_fault *vmf, vm_fault_t *fault_type, size_t len) > > { > > struct vm_area_struct *vma =3D vmf ? vmf->vma : NULL; > > struct mm_struct *fault_mm; > > @@ -2258,7 +2258,7 @@ static int shmem_get_folio_gfp(struct inode *inod= e, pgoff_t index, > > huge_gfp =3D vma_thp_gfp_mask(vma); > > huge_gfp =3D limit_gfp_mask(huge_gfp, gfp); > > folio =3D shmem_alloc_and_add_folio(huge_gfp, > > - inode, index, fault_mm, true); > > + inode, index, fault_mm, true, len); > > if (!IS_ERR(folio)) { > > count_vm_event(THP_FILE_ALLOC); > > goto alloced; > > @@ -2267,7 +2267,8 @@ static int shmem_get_folio_gfp(struct inode *inod= e, pgoff_t index, > > goto repeat; > > } > > =20 > > - folio =3D shmem_alloc_and_add_folio(gfp, inode, index, fault_mm, fals= e); > > + folio =3D shmem_alloc_and_add_folio(gfp, inode, index, fault_mm, fals= e, > > + len); > > if (IS_ERR(folio)) { > > error =3D PTR_ERR(folio); > > if (error =3D=3D -EEXIST) > > @@ -2377,10 +2378,10 @@ static int shmem_get_folio_gfp(struct inode *in= ode, pgoff_t index, > > * Return: 0 if successful, else a negative error code. > > */ > > int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio *= *foliop, > > - enum sgp_type sgp) > > + enum sgp_type sgp, size_t len) > > { > > return shmem_get_folio_gfp(inode, index, foliop, sgp, > > - mapping_gfp_mask(inode->i_mapping), NULL, NULL); > > + mapping_gfp_mask(inode->i_mapping), NULL, NULL, len); > > } > > EXPORT_SYMBOL_GPL(shmem_get_folio); > > =20 > > @@ -2475,7 +2476,7 @@ static vm_fault_t shmem_fault(struct vm_fault *vm= f) > > =20 > > WARN_ON_ONCE(vmf->page !=3D NULL); > > err =3D shmem_get_folio_gfp(inode, vmf->pgoff, &folio, SGP_CACHE, > > - gfp, vmf, &ret); > > + gfp, vmf, &ret, PAGE_SIZE); > > if (err) > > return vmf_error(err); > > if (folio) { > > @@ -2954,6 +2955,9 @@ shmem_write_begin(struct file *file, struct addre= ss_space *mapping, > > struct folio *folio; > > int ret =3D 0; > > =20 > > + if (!mapping_large_folio_support(mapping)) > > + len =3D min_t(size_t, len, PAGE_SIZE - offset_in_page(pos)); > > + > > /* i_rwsem is held by caller */ > > if (unlikely(info->seals & (F_SEAL_GROW | > > F_SEAL_WRITE | F_SEAL_FUTURE_WRITE))) { > > @@ -2963,7 +2967,7 @@ shmem_write_begin(struct file *file, struct addre= ss_space *mapping, > > return -EPERM; > > } > > =20 > > - ret =3D shmem_get_folio(inode, index, &folio, SGP_WRITE); > > + ret =3D shmem_get_folio(inode, index, &folio, SGP_WRITE, len); > > if (ret) > > return ret; > > =20 > > @@ -3083,7 +3087,7 @@ static ssize_t shmem_file_read_iter(struct kiocb = *iocb, struct iov_iter *to) > > break; > > } > > =20 > > - error =3D shmem_get_folio(inode, index, &folio, SGP_READ); > > + error =3D shmem_get_folio(inode, index, &folio, SGP_READ, PAGE_SIZE)= ; > > if (error) { > > if (error =3D=3D -EINVAL) > > error =3D 0; > > @@ -3260,7 +3264,7 @@ static ssize_t shmem_file_splice_read(struct file= *in, loff_t *ppos, > > break; > > =20 > > error =3D shmem_get_folio(inode, *ppos / PAGE_SIZE, &folio, > > - SGP_READ); > > + SGP_READ, PAGE_SIZE); > > if (error) { > > if (error =3D=3D -EINVAL) > > error =3D 0; > > @@ -3469,7 +3473,8 @@ static long shmem_fallocate(struct file *file, in= t mode, loff_t offset, > > error =3D -ENOMEM; > > else > > error =3D shmem_get_folio(inode, index, &folio, > > - SGP_FALLOC); > > + SGP_FALLOC, > > + (end - index) << PAGE_SHIFT); > > if (error) { > > info->fallocend =3D undo_fallocend; > > /* Remove the !uptodate folios we added */ > > @@ -3822,7 +3827,7 @@ static int shmem_symlink(struct mnt_idmap *idmap,= struct inode *dir, > > } else { > > inode_nohighmem(inode); > > inode->i_mapping->a_ops =3D &shmem_aops; > > - error =3D shmem_get_folio(inode, 0, &folio, SGP_WRITE); > > + error =3D shmem_get_folio(inode, 0, &folio, SGP_WRITE, PAGE_SIZE); > > if (error) > > goto out_remove_offset; > > inode->i_op =3D &shmem_symlink_inode_operations; > > @@ -3868,7 +3873,7 @@ static const char *shmem_get_link(struct dentry *= dentry, struct inode *inode, > > return ERR_PTR(-ECHILD); > > } > > } else { > > - error =3D shmem_get_folio(inode, 0, &folio, SGP_READ); > > + error =3D shmem_get_folio(inode, 0, &folio, SGP_READ, PAGE_SIZE); > > if (error) > > return ERR_PTR(error); > > if (!folio) > > @@ -5255,7 +5260,7 @@ struct folio *shmem_read_folio_gfp(struct address= _space *mapping, > > int error; > > =20 > > error =3D shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, > > - gfp, NULL, NULL); > > + gfp, NULL, NULL, PAGE_SIZE); > > if (error) > > return ERR_PTR(error); > > =20 > > diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c > > index 3c3539c573e7..540a0c2d4325 100644 > > --- a/mm/userfaultfd.c > > +++ b/mm/userfaultfd.c > > @@ -359,7 +359,7 @@ static int mfill_atomic_pte_continue(pmd_t *dst_pmd= , > > struct page *page; > > int ret; > > =20 > > - ret =3D shmem_get_folio(inode, pgoff, &folio, SGP_NOALLOC); > > + ret =3D shmem_get_folio(inode, pgoff, &folio, SGP_NOALLOC, PAGE_SIZE)= ; > > /* Our caller expects us to return -EFAULT if we failed to find folio= */ > > if (ret =3D=3D -ENOENT) > > ret =3D -EFAULT; > > --=20 > > 2.43.0 > > =