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 C74B91EEA3C for ; Thu, 14 May 2026 02:19:03 +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=1778725145; cv=none; b=hY23UuVDaUo+YQAzmdL2w3chTBJBAcJM33UqUP9jzuvdd/eJSpDMYfGdsNJWfTnr8M26CwobYW6kM7BVt9lzDa0msYOy6Rg7bU2uw5tZ4qhWam0SqjR8KOUCPkhMBzujcwbvCH6UjpIaK6L/hX2sacTy1qNV2a8VqccLscPT+kA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778725145; c=relaxed/simple; bh=KU1MaY7d0ldjy820XWNm/mpOxByfz69pYnamqc6GfMA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hZ/v7XjafKPCwvYzstBYhfasPdM/pyHzfRUYokDBnf8dIP1Zo+owCXbWZjXQL8hsgpS05Mk7QIddJ0uzM3Bf5uYBTfR1KZDdu+S19/mWlieAT+OwINL6PjRzZ0MqlOKPQxKqgf0xVcE8T8CcYw/RPeEoWB4dNmqYqO8utSr9KQk= 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=S9zSbRV/; 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="S9zSbRV/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778725142; 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=NTcHCLMwDFGHou/kFY3HOs8s4576E62WE4EOADoCAms=; b=S9zSbRV/7Hx0S6G+MngLYp9pVE3oBVOYtpBUO8LqU3lX9FJB3nAzaGhzYVNIANwEZF6qJK 5s/XFn47hzeOxtfqx+EgRag1CAsJu7cxCFn8hwrERLxajcyaYW5Jd6AMfYRekc7f2d0HIL 0+n/7ayTuNegSq2TPNHp7MbjqYYqEXQ= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-qaZwh6wANeuCRLVUQVUstg-1; Wed, 13 May 2026 22:19:01 -0400 X-MC-Unique: qaZwh6wANeuCRLVUQVUstg-1 X-Mimecast-MFC-AGG-ID: qaZwh6wANeuCRLVUQVUstg_1778725141 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-90d02857cdfso746878785a.2 for ; Wed, 13 May 2026 19:19:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778725141; x=1779329941; 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=NTcHCLMwDFGHou/kFY3HOs8s4576E62WE4EOADoCAms=; b=TjNQmLx90AAU6YGAMfN0ySMyfXMNDeTiD+lw4CL2NpBDoLTSKaG5zgEBQPY17XqSI6 EGcL14LykcrPD8mJ0pQ5S6LKqhMX4J290tIxl1dGh/dcFmROWBnW/xgMNUDMfQ4sQVNY 0xCaxJJH+Jk0R6jGmPYdwTAXRNA1tURdF0Lffn8NPzk9TNBjkNPoueGofUMnS+h1ORpq 1O69z75Get1R+uLUP+NJGl8PPSOxDHC+XT8gcbpCOXRyHhsHt8OL+IRkL6FbyPn7b2hR ATwpuX06taP7KhsdlWafL6DyxN5smSVwXvGaOUJxN7GJnCV5o5oRqQR6tdkiGOB/zLNm 1scw== X-Forwarded-Encrypted: i=1; AFNElJ8bw2ZxCmeO/nlPdfxrJd1KnCG07BCuP3I0gS2nk20YaJnz3fT+22hDzVYofof+SsEffv0kbLH9b029FTU=@vger.kernel.org X-Gm-Message-State: AOJu0YyoLBMzyrs7i5BUxCuO73d156eRp93xHAWLFK2tas6PuOAyHF+S DrBFdmLTTUlM9dy1hx3vziFoIig9z0e/zafWDQtRoRGnehTsaGb2mqNMSC4NJFlDiYsN7qokPf2 3kBESI5vfF6bniLap4Tg8RbDKHTD+F+kfxbl9QGONZwftgMH4jDFumklgmSPC/trwaQ== X-Gm-Gg: Acq92OGQ9lK6Pe64IXxEDCO5xmP8qyNhvfmTxOzuEzvUmSc3Lz9kBKBA+umiJKI2v7Y kGm727+G21vTFi8GEgLvNjzUqSxkxUYtjBDxL7/dAYPxULVfqgC84JNrs0zvKSMpKcKKzzhVK41 rBrVcajutradhe9TfTM1kF/1XgiDrijKx+w1yverz+AojcnWJjfDPIstlSNCVVXj+pRTh+6ewWw o9bYbwsWZBq2PpR0jQeryN39c9oXEo8joGVOLFH1bt+SjT0EvTgZPxQBoWd81e8ORoz8an3sHSG k/7FIz4n8ng7FdXJpCWk8FWxLeNi6LF6Los+FNTMMvq6S2kA5359ZB4T8C469+0yJmrKgliOZP8 9zJ2pbfh0tLPPPqKMaOxjNXG6 X-Received: by 2002:a05:620a:1708:b0:910:4023:4fc5 with SMTP id af79cd13be357-910402352f4mr609026785a.13.1778725140302; Wed, 13 May 2026 19:19:00 -0700 (PDT) X-Received: by 2002:a05:620a:1708:b0:910:4023:4fc5 with SMTP id af79cd13be357-910402352f4mr609022885a.13.1778725139748; Wed, 13 May 2026 19:18:59 -0700 (PDT) Received: from [192.168.2.110] ([70.53.202.134]) by smtp.gmail.com with ESMTPSA id af79cd13be357-910bcf35843sm118154085a.38.2026.05.13.19.18.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 May 2026 19:18:59 -0700 (PDT) Message-ID: <1f4bccaf-6472-4e4c-92d0-28ac05f6f838@redhat.com> Date: Wed, 13 May 2026 22:18:48 -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 v4 2/9] mm: introduce pgtable_has_pmd_leaves() To: "David Hildenbrand (Arm)" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, baolin.wang@linux.alibaba.com, 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, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com References: <2a0bae00cdd2b6ef6b962610b523ebfc97806ba7.1777663129.git.luizcap@redhat.com> <07f1039c-cf9b-4b97-a044-9d5771ea54fb@kernel.org> Content-Language: en-US, en-CA From: Luiz Capitulino In-Reply-To: <07f1039c-cf9b-4b97-a044-9d5771ea54fb@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026-05-13 11:36, David Hildenbrand (Arm) wrote: > On 5/1/26 21:18, Luiz Capitulino wrote: >> Currently, we have two helpers that check for PMD-sized pages but have >> different names and slightly different semantics: >> >> - has_transparent_hugepage(): the name suggests it checks if THP is >> enabled, but when CONFIG_TRANSPARENT_HUGEPAGE=y and the architecture >> implements this helper, it actually checks if the CPU supports >> PMD-sized pages >> >> - thp_disabled_by_hw(): the name suggests it checks if THP is disabled >> by the hardware, but it just returns a cached value acquired with >> has_transparent_hugepage(). This helper is used in fast paths >> >> This commit introduces a new helper called pgtable_has_pmd_leaves() >> which is intended to replace both has_transparent_hugepage() and >> thp_disabled_by_hw(). pgtable_has_pmd_leaves() has very clear semantics: >> it returns true if the CPU supports PMD-sized pages and false otherwise. >> It always returns a cached value, so it can be used in fast paths. > > Oh, one more thing: what will be the semantics regarding > CONFIG_TRANSPARENT_HUGEPAGE? > > I assume it will only return true if CONFIG_TRANSPARENT_HUGEPAGE is enabled, > correct? > > That is, for example, relevant for patch #2. > > We could later change these semantics, but for now we should be very clear about > what it means. I intended to decouple the API from CONFIG_TRANSPARENT_HUGEPAGE,so my goal was to return true as long as PMD-sized pages are supported[*]. If arch_has_pmd_leaves() is not implemented by the arch, we default to CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE, not CONFIG_TRANSPARENT_HUGEPAGE. Now, do you mean to say that the API should still be tied to CONFIG_TRANSPARENT_HUGEPAGE? If yes, why? * Sashiko found out that the current arch_has_pmd_leaves() implementation for x86 (and possibly the other archs) is guarded by CONFIG_TRANSPARENT_HUGEPAGE, so we may return true without the hardware check. But that's a bug