[RFC 04/10] drivers: i915 selftest: use pgtable_has_pmd_leaves()

Luiz Capitulino posted 10 patches 1 month, 1 week ago
There is a newer version of this series
[RFC 04/10] drivers: i915 selftest: use pgtable_has_pmd_leaves()
Posted by Luiz Capitulino 1 month, 1 week ago
igt_can_allocate_thp() uses has_transparente_hugepage() to check if
PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead.

Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
---
 drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
index bd08605a1611..c76aafa36d2b 100644
--- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
+++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
@@ -1316,7 +1316,7 @@ typedef struct drm_i915_gem_object *
 
 static inline bool igt_can_allocate_thp(struct drm_i915_private *i915)
 {
-	return i915->mm.gemfs && has_transparent_hugepage();
+	return i915->mm.gemfs && pgtable_has_pmd_leaves();
 }
 
 static struct drm_i915_gem_object *
-- 
2.51.1
Re: [RFC 04/10] drivers: i915 selftest: use pgtable_has_pmd_leaves()
Posted by David Hildenbrand (Red Hat) 1 month ago
On 06.11.25 22:28, Luiz Capitulino wrote:
> igt_can_allocate_thp() uses has_transparente_hugepage() to check if
> PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead.
> 
> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
> ---
>   drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
> index bd08605a1611..c76aafa36d2b 100644
> --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
> +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
> @@ -1316,7 +1316,7 @@ typedef struct drm_i915_gem_object *
>   
>   static inline bool igt_can_allocate_thp(struct drm_i915_private *i915)
>   {
> -	return i915->mm.gemfs && has_transparent_hugepage();
> +	return i915->mm.gemfs && pgtable_has_pmd_leaves();

On second thought, is it problematic that we might be losing the 
CONFIG_TRANSPARENT_HUGEPAGE check? Should we check for that separately?

-- 
Cheers

David
Re: [RFC 04/10] drivers: i915 selftest: use pgtable_has_pmd_leaves()
Posted by Luiz Capitulino 1 month ago
On 2025-11-17 12:30, David Hildenbrand (Red Hat) wrote:
> On 06.11.25 22:28, Luiz Capitulino wrote:
>> igt_can_allocate_thp() uses has_transparente_hugepage() to check if
>> PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead.
>>
>> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
>> ---
>>   drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>> index bd08605a1611..c76aafa36d2b 100644
>> --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>> +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>> @@ -1316,7 +1316,7 @@ typedef struct drm_i915_gem_object *
>>   static inline bool igt_can_allocate_thp(struct drm_i915_private *i915)
>>   {
>> -    return i915->mm.gemfs && has_transparent_hugepage();
>> +    return i915->mm.gemfs && pgtable_has_pmd_leaves();
> 
> On second thought, is it problematic that we might be losing the CONFIG_TRANSPARENT_HUGEPAGE check? Should we check for that separately?

That's a good point.

In this RFC, pgtable_has_pmd_leaves() should be functionally equivalent
to has_transparent_hugepage() so I think we're good. That beind said, I
also think that we should disentangle pgtable_has_pmd_leaves() from THP
now or in the future. When we do this the breakage you're spotting will
happen.

What about adding thp_has_pmd_support() which does:

   return IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && pgtable_has_pmd_leaves();

Then I can convert all the cases you spotted to thp_has_pmd_support().
Re: [RFC 04/10] drivers: i915 selftest: use pgtable_has_pmd_leaves()
Posted by David Hildenbrand (Red Hat) 2 weeks, 3 days ago
On 11/17/25 19:55, Luiz Capitulino wrote:
> On 2025-11-17 12:30, David Hildenbrand (Red Hat) wrote:
>> On 06.11.25 22:28, Luiz Capitulino wrote:
>>> igt_can_allocate_thp() uses has_transparente_hugepage() to check if
>>> PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead.
>>>
>>> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
>>> ---
>>>    drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>>> index bd08605a1611..c76aafa36d2b 100644
>>> --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>>> +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>>> @@ -1316,7 +1316,7 @@ typedef struct drm_i915_gem_object *
>>>    static inline bool igt_can_allocate_thp(struct drm_i915_private *i915)
>>>    {
>>> -    return i915->mm.gemfs && has_transparent_hugepage();
>>> +    return i915->mm.gemfs && pgtable_has_pmd_leaves();
>>
>> On second thought, is it problematic that we might be losing the CONFIG_TRANSPARENT_HUGEPAGE check? Should we check for that separately?
> 
> That's a good point.
> 
> In this RFC, pgtable_has_pmd_leaves() should be functionally equivalent
> to has_transparent_hugepage() so I think we're good. That beind said, I
> also think that we should disentangle pgtable_has_pmd_leaves() from THP
> now or in the future. When we do this the breakage you're spotting will
> happen.
> 
> What about adding thp_has_pmd_support() which does:
> 
>     return IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && pgtable_has_pmd_leaves();
> 
> Then I can convert all the cases you spotted to thp_has_pmd_support().

I hope we can avoid such a wrapper for the time being. Maybe we can just 
keep pgtable_has_pmd_leaves() glued to CONFIG_TRANSPARENT_HUGEPAGE for 
now, and leave untangling that for the next cleanup?

-- 
Cheers

David
Re: [RFC 04/10] drivers: i915 selftest: use pgtable_has_pmd_leaves()
Posted by Luiz Capitulino 2 weeks, 2 days ago
On 2025-12-02 05:51, David Hildenbrand (Red Hat) wrote:
> On 11/17/25 19:55, Luiz Capitulino wrote:
>> On 2025-11-17 12:30, David Hildenbrand (Red Hat) wrote:
>>> On 06.11.25 22:28, Luiz Capitulino wrote:
>>>> igt_can_allocate_thp() uses has_transparente_hugepage() to check if
>>>> PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead.
>>>>
>>>> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
>>>> ---
>>>>    drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>>>> index bd08605a1611..c76aafa36d2b 100644
>>>> --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>>>> +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c
>>>> @@ -1316,7 +1316,7 @@ typedef struct drm_i915_gem_object *
>>>>    static inline bool igt_can_allocate_thp(struct drm_i915_private *i915)
>>>>    {
>>>> -    return i915->mm.gemfs && has_transparent_hugepage();
>>>> +    return i915->mm.gemfs && pgtable_has_pmd_leaves();
>>>
>>> On second thought, is it problematic that we might be losing the CONFIG_TRANSPARENT_HUGEPAGE check? Should we check for that separately?
>>
>> That's a good point.
>>
>> In this RFC, pgtable_has_pmd_leaves() should be functionally equivalent
>> to has_transparent_hugepage() so I think we're good. That beind said, I
>> also think that we should disentangle pgtable_has_pmd_leaves() from THP
>> now or in the future. When we do this the breakage you're spotting will
>> happen.
>>
>> What about adding thp_has_pmd_support() which does:
>>
>>     return IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && pgtable_has_pmd_leaves();
>>
>> Then I can convert all the cases you spotted to thp_has_pmd_support().
> 
> I hope we can avoid such a wrapper for the time being. Maybe we can just keep pgtable_has_pmd_leaves() glued to CONFIG_TRANSPARENT_HUGEPAGE for now, and leave untangling that for the next cleanup?

OK, I can do that in the v1 posting.

Re: [RFC 04/10] drivers: i915 selftest: use pgtable_has_pmd_leaves()
Posted by David Hildenbrand (Red Hat) 1 month ago
On 06.11.25 22:28, Luiz Capitulino wrote:
> igt_can_allocate_thp() uses has_transparente_hugepage() to check if
> PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead.
> 

Right, I think we really only care about PMDs here for now.

-- 
Cheers

David