From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 05A90382367 for ; Tue, 21 Apr 2026 06:27:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776752853; cv=none; b=GLpoXV6iEajLw+zJD6VBXzTsPfkUrc61HzGJxuO3sMv5E5k37urijBK4TkHdSlnkoB2m7QS8ySPAjg30aTIhwJ65fMFDdsjlwBL4NlQ7NLCvRMLP7IfpBgxqukmfu72iAYgO4iu6QKzKf/lS3LcS37J/AqxpnEFqGk3GDhtCEic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776752853; c=relaxed/simple; bh=C5G2FgNxnWV9IBQ/HZo/Cfw7Yts2BxhV5k82JaVyyvg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jnvk1PQ7vKSiOBbUoKNtSz9KyIh8giVyOJdU5tfXYwfMiDE86746X9BXO6G3S9gM5q12RXOsl5ZZgrV8+rJQUNDZrXDKGRF0Ln7JZE4Q6WZNxGBEWOBHuXF8PJpejnPJAdsif9LCxh84OZlX7J+2Yfu31/B3sUWttshYC02DIY8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=mEokBGrd; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="mEokBGrd" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1776752843; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=G+aWGRtKLkfO/yrjpaFf4WBItCdnCDojE39GH29+8S4=; b=mEokBGrdsUau43hRvckSReYHfX1cJdufgMwPkm6cupbR1I4hSxxS3G8HZrAlUqPtMaDz6+fv0/WLx6k6twcsmZJsyPd2R17i+Lu9XeX/sTI7lWRJIgz0962dxEBZgfrUDWzpgSHEwdXtCIdBzgJ7gkbXS+K6xeiCkfJOiIVT474= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R401e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032089153;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0X1Ryo0o_1776752841; Received: from 30.74.144.134(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X1Ryo0o_1776752841 cluster:ay36) by smtp.aliyun-inc.com; Tue, 21 Apr 2026 14:27:22 +0800 Message-ID: Date: Tue, 21 Apr 2026 14:27:21 +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 v3] mm: shmem: always support large folios for internal shmem mount To: "David Hildenbrand (Arm)" , akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, ziy@nvidia.com, ljs@kernel.org, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <26f954be62348591e720c4e8b7a9099b74dc1d6d.1776331555.git.baolin.wang@linux.alibaba.com> <1b3c0401-6d10-4a28-97c8-8e3858d8dc3d@kernel.org> <015de194-99b9-4f9e-8c89-d35807c6fd08@linux.alibaba.com> <07e26d39-6155-4661-b3df-c2419535ed43@kernel.org> From: Baolin Wang In-Reply-To: <07e26d39-6155-4661-b3df-c2419535ed43@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/21/26 3:00 AM, David Hildenbrand (Arm) wrote: > On 4/17/26 14:45, Baolin Wang wrote: >> >> >> On 4/17/26 5:52 PM, David Hildenbrand (Arm) wrote: >>> On 4/17/26 11:27, Baolin Wang wrote: >>>> >>>> >>>> >>>> For tmpfs, yes. >>> >>> So, we could pass this check here, not setting >>> mapping_set_large_folios(), but later someone toggles it and we missed >>> to set mapping_set_large_folios()? >> >> Indeed. Good point. >> >>> >>> Or would we always go through another __shmem_get_inode() after a >>> remount? >> >> Not really. There could be files created before remount whose mappings >> don't support large folios (with 'huge=never' option), while files >> created after remount will have mappings that support large folios (if >> remounted with 'huge=always' option). >> >> It looks like the previous commit 5a90c155defa was also problematic. The >> huge mount option has introduced a lot of tricky issues:( >> >> Now I think Zi's previous suggestion should be able to clean up this >> mess? That is, calling mapping_set_large_folios() unconditionally for >> all shmem mounts, and revisiting Kefeng's first version to fix the >> performance issue. > > Okay, so you'll send a patch to just set mapping_set_large_folios() > unconditionally? I'm still hesitating on this. If we set mapping_set_large_folios() unconditionally, we need to re-fix the performance regression that was addressed by commit 5a90c155defa. But it's hard for me to convince myself to add a new flag similar to IOCB_NO_LARGE_CHUNK for this hack (like the patch in [1] does). >> [1] https://lore.kernel.org/all/20240914140613.2334139-1- >> wangkefeng.wang@huawei.com/ > > Is that really required? Which call path would be the problematic bit > with the above? > > I'd say, we'd check in the large folio allocation code whether ->huge is > set to never instead? Yes, this is exactly our current logic. When allocating large folios, we'll check the ->huge setting in shmem_huge_global_enabled(), which means large folio allocations always respect the ->huge setting. But as I mentioned earlier, the ->huge setting cannot keep the mapping_set_large_folios() setting consistent across all mappings in the entire tmpfs mount. My concern is that 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. However, I got some insights from Documentation/admin-guide/mm/transhuge.rst. Does this mean that after remount, whether the mappings of existing files support large folios should remain unchanged? “ ``mount -o remount,huge= /mountpoint`` works fine after mount: remounting ``huge=never`` will not attempt to break up huge pages at all, just stop more from being allocated. ” Do you think this makes sense?