From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 ED37135AC17 for ; Mon, 1 Jun 2026 12:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780316458; cv=none; b=eERhvI+N6Y29q9b3+M89EHP1976XSfZ/Lt4BF+C1ucAe6HVM1vGkjWplxmHLOYab6S8XL8CWhpb4H2PtIlJkxcijs/agKh6tWCjTpKPeicXWvF+oaH8QsPjnQPTG53rxo9DIBu+MourTI8OjfuDf0HT5ctKyE1coBnA5R9RqfHQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780316458; c=relaxed/simple; bh=c+7mNfQ/6LwmoLVo39+ZwlX1fd5wQCHpCKlVMYXzq08=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ah1fDKQoGInrTprax4eoV3llNaMJuCQhLsL0t/PVFGhr21WzmB5O3ufWpefEckANWUs6Kk0Bs3+wsWyP1pF2l2T1XFxX3RJqAq245+KAU/6R+znnVDB+qUmIEexazjBFiuE7R5Iip9Tq6VXZwja1Jw4WKG5UgMqXPCEJPC1S5fY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=d8XKg8ry; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d8XKg8ry" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780316456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ARkpOMLTcYeGeJR1eIF6OuQ1ndOsQ6TntcYnAK5DjuI=; b=d8XKg8ryjI//XBiCbhyILL15U9RmAl48aAGerM+dD2rZWTGvhKL+8y0XRy5BCGGesVg6fY zPnnVkw83tkBE30IldikkljP1wCv27ck/qKRhgvzqoE04QeaXOqQZMSc8FK/Izo3+gzs+I gOjMLgJjnhhik8cBs7awTkBGP9VSVmE= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-GLCekFz0Nn22iHn0pe6qqA-1; Mon, 01 Jun 2026 08:20:55 -0400 X-MC-Unique: GLCekFz0Nn22iHn0pe6qqA-1 X-Mimecast-MFC-AGG-ID: GLCekFz0Nn22iHn0pe6qqA_1780316454 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-8ccdcd8dd3dso78134196d6.3 for ; Mon, 01 Jun 2026 05:20:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780316454; x=1780921254; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ARkpOMLTcYeGeJR1eIF6OuQ1ndOsQ6TntcYnAK5DjuI=; b=MA1zPUdRZb2J08fx9t1J/ohAxSCUpkgzocQj8WoqZ1Yd93Ya+RioEfF2u/yfYOfvbe lM+4J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nM7veLbRtQ8= X-Received: by 2002:a05:6214:194c:b0:8ca:1eb5:eaa3 with SMTP id 6a1803df08f44-8ccefd85525mr182585976d6.27.1780316454429; Mon, 01 Jun 2026 05:20:54 -0700 (PDT) X-Received: by 2002:a05:6214:194c:b0:8ca:1eb5:eaa3 with SMTP id 6a1803df08f44-8ccefd85525mr182583376d6.27.1780316452680; Mon, 01 Jun 2026 05:20:52 -0700 (PDT) Received: from [192.168.2.110] (bras-base-aylmpq0104w-grc-22-70-53-202-134.dsl.bell.ca. [70.53.202.134]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ccea1c2fd8sm91424496d6.23.2026.06.01.05.20.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2026 05:20:52 -0700 (PDT) Message-ID: Date: Mon, 1 Jun 2026 08:20:50 -0400 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: Baolin Wang , 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> Content-Language: en-US, en-CA From: Luiz Capitulino In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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.