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 49741271A9A for ; Wed, 17 Dec 2025 18:50:24 +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=1765997426; cv=none; b=jyocOu44rL0MJfydmlGbfbUt+CtAPIPVjJvfQDEgcry9MRSmI5b1B7GikRiKVbEv8ECd/4a6pKZbpVoha20sZDfEtH+QO0iHcYApNJ4JoRHox1IyvE6egNhHDDT0jms4sWS1MHai7h8QwE0MU6y+ewcNNVE4mDWoEYBhRBhkpow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765997426; c=relaxed/simple; bh=hzlL2UKBWy3vRlakEcxKC5AsJsJB9MQjzH1xWh6n9CY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LvL3yuiNj2VZ7vsfcCiDs50jqZ+BKdAtcP/ZC7zFRre8lwomwW+Br5/7BGUMv05F6xtM/RNA7pb87fgTLXExqndGflAmZ392eYe1CI018P7uVM/TfActoGj0dyQ3/plEWQ5VwasaLhqSnebBuKumKXKL9ngyZN7xmiss08wo7Fw= 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=hp+ly/O7; 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="hp+ly/O7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765997423; 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=EidE7jdXt0UYKwzPU9UpTjHI4QPMS/jha9Tv6skpLTs=; b=hp+ly/O7CvbN/S3uTuvbSWQPt/hz7P+BBRw/CDdapT+4+ulobpRRyffSNcBlYc+VV0Te+q c05fVZuB5mZ6dUNaAfhz8/s0jUrfeRUDGIjTVZN3u6DsHoo15hEaor68lSpqPUphigiL1P HUGDsY9Cl4URDRIz7ZnU76AgxJFOYek= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-512-VY-pf7juM_2ReyvDieMpjQ-1; Wed, 17 Dec 2025 13:50:22 -0500 X-MC-Unique: VY-pf7juM_2ReyvDieMpjQ-1 X-Mimecast-MFC-AGG-ID: VY-pf7juM_2ReyvDieMpjQ_1765997421 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-88a2d8b7ea5so57146306d6.0 for ; Wed, 17 Dec 2025 10:50:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765997421; x=1766602221; 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=EidE7jdXt0UYKwzPU9UpTjHI4QPMS/jha9Tv6skpLTs=; b=K5xC2aIzSnsBmGyo1ruPD1GaK7zBuWt1dwNlCIKf9uaCLasgzGO3AiPf/Rq4dnzvuU XddKjnp4QSMAaNfUyIC1oV+ouzOu5UoOcByZvJ71nzCpLkvbEjdoQKaeEKKzelnBCf8w LXReCYN2r2+qEII1baf3rt3YEbbf7QNkD2APfOmpJGJvLyBT86yMEr3kWESbcIiMYRn0 ZpdgdNCVuuwDPror8iSV0xCaRzpBAMRxRHfqCVqOWLEcIqFpJ8maVj7L0Zvd4jiTGorl zW4kJ8zyj36rXSDJTfnghRUt/2rTqvaLjRLk/0WjdTh/FOflcyWS3TNVegQnspOYZdv2 QTxQ== X-Forwarded-Encrypted: i=1; AJvYcCVABWZLknEnIHd4fUXjaT9nB9apLh8qXuzLxrZswFWb1HIj7DSCakjqCQRC73qV0sPAtYPeGmFbDFAj69o=@vger.kernel.org X-Gm-Message-State: AOJu0YywEx22bnm32Rt3d6yqQyLVeorN8TZpWSpqq9A91PWFqS9CinzT cbxlO/mIviNPR9oPTGrNU5UehaS7RFbOqZoDMcdGRiLDj3KJVO4bSisy79dtMpCFilwWAAgW5R4 Ums37KeWQuk5at86WO3/NLU10nthDb9YqXk0pb+QkEm6F/xMI1FXW7LeKoUruBKX2srxErPlO2A == X-Gm-Gg: AY/fxX4F3Zw1OpaVDE15jV5qDM5F+BQpaL362QEu3MuG/d4pIixUP+/kRx4lslE4YA/ z9Z5YFRvX+P1WljyH17ucMTpN7t7daFlpfPf35lFvyei2SXMG2Fhyrz64zejNlJurkuRDglcEpq R22IOK2WnJLMdSRd5PRw0DcLzu3A4MFjj0IEYqpZhMkq3W2xI3SXvBv8KXF+0nmJcs0kckgY5Dz CrYHT1Da50iRFp4oV5FRdGPJ0w5h5Jak3/v7A3H5tYTYDLPW+iaLit/vFk/b0EKCJJsQM3L2hhe a7QHY/YxP1b5k2Bp+2JySnQFf2/WV8brAIn5hMEEJEP3Wk0cJOcrHNzaFvesFzUqAu2yw6Iv+Ng ywa80zQHNkTo= X-Received: by 2002:ad4:5ba8:0:b0:87c:b91:788f with SMTP id 6a1803df08f44-8887e42ed67mr328077836d6.16.1765997421010; Wed, 17 Dec 2025 10:50:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IETx0DwnisTQ5EVVeGIDPDdI0MYWLK5ibI8oPBGvf27VhTZegS1FyULmKsUp5rce/dArvnPnA== X-Received: by 2002:ad4:5ba8:0:b0:87c:b91:788f with SMTP id 6a1803df08f44-8887e42ed67mr328077486d6.16.1765997420556; Wed, 17 Dec 2025 10:50:20 -0800 (PST) Received: from [192.168.2.110] ([76.65.77.217]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-88c5e169c8csm1563416d6.24.2025.12.17.10.50.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Dec 2025 10:50:20 -0800 (PST) Message-ID: <4c43344e-8ecd-43ba-b8d2-e62e9e0fecb6@redhat.com> Date: Wed, 17 Dec 2025 13:50:09 -0500 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 07/11] mm: shmem: use pgtable_has_pmd_leaves() To: Baolin Wang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com References: <64b1e5fd-113d-4874-9b6c-6e344bd24ed5@redhat.com> <324b64d3-2d12-462c-9afc-070dd100c582@linux.alibaba.com> Content-Language: en-US, en-CA From: Luiz Capitulino In-Reply-To: <324b64d3-2d12-462c-9afc-070dd100c582@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025-12-16 21:03, Baolin Wang wrote: > > > On 2025/12/16 21:47, Luiz Capitulino wrote: >> On 2025-12-16 02:52, Baolin Wang wrote: >>> >>> >>> On 2025/12/16 05:16, Luiz Capitulino wrote: >>>> Shmem uses has_transparent_hugepage() to check if PMD-sized pages are >>>> supported, use pgtable_has_pmd_leaves() instead. >>>> >>>> Signed-off-by: Luiz Capitulino >>>> --- >>>> mm/shmem.c | 7 ++++--- >>>> 1 file changed, 4 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/mm/shmem.c b/mm/shmem.c >>>> index b329b5302c48..ad5825667b49 100644 >>>> --- a/mm/shmem.c >>>> +++ b/mm/shmem.c >>>> @@ -689,7 +689,8 @@ static int shmem_parse_huge(const char *str) >>>> else >>>> return -EINVAL; >>>> - if (!has_transparent_hugepage() && >>>> + if (!(IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && >>>> + pgtable_has_pmd_leaves()) && >>>> huge != SHMEM_HUGE_NEVER && huge != SHMEM_HUGE_DENY) >>>> return -EINVAL; >>>> @@ -4655,7 +4656,7 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) >>>> ctx->huge = result.uint_32; >>>> if (ctx->huge != SHMEM_HUGE_NEVER && >>>> !(IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && >>>> - has_transparent_hugepage())) >>>> + pgtable_has_pmd_leaves())) >>>> goto unsupported_parameter; >>>> ctx->seen |= SHMEM_SEEN_HUGE; >>>> break; >>>> @@ -5439,7 +5440,7 @@ void __init shmem_init(void) >>>> #endif >>>> #ifdef CONFIG_TRANSPARENT_HUGEPAGE >>>> - if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY) >>>> + if (pgtable_has_pmd_leaves() && shmem_huge > SHMEM_HUGE_DENY) >>> >>> Using pgtable_has_pmd_leaves() here is a bit confusing because the definition of pgtable_has_pmd_leaves() is: it returns true if the CPU supports PMD-sized pages and false otherwise. >>> >>> However, tmpfs and shmem already support other sizes of large folios, not just PMD-sized large folios. >>> >>> So, for me, using has_transparent_hugepage() to check would be at least clearer (even though it doesn't change the functionality). >> >> This is more of a naming issue, correct? > > Yes. > >> Would adding something like thp_has_pmd_support() which expands to: >> >> return IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && pgtable_has_pmd_leaves(); >> >> solve it for you? I suggested it in my RFC, but David advised not to do it. > > I agree with David. The thp_has_pmd_support() is not helpful too. What I mean is that the term 'pmd' shouldn't be used here. PMD-sized large folios aren't any more special than others. > > shmem also supports mTHP, and a better approach might be what you did in patch 10: even if PMD-sized pages are not supported on an architecture, shmem can still use other sizes of mTHP. Oh, I get watch you mean now. I'll have to dig a little deeper into the shmem code but I'll give your suggestion a try. Thanks for your feedback. > >> Also, I'm not sure if the comparison with other folio sizes apply, as >> PUD and PMD sizes are special. >