From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (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 16927377017 for ; Mon, 1 Jun 2026 12:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780315757; cv=none; b=uEzZhDNfcgjShuMMqgIbZaVmbOIoGswNWx/WHIpyN/E+jODAeIAVXpAwDH/JlJJKkZ4+69XyyTs4isvn2HH9cwRXvPR4WaRrWRtaJjBOCKknIgx3ZvjEZLFJzTgjZFpVmbbBdIaIT8URaCI/AYo4Fk2mGZaNQBtgzcelJAsdkso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780315757; c=relaxed/simple; bh=36Jxj7WUJxgpdsbiaGvXPvprS+63XCILIbTwpumnrIM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tsjpU11PSmlBXThpPOJfhhF1KKEIF0gybCyE/xi4X0hMsU/UYKcahbdXx+DPbKbfqw/LkP7LAs/fQyqmF+MBuZq222exjETsnYWOnptH6+Vdonu79rFuYb/vvc9z4i1S3pqh5KN6dTPpklpSee8m87npLMQyMhPnyhtkg40yM3g= 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=Ktvkqc9S; arc=none smtp.client-ip=115.124.30.100 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="Ktvkqc9S" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1780315753; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=WfB0ZqR87Vb3EIeBR7rBV20qtEzbHkO/sIK+WTO1F1c=; b=Ktvkqc9SCgNrFJNPLRSMRyIDPRVOCI9iwONxZkZyWk5MogF8zId/+zB3EiuV15kF5auUCfVTaxU1tISP1jHYNQ8Gyp1qR6Q/Le1kbkQ4j5GOSwwQXJK+BoFRaMks48wlZgHkBY+toCcuQ0FyP2cx3ssH3bzijEjQbzGHWiRwOsU= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;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=27;SR=0;TI=SMTPD_---0X4.VMA8_1780315750; Received: from 30.166.19.62(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X4.VMA8_1780315750 cluster:ay36) by smtp.aliyun-inc.com; Mon, 01 Jun 2026 20:09:11 +0800 Message-ID: Date: Mon, 1 Jun 2026 20:09:10 +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: <144e7639734a501340bffe5652f8ce32b3657e23.1780066530.git.luizcap@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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?