From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012070.outbound.protection.outlook.com [52.101.43.70]) (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 429281643B for ; Thu, 16 Apr 2026 01:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.70 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776304366; cv=fail; b=CWfjLt64WArUH3l4HnN1YriyMv9/jZeIjPiLzin00lhsEJLqFCv/+l6NX/8nK2y4mbjIk604f6JOWJE6A5FS2DxneUnXYKoiCobHhX/HTI6aDmRM3jk2K7pwRmhyRwiSuoEivJhHeWpyqaiMuKa06MqnRKSZNCuor29GrACjepA= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776304366; c=relaxed/simple; bh=JciJt9TA7GcThB/mHglJVt18Z/ml2kcFEIpdGq2zFbc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Hn9afvpKzPRk7K+3t7F+BYu/0QzhIJmg5HQuXV2E0GPBV9ifkUfKvxIbUd4GsAq2mZuijWwZ8iPmJjMSsJUhs0uPSuXyEpGvz+CSyXFkaCA00oh71JA4UQnSsuuERLH7XffI3RSu682fxGp0bdyh6Wl1miadfocnKnY0r+aCYGA= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=eypuGEjk; arc=fail smtp.client-ip=52.101.43.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="eypuGEjk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EujmMRMt7qIuTGvt0WsnzHLPpjfen0+omi2fywXlsnczf5DoE/kMGho90GkKq+c6ZXbJXdNMFengW2T1PbrlNf6fdrCwEgzK3VtlaxAvscWTjNXi17f3WcVd6mBnNWCRWn5nx0QyVn6awk6nuvFbJJ6RWiol0gDRQXHqWD7RpCfbGrvwO7zPCw52DQgJE3fCjPTUZBkwlrS4/N9lfPfPjhfAX3/Jp1NFqJ5jRSfwEbRN72VjxoRCwgmkFhGY14f1mYAjU0yBrZaYZQqO01lpIPz31I3nqR5P9NGYYwOEblEHgCpc2pdN1jbG6qD7gMSBTnBPpQ53PJgwG9ccr87I8A== 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=vVodotFWQhOeR7Iz77FHIev/mfZcU4iG0XRI2/5ILn0=; b=FnI2MtgdWnZr6XBoYRcA1TfqVFin7z/9U3jmqZmtLInLIpveXD7o6spT5u0nGel5lhuLNg7MQpGBDhvPn3zT6z+0OLI2zL1bYymyyr3p7IoCng3jBnVFiI3VvkFx944kTsOLpcct4R5oIwyp3JfYuEYTrkXEWA6psluSWHdsDvZt4IopHwzvrW2Sl3jDUjHNHFyUXZPYnhXTOJy8twQEvQKH8vrNVFSIocn4eme5sc7SrbKJOOgyurHMukjcv44v9/2Wy1Kcyk/UthQeUTBYtqkJJGjhI0yh5z7/vHZJXt/ClSGrpuCuB7oP2IB2g1W41IS6ZGq+UGYwtx6Uk6RDJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vVodotFWQhOeR7Iz77FHIev/mfZcU4iG0XRI2/5ILn0=; b=eypuGEjkbD5H1VQ5qMoh6af2/4j9te+gr1s+UKmcYg/NAZqdCmGsz6fUiUS+W2tVEdw4rjIY41/tROMJxp0wvmu2HlJxyNEsQ79o7P2fUp+h9iH2RiZYmg56wQxDrH/V5OvWF7CyOKTl8bNj5e5xt1P6Lbhnz5RdhZMlvBppQFl8g/PBN/w2FQD3WQtcS5TqJQSaKlmbcyjPT+Uj3ciQN6AZDS5QtPTWtZxAIPMVzO0azddmtj66CIy/YzmjmEZ294338IKJa/soWhHEL1h0PD5o4UacCvOqonYtnQZnSuN+UFuv2NUvhrjIT3athFHbWHX1uKUbgnWrdhAQ/ojTRg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) by SA6PR12MB999202.namprd12.prod.outlook.com (2603:10b6:806:450::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.21; Thu, 16 Apr 2026 01:52:41 +0000 Received: from DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::f01d:73d2:2dda:c7b2]) by DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::f01d:73d2:2dda:c7b2%4]) with mapi id 15.20.9818.017; Thu, 16 Apr 2026 01:52:41 +0000 From: Zi Yan To: Baolin Wang Cc: "David Hildenbrand (Arm)" , willy@infradead.org, akpm@linux-foundation.org, hughd@google.com, ljs@kernel.org, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: shmem: don't set large-order range for internal shmem mount Date: Wed, 15 Apr 2026 21:52:38 -0400 X-Mailer: MailMate (2.0r6290) Message-ID: In-Reply-To: <907b3a20-52b3-4969-8456-bd3a8d2571f2@linux.alibaba.com> References: <2d138a3f-0006-4a01-852a-4570d7ba781d@linux.alibaba.com> <1a3cb6b2-94e0-4268-8cd9-1f9a9deb6c6b@linux.alibaba.com> <875dc63b-0cd2-49e5-8b0d-3fb062789813@kernel.org> <846B17B0-1BAF-4959-8FC2-42744C44B1D6@nvidia.com> <16745f2b-b008-4df1-ac76-f18b4a826dbd@linux.alibaba.com> <4AD72E13-C4AE-4ADA-8AB2-DDB3CEE6A527@nvidia.com> <907b3a20-52b3-4969-8456-bd3a8d2571f2@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MN2PR01CA0043.prod.exchangelabs.com (2603:10b6:208:23f::12) To DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB9473:EE_|SA6PR12MB999202:EE_ X-MS-Office365-Filtering-Correlation-Id: aeebb3c5-66a3-43c7-196b-08de9b5ad885 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: TFQ/etHo6bIdi9SVNHZxhHbh+cCSkj1t+xzgwQk5Y25YrorMEhaycjJ23ExokYOYjP401K9pDDHckKsM5zF6UovMY5zsT1Cy2f3Brzc1HsT3vHkCncpUIvsSTibVrw7hf5jWuQCE3JHzvAHWkdra9jVHB22QDWqzgC75QrUDz1dNOnoOiowTTyJFEMpMmYxERNCViZzMCgAThtOn3DPROx83KojPzZxGvvG0oVN5Io/46Y04wZrhUEckH6Basvzgbe3piDGGc6ku/MJTJid5QshpVmsLvZC/CVGGQky1HPZPi7WNncFH3vr/QT4Mu+GyBfMl623Hmwa5//UinB/2qJ6F/W9843K4I4oJbm5xR2FDtZqARA2Sxm+Avi6wjxJXoIRHOOBUqXuxt5X0e1O0cRfGnJA2Mbs5Hg59DB7+t1v8g4Wdj7ME7eUyI7uZ8qoobzPEfBvMrwyfallfLq11A/QuUkl9FONOXs9tPVEova4yDXBd5jhV1+eqVNmd6cnKR8eLssbsxRYI9z5WAEb3vK1+hsqv1rR/moRGScgyzsNFNAkI2wFfSU5WYPxoCrkbWoKcBtbkrrmGzurdDX+DFcs9b61eASMB7A2JdaNkrXF99Sbw8sUj9CqXflyeLFtgLkYb8mgkPFCfRnDM5qs4TVeZfVtgWP+p3ARvV50YZ30K4mH0eBI+GzEih1syToD/wpYUQNRUEwKK+cdJQoJA0uzLbvxzrjVievX/taOwM9w= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB9473.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cUhYczhuTE5wdnlwUlJJK0lCYi9vcGhUSnNBYzJlVlcrSm5ZRUF3NzRpMWw4?= =?utf-8?B?czFVZUwwUmVuNk5LTlJUaG5DOTFZSWtJZjRkWHJucWRaS0NiYmROUVZGL2th?= =?utf-8?B?ZDM4VzNzMzM2aUswUWlGSmdqUVBIMWI1MHlkU2FhV1RCWkdsejFnVVh4REJp?= =?utf-8?B?UVZWRDNyaXZsdG54d212UHdaUlJYOUZaeUQvWEVsVENodWU2T20zQ0wyZ1dN?= =?utf-8?B?RllSajRZSStKVVg5WmdWNGp2K0Jyb0gwd0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VhYSjJ5ZDBBckF4V1RaVjZMS1BMT21yQjRjUGNURlFl?= =?utf-8?B?MUowZUZ3a1d5RnM0TU1TVGxJU3JtWWJwWDNBWXdBcW8vbjlWcE1zendkUU9M?= =?utf-8?B?Uk04bjVwVis5a3BORTFNKzNoelBlcUViSjVUY3RmdEVkT0pneVNJRmg3aWRm?= =?utf-8?B?RDZqWkhjKy85M3IrUEhnWGhyb0hRUGxyblEybTUyYVE4enhmNmowTWI2ZjJt?= =?utf-8?B?OVZhVW5LYnlnVW1UNDh5V2hrRGgwNjNBOTV3bHEzNVo1dTBKdVA1UT09?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: aeebb3c5-66a3-43c7-196b-08de9b5ad885 X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB9473.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2026 01:52:41.6999 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /Vhv/Bkq2ZGG+4s/i6hshLpmjVRg+146nTGEzl89cxNHYsVj+C7hXEbszEh81Ivh X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA6PR12MB999202 On 15 Apr 2026, at 21:45, Baolin Wang wrote: > On 4/16/26 9:36 AM, Zi Yan wrote: >> On 15 Apr 2026, at 21:22, Baolin Wang wrote: >> >>> On 4/16/26 9:11 AM, Zi Yan wrote: >>>> On 15 Apr 2026, at 21:05, Baolin Wang wrote: >>>> >>>>> On 4/15/26 10:36 PM, David Hildenbrand (Arm) wrote: >>>>>> On 4/15/26 12:05, Baolin Wang wrote: >>>>>>> >>>>>>> >>>>>>> On 4/15/26 5:54 PM, David Hildenbrand (Arm) wrote: >>>>>>>>> >>>>>>>>> Yes, that makes sense. >>>>>>>>> >>>>>>>>> However, it=E2=80=99s also possible that the mapping does not sup= port large >>>>>>>>> folios, yet anonymous shmem can still allocate large folios via t= he >>>>>>>>> sysfs interfaces. That doesn't make sense, right? >>>>>>>> >>>>>>>> That's what I am saying: if there could be large folios in there, = then >>>>>>>> let's tell the world. >>>>>>>> >>>>>>>> Getting in a scenario where the mapping claims to not support larg= e >>>>>>>> folios, but then we have large folios in there is inconsistent, no= t? >>>>>>>> >>>>>>>> [...] >>>>>>>> >>>>>>>>> >>>>>>>>> For the current anonymous shmem (tmpfs is already clear, no quest= ions), >>>>>>>>> I don=E2=80=99t think there will be any "will never have/does nev= er allow" >>>>>>>>> cases, because it can be changed dynamically via the sysfs interf= aces. >>>>>>>> >>>>>>>> Right. It's about non-anon shmem with huge=3Doff. >>>>>>>> >>>>>>>>> >>>>>>>>> If we still want that logic, then for anonymous shmem we can trea= t it as >>>>>>>>> always "might have large folios". >>>>>>> >>>>>>> OK. To resolve the confusion about 1, the logic should be changed a= s >>>>>>> follows. Does that make sense to you? >>>>>>> >>>>>>> if (sbinfo->huge || (sb->s_flags & SB_KERNMOUNT)) >>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0mapping_set_large_folios(inode->i_mappin= g); >>>>>> >>>>>> I think that's better. >>>>> >>>>> Thanks for your valuable input. >>>>> >>>>> But has Willy says, maybe we can just >>>>>> unconditionally set it and have it even simpler. >>>>> >>>>> However, for tmpfs mounts, we should still respect the 'huge=3D' moun= t option. See commit 5a90c155defa ("tmpfs: don't enable large folios if not= supported"). >>>> >>>> Is it possible to get sbinfo->huge during tmpfs=E2=80=99s folio alloca= tion time, so that >>>> even if all tmpfs has mapping_set_large_folios() but sbinfo->huge can = still >>>> decide whether huge page will be allocated for a tmpfs? >>> >>> Yes, of course. However, the issue isn=E2=80=99t whether tmpfs allows a= llocating large folios. >>> >>> The problem commit 5a90c155defa tries to fix is that when tmpfs is moun= ted with the 'huge=3Dnever' option, we will not allocate large folios for i= t. Then when writing tmpfs files, generic_perform_write() will call mapping= _max_folio_size() to get the chunk size and ends up with an order-9 size fo= r writing tmpfs files. However, this tmpfs file is populated only with smal= l folios, resulting in a performance regression. >> >> IIUC, generic_perform_write() needs to use a small chunk if tmpfs denies= huge. >> It seems that Kefeng did that in the first try[1]. But willy suggested >> the current fix. >> >> I wonder if we should revisit Kefeng=E2=80=99s first version. >> >> [1] https://lore.kernel.org/all/20240914140613.2334139-1-wangkefeng.wang= @huawei.com/ > > Personally, I still prefer the current fix (commit 5a90c155defa). We shou= ld honor the tmpfs mount option. If it explicitly says no large folios, we = shouldn=E2=80=99t call mapping_set_large_folios(). Isn=E2=80=99t that more = consistent with its semantics? Filesystems wishing to turn on large folios in the pagecache should call ``mapping_set_large_folios`` when initializing the incore inode. You mean tmpfs with huge option set is a FS wishing to turn on large folios in the pagecache, otherwise it is a FS wishing not to have large fol= io in the pagecache. tmpfs with different options is seen as different FSes. Best Regards, Yan, Zi