From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3A9F6281357 for ; Tue, 5 May 2026 10:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777977970; cv=none; b=psmdioIpw4AvelfuLg5Y0+cSNdsMuz9DyEiCRYKp7vTFw8Mh2u12cgXkwGET5Ttw6URDsYDacsEmfTbwyx1ALbu5Ti9fx/fAMBM1nSzrIoiKVtW1TBopHlue13SJlk+ndcEBdJIWDplieTJ8loiiKJpgERWppUz8IuziTgo++Sg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777977970; c=relaxed/simple; bh=+GNY90dzTILC5CDafZz5WsKt74hrsB3DqDY3Q/XEH6I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Mp5Tq/8rAbI9yOForBdNGWXh6QWJiim9r4fqvoAI+H/hjXyx0bfdOJ2zWOW3U9lSdSAzz4X+25MLdO8rnsFruYix7RXe9qC4T7VXkyMwYwdC9un9m+tG9cAayMiN7Z45WGYtzF9c57w6c7nsSyUifgSK6g96M7SBCpfvDHk6hck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BRRjlRRR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BRRjlRRR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 505E3C2BCB4; Tue, 5 May 2026 10:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777977969; bh=+GNY90dzTILC5CDafZz5WsKt74hrsB3DqDY3Q/XEH6I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BRRjlRRR+nmnd8jDCl/yDYBBP8BJ0uWyuuogsOhF2nKQ3grbbRG/+U3LA5c+ij4TY vJFv4EU328MUB2ofyxWqTt3tX2jszVkVh98P3Akk1vIYzzan27vwDYjkAYMkYTPmnI ofAzG9yjvC1dmm4nueiEHxmNrcNrL7uPIh+fZwxiybGfO2aMzX8ntgr2wWTc7uDJjg 9srLQvOGsvNq8zY1pnd0JeLKXhQO/GvCXzHoHKhMLlQPjv0uypqkEO/tsEsxShxvnw zAGISLcLExl0S9IuJwk3rk/eLOTYvunWoajPfWMkIBvShpEscz1KcEnNBtBJmXl70l RRvNyEB35YX5g== Date: Tue, 5 May 2026 11:46:05 +0100 From: Lorenzo Stoakes To: Baolin Wang Cc: akpm@linux-foundation.org, hughd@google.com, willy@infradead.org, ziy@nvidia.com, david@kernel.org, lance.yang@linux.dev, wangkefeng.wang@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Revert "tmpfs: don't enable large folios if not supported" Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Apr 23, 2026 at 09:41:42AM +0800, 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 Acked-by: Lorenzo Stoakes As David asked, should we have a Fixes tag? What about cc: stable? Cheers, Lorenzo > --- > 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. > --- > 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: > -- > 2.47.3 >