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 CBDC9351C04 for ; Thu, 9 Apr 2026 21:19:27 +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=1775769569; cv=none; b=i2d/NAIfYo9uOvDHcql0PvE3psvtje1NQ0/D74h5uEjpRMeTS7eF5d/WC9IIpFhwFD94ryhIB+TkLY6wGSSzfyWDKcQs13JdxE8VGsYur9XIvQ/PlTRuzMBrzE9CHxHMKC1oKERdYeRuCNvYf7/18cR2AZEOD3Su9MOj+vrwLXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775769569; c=relaxed/simple; bh=72fnPX6YSutqhCeIpY8qT/u5WjUzBzzdZachsDBd5jk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kQQc5ySA52Reyd+iUATRZpTY6DxVCrPRf26LWFE/9Mfzw4RjR6/ux78HiCJTTpJPAWsfcVpQtmNAF+z7ZgdHBVIzVRAS0O1iszJeUYSYzaYF04swX19ZLLzNLAg7KSo2yt+LGSMLaf97Xs1UPx0C5dH7pcw046AR8bW7Z2bzVuY= 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=J4zk6i1m; 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="J4zk6i1m" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775769566; 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=EIUt9WlgOJJqFjCvH2t68LmJqvUmIIgnA/Q8Mpi6SV0=; b=J4zk6i1mLiH5vgtEfsOuNPn4JJp9zprbrhnbUgguVtDIVPCE5yRHtVdssvcIWLYGodiYV/ wlmiQFgP0G4voHFzLd613H42K007TiicDH1BG/9QwM7U/oobBJt4oS3dRj3i6e6ChCb6B7 nSqkjyFvm+7Dgoiz8RX+6o83EQ0WOdA= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-68ag81rLNbmK4xWz7heKRg-1; Thu, 09 Apr 2026 17:19:25 -0400 X-MC-Unique: 68ag81rLNbmK4xWz7heKRg-1 X-Mimecast-MFC-AGG-ID: 68ag81rLNbmK4xWz7heKRg_1775769564 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-8d3bea3aa34so297306085a.0 for ; Thu, 09 Apr 2026 14:19:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775769564; x=1776374364; 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=EIUt9WlgOJJqFjCvH2t68LmJqvUmIIgnA/Q8Mpi6SV0=; b=HF3bGi6bea/pwtTR9Mqyu4YpR5lqVkByyW0r171CsmR/UjQLIQ97bx80TIBqPrpipD hkydbOxF4X0XalgqXDCJv1cQ/PvBuJN9SD62F/kcRohgmIi/7VV34vQ6ccAPtjYC9VeE qQiaHjZm+SgxiylDWJxbyXMGh6Xt+GSndPiIFfgEyktk4imMVR3dh/6UvPHNOaq806GB SwM55KvYaYqzzqnlau2hKDT4Sm5OU/I2g/vD+mdJL00sCH7EAuRpwOTTrlWmF7ioDZxK s0ELa5jZEmnrVNFxf+B6RBt+x/+u4tZn/pfDNQfA0bVY2ZmW6In302lGFR2rC+M/E41y ffgA== X-Gm-Message-State: AOJu0YxO0vUgwBBPVI57EnUMD7Ds3t9a1HEAhYK8jcjfQwP7LtOQI75w sZM8eQHvbbWegI6/UAFTJ80lteCeFpaJiL5BHl0H0wwXRmPTG/fOF4vWomC6nLgtcuv3AKsE9pf K4OHXMfCMNzhSeDIAsb6As5hjQpHRkzBaPEkYGq8aZNfhyzsX2CCCvF3OugsdEGNf7A== X-Gm-Gg: AeBDieth98RyNS3Q4AFqTEFRIrhHd+zTN2SXPW9PkwRS4Gso9xMq6MK4aEfxSD8gUNv mhStnShlBSGU2RJ/mSLvIJ9rulyHAqpXjzl/xedA9z3yGR9MZATV1fTL/ForWJe8bvF+pINglih cIDo0OtRkgFSOj678Ab8hpToI6ecPFPrih2MSEPQC/lpRI9bL6yZhLdMGgNckIVMCp4jCi66PsA VyFGGRxViKJ2+gHiv+zPg3Pz9ZQGVy5PsqGYexeCslcabjWr9iRdKeYx+raEfSt0FeEmX59rIeK Esnjx3+RsGnkPdN7wQ0qzxDuSZYt/Fw3EZQsPIT9t6f2d0SPdo095vnYeBOlv8qkix2yAfCiMOM ddDxgl46w01VO4Y3NrFT/Mxhw/Wt6zCJEW0As7VodOIfqGKzMk0UhH14moc+fVD5/LSCTeJuHL2 wFhPkYPlEmdXIdcWU= X-Received: by 2002:a05:620a:404a:b0:8cd:b38e:9042 with SMTP id af79cd13be357-8ddcd022ef9mr81979585a.8.1775769564474; Thu, 09 Apr 2026 14:19:24 -0700 (PDT) X-Received: by 2002:a05:620a:404a:b0:8cd:b38e:9042 with SMTP id af79cd13be357-8ddcd022ef9mr81974185a.8.1775769563966; Thu, 09 Apr 2026 14:19:23 -0700 (PDT) Received: from [192.168.2.110] (bras-base-aylmpq0104w-grc-53-69-159-169-238.dsl.bell.ca. [69.159.169.238]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb9637c5esm47958885a.38.2026.04.09.14.19.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Apr 2026 14:19:23 -0700 (PDT) Message-ID: Date: Thu, 9 Apr 2026 17:19:22 -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 v3 09/10] mm: thp: always enable mTHP support To: Zi Yan Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com References: <6dea717fe8c86003e7da33c9a7623b834649d5ee.1775679721.git.luizcap@redhat.com> <772C4431-FA93-4477-B1CE-3BE5EA97FD0B@nvidia.com> <7830cda5-b3df-4da1-805b-278d5af6b2b1@redhat.com> <3B2D36D9-4B04-4548-ABA0-AE5DAF66B2EF@nvidia.com> Content-Language: en-US, en-CA From: Luiz Capitulino In-Reply-To: <3B2D36D9-4B04-4548-ABA0-AE5DAF66B2EF@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2026-04-09 16:10, Zi Yan wrote: > On 9 Apr 2026, at 16:07, Luiz Capitulino wrote: > >> On 2026-04-09 11:55, Zi Yan wrote: >>> On 8 Apr 2026, at 16:23, Luiz Capitulino wrote: >>> >>>> If PMD-sized pages are not supported on an architecture (ie. the >>>> arch implements arch_has_pmd_leaves() and it returns false) then the >>>> current code disables all THP, including mTHP. >>>> >>>> This commit fixes this by allowing mTHP to be always enabled for all >>>> archs. When PMD-sized pages are not supported, its sysfs entry won't be >>>> created and their mapping will be disallowed at page-fault time. >>>> >>>> Similarly, this commit implements the following changes for shmem: >>>> >>>> - In shmem_allowable_huge_orders(): drop the pgtable_has_pmd_leaves() >>>> check so that mTHP sizes are considered >>>> - In shmem_alloc_and_add_folio(): don't consider PMD and PUD orders >>>> when PMD-sized pages are not supported by the CPU >>>> >>>> Signed-off-by: Luiz Capitulino >>>> --- >>>> mm/huge_memory.c | 13 ++++++++----- >>>> mm/shmem.c | 4 +++- >>>> 2 files changed, 11 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c >>>> index 86e489c0a150..6de3d8ebc35c 100644 >>>> --- a/mm/huge_memory.c >>>> +++ b/mm/huge_memory.c >>>> @@ -118,6 +118,9 @@ unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, >>>> else >>>> supported_orders = THP_ORDERS_ALL_FILE_DEFAULT; >>>> >>>> + if (!pgtable_has_pmd_leaves()) >>>> + supported_orders &= ~(BIT(PMD_ORDER) | BIT(PUD_ORDER)); >>> >>> Why is BIT(PUD_ORDER) also removed? I thought PMD THP support and PUD THP support >>> are separate. Here the code implies PUD THP relies on PMD THP. Is that the case? >> >> This was a suggestion from David to an earlier version: >> >> https://lore.kernel.org/linux-mm/dac20466-adac-4e47-8f50-87f4774fd57b@kernel.org/ >> >> My understanding was that if an arch doesn't support PMD pages then it >> probably doesn't support PUD pages either. > > Got it. Can you add a comment on “No PMD leaves -> No PUD leaves” for > pgtable_has_pmd_leaves(), so that no one would ask the same question again? Sure, I can do that. > > Thanks. > > Best Regards, > Yan, Zi >