From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 685A630ACF1 for ; Thu, 23 Apr 2026 02:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776912405; cv=none; b=FSFVV6Fhzxms1F43Fz+RB8m3UPf/EBLQf27lorPUKboNf3oKxlWunE/4vhhxWCHoRUJ4ANte6uK5vBgRaH4f0HBjYCayz0Q8dZDPJ3f8jCXwgoq90Bu9ITnwSdhtH/MAmz45GE9rgFJfHJ/rJclR9qKz4jHAPl+C09Rksxl1l9o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776912405; c=relaxed/simple; bh=XQtByWKLoHt3JDIkw9A/fL3z8uARx39tMV/++YMzt8k=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Md+X9W/ml/ub6vGYe6ae+Y+PbRIIXhopxaMMbkDaugKHHC7bKLL63pbeos4nJVnchYw62NgYKVeF/T5UWHKrdhRyyu/Hou/8hE5VQHiDxAvlgZIRk/MDcS6chF/u1VHBPHjbyyHs8XfWVbIIZrbzrK8zOU47tgzP3ry5TCkDJUw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=N72OwZto; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="N72OwZto" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=j6TEcC/k0cIqgg7/ppJTuoefMF2zsA6Agg3eQu3BxA4=; b=N72OwZtoYJCxx4bo3pf3Z76vVDpwD7yXKDzexbYoF0aoIMIcsEXSFktGE2GkOl2GmgT7vXbpj ywEE1volGKkfIwGSpPdHIhDRazKKYe/cadzhXGTVEaPJsGN327QEHqDSskXhDIkn60690uI6X+D 4uCzvhSjqZOrfULQtXdzdlY= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4g1L0t4dDhzKm9l; Thu, 23 Apr 2026 10:40:14 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 90F5A40561; Thu, 23 Apr 2026 10:46:39 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 23 Apr 2026 10:46:38 +0800 Message-ID: <5c915191-b477-40af-8d56-ba9f2c24c5ec@huawei.com> Date: Thu, 23 Apr 2026 10:46:37 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Revert "tmpfs: don't enable large folios if not supported" To: Baolin Wang , , CC: , , , , , , References: Content-Language: en-US From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To dggpemf100008.china.huawei.com (7.185.36.138) On 4/23/2026 9:41 AM, Baolin Wang wrote: > This reverts commit 5a90c155defa684f3a21f68c3f8e40c056e6114c. > > Currently, when shmem mounts are initialized, they only use 'sbinfo->huge' to > determine whether the shmem mount supports large folios. However, for anonymous > shmem, whether it supports large folios can be dynamically configured via sysfs > interfaces, so setting or not setting mapping_set_large_folios() during initialization > cannot accurately reflect whether anonymous shmem actually supports large folios, > which has already caused some confusion[1]. > > Moreover, for tmpfs mounts, relying on 'sbinfo->huge' cannot keep the mapping_set_large_folios() > setting consistent across all mappings in the entire tmpfs mount. In other words, > under the same tmpfs mount, after remount, we might end up with some mappings > supporting large folios (calling mapping_set_large_folios()) while others don't. > > After some investigation, I found that the write performance regression addressed > by commit 5a90c155defa has already been fixed by the following commit 665575cff098b > ("filemap: move prefaulting out of hot write path"). See the following test data: > > Base: > dd if=/dev/zero of=/mnt/tmpfs/test bs=400K count=10485 (3.2 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/test bs=800K count=5242 (3.2 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/test bs=1600K count=2621 (3.1 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/test bs=2200K count=1906 (3.0 GB/s ) > dd if=/dev/zero of=/mnt/tmpfs/test bs=3000K count=1398 (3.0 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/test bs=4500K count=932 (3.1 GB/s) > > Base + revert 5a90c155defa: > dd if=/dev/zero of=/mnt/tmpfs/test bs=400K count=10485 (3.3 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/test bs=800K count=5242 (3.3 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/test bs=1600K count=2621 (3.2 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/test bs=2200K count=1906 (3.1 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/testbs=3000K count=1398 (3.0 GB/s) > dd if=/dev/zero of=/mnt/tmpfs/test bs=4500K count=932 (3.1 GB/s) > > The data is basically consistent with minor fluctuation noise. So we can now > safely revert commit 5a90c155defa to set mapping_set_large_folios() for all > shmem mounts unconditionally. > > [1] https://lore.kernel.org/all/ec927492-4577-4192-8fad-85eb1bb43121@linux.alibaba.com/ > Signed-off-by: Baolin Wang > --- > Note: for more investigation and test data, see: > https://lore.kernel.org/all/116df9f9-4db7-40d4-a4a4-30a87c0feffa@linux.alibaba.com/ > Thanks Kefeng for confirming the performance issue. LGTM, Reviewed-by: Kefeng Wang > --- > mm/shmem.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/mm/shmem.c b/mm/shmem.c > index 4ecefe02881d..dafbea53b22d 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -3087,10 +3087,7 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap, > cache_no_acl(inode); > if (sbinfo->noswap) > mapping_set_unevictable(inode->i_mapping); > - > - /* Don't consider 'deny' for emergencies and 'force' for testing */ > - if (sbinfo->huge) > - mapping_set_large_folios(inode->i_mapping); > + mapping_set_large_folios(inode->i_mapping); > > switch (mode & S_IFMT) { > default: