From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (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 9FDED3630B9 for ; Tue, 2 Jun 2026 02:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780368928; cv=none; b=DWnZbbreJ6PYDQAoj50hWgPX+5av3VlpcwxCP7zEijfw/gfO4elhMjvvmSwvwkHUnP3N8f3nQk0MhNpP+zdVGB/fglLj77dn/xw0Kp+N4gUMVFyw7+eI2MIFMyTpB3YjE/PNZRstSP64cQgjLAcOzjLgJM0q14fmUIJvVYTwXlg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780368928; c=relaxed/simple; bh=7uJc03HFGu3Hb6RwtM3cZCVF038avBoyl0nsCKL0t4Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WYHD7xmVKiIDvuwraEHmmeYuzQlfy33SJXXs0xxxk8xVbhcr2rGs8WsBExGr0Zb1oSoq4Gn1msFAGp+aX338PQDYjfkg8nogUmDw7R0Y6fKDQ3xSDT718DteYmBt8ON+boseK/AUD4yxcBkmHHk7Ge5Kum12K9dsDO7bCdqPMXs= 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=UojR3uHR; arc=none smtp.client-ip=115.124.30.131 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="UojR3uHR" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1780368918; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=7Th6POTS5cfqS0INpKHeDI8jZg/Oz3hxMZKWpXyeBNo=; b=UojR3uHRs+0+ZeEwzGlHyACN6yUZsV+c/37BZmOwEN4OZEFSQB/TJOTO6rlnxFeyaqahx/frkyrQOlkZGJsucoBTu+Z02YA6djz7TctQ8iMQSwgrL6jI1CqGKlaXmUq81Oh63csFhHp2bKY3GpvN4hizFqH3s8fHL6ZPeogi/JQ= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045098064;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=27;SR=0;TI=SMTPD_---0X42efNp_1780368914; Received: from 30.166.17.138(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X42efNp_1780368914 cluster:ay36) by smtp.aliyun-inc.com; Tue, 02 Jun 2026 10:55:15 +0800 Message-ID: <4d8ca368-d37f-4a8f-bec2-bcbf159ffc20@linux.alibaba.com> Date: Tue, 2 Jun 2026 10:55:13 +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 v5 07/14] mm: shmem: allow THP support determination at folio allocation time To: Luiz Capitulino , linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org References: <144e7639734a501340bffe5652f8ce32b3657e23.1780066530.git.luizcap@redhat.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 6/1/26 8:20 PM, Luiz Capitulino wrote: > On 2026-06-01 08:09, Baolin Wang wrote: >> >> >> On 5/29/26 10:55 PM, Luiz Capitulino wrote: >>> In order to enable THP support in shmem today, besides the user >>> configuration required, the CPU must support PMD-sized pages. This >>> is the case because of the following has_transparent_hugepage() >>> usage: >>> >>> - shmem_parse_one() and shmem_parse_huge(): Check if THP is built-in and >>>    if the CPU supports PMD-sized pages >>> >>> - shmem_init(): Since the CONFIG_TRANSPARENT_HUGEPAGE guard is outside >>>    the code block calling has_transparent_hugepage(), the >>>    has_transparent_hugepage() call is exclusively checking if the CPU >>>    supports PMD-sized pages >>> >>> While it's necessary to check if CONFIG_TRANSPARENT_HUGEPAGE is enabled >>> in all cases, shmem can determine THP size support at folio allocation >>> time. Therefore, drop the has_transparent_hugepage() usage listed above >>> while keeping the CONFIG_TRANSPARENT_HUGEPAGE checks. >>> >>> Additionally, we need to check if PMD size order is supported in >>> shmem_getattr(). Use pgtable_has_pmd_leaves() for that. >>> >>> Signed-off-by: Luiz Capitulino >>> --- >>>   mm/shmem.c | 9 +++++---- >>>   1 file changed, 5 insertions(+), 4 deletions(-) >>> >>> diff --git a/mm/shmem.c b/mm/shmem.c >>> index 88bc0c292f1a..108dc969b92a 100644 >>> --- a/mm/shmem.c >>> +++ b/mm/shmem.c >>> @@ -689,7 +689,7 @@ static int shmem_parse_huge(const char *str) >>>       else >>>           return -EINVAL; >>> -    if (!has_transparent_hugepage() && >>> +    if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && >>>           huge != SHMEM_HUGE_NEVER && huge != SHMEM_HUGE_DENY) >>>           return -EINVAL; >>> @@ -1303,6 +1303,8 @@ static int shmem_getattr(struct mnt_idmap *idmap, >>>       generic_fillattr(idmap, request_mask, inode, stat); >>>       orders = shmem_huge_global_enabled(inode, 0, 0, false, NULL, 0); >>> +    if (!pgtable_has_pmd_leaves()) >>> +        orders &= ~BIT(PMD_ORDER); >> >> Ah, you did in this patch, but this change should belong in patch 14? > > If we move it, then this patch will add a temporary issue until patch 14 > where shmem_getattr() may report PMD-size for blksize even when the CPU > doesn't support PMD-sized pages. OK. I see. Feel free to add: Reviewed-by: Baolin Wang