* [PATCH] drm/i915/userptr: Convert page APIs to folio equivalents in put_pages
@ 2026-07-23 6:46 Hongfu Li
2026-10-29 13:46 ` Tal Zussman
0 siblings, 1 reply; 3+ messages in thread
From: Hongfu Li @ 2026-07-23 6:46 UTC (permalink / raw)
To: jani.nikula, joonas.lahtinen, rodrigo.vivi, tursulin, airlied,
simona, kees, tzimmermann
Cc: intel-gfx, dri-devel, linux-kernel, hongfu.li, Hongfu Li
From: Hongfu Li <lihongfu@kylinos.cn>
Cache the folio with page_folio() at the start of the sg_table loop,
then use folio helpers directly to eliminate repeated compound_head()
lookups inside page API wrappers.
Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
---
drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index 043095f93ac6..0ae68c52cc12 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
@@ -160,6 +160,7 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
struct sg_table *pages)
{
struct sgt_iter sgt_iter;
struct page *page;
+ struct folio *folio;
if (!pages)
@@ -177,7 +178,9 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
obj->mm.dirty = false;
for_each_sgt_page(page, sgt_iter, pages) {
- if (obj->mm.dirty && trylock_page(page)) {
+ folio = page_folio(page);
+
+ if (obj->mm.dirty && folio_trylock(folio)) {
/*
* As this may not be anonymous memory (e.g. shmem)
* but exist on a real mapping, we have to lock
@@ -193,14 +196,14 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object *obj,
* on the folio. Such a try_to_unmap() will result
* in us calling put_pages() and so recursively try
* to lock the page. We avoid that deadlock with
- * a trylock_page() and in exchange we risk missing
+ * a folio_trylock() and in exchange we risk missing
* some page dirtying.
*/
- set_page_dirty(page);
- unlock_page(page);
+ folio_mark_dirty(folio);
+ folio_unlock(folio);
}
- mark_page_accessed(page);
+ folio_mark_accessed(folio);
}
obj->mm.dirty = false;
--
2.54.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/i915/userptr: Convert page APIs to folio equivalents in put_pages
2026-07-23 6:46 [PATCH] drm/i915/userptr: Convert page APIs to folio equivalents in put_pages Hongfu Li
@ 2026-10-29 13:46 ` Tal Zussman
2026-10-30 3:06 ` Hongfu Li
0 siblings, 1 reply; 3+ messages in thread
From: Tal Zussman @ 2026-10-29 13:46 UTC (permalink / raw)
To: Hongfu Li, Hongfu Li
Cc: jani.nikula, joonas.lahtinen, rodrigo.vivi, tursulin, airlied,
simona, kees, tzimmermann, intel-gfx, dri-devel, linux-kernel,
tz2294
On Thu, Jul 23, 2026 at 02:46:51PM +0800, Hongfu Li wrote:
> From: Hongfu Li <lihongfu@kylinos.cn>
>
> Cache the folio with page_folio() at the start of the sg_table loop,
> then use folio helpers directly to eliminate repeated compound_head()
> lookups inside page API wrappers.
>
> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
Hi,
Is there any update on picking this up? It would be great to get this
in, as it removes the last user of trylock_page() in the tree.
Thanks,
Tal
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/i915/userptr: Convert page APIs to folio equivalents in put_pages
2026-10-29 13:46 ` Tal Zussman
@ 2026-10-30 3:06 ` Hongfu Li
0 siblings, 0 replies; 3+ messages in thread
From: Hongfu Li @ 2026-10-30 3:06 UTC (permalink / raw)
To: Tal Zussman, Hongfu Li
Cc: hongfu.li, jani.nikula, joonas.lahtinen, rodrigo.vivi, tursulin,
airlied, simona, kees, tzimmermann, intel-gfx, dri-devel,
linux-kernel
On 10/29/26 9:46 PM, Tal Zussman wrote:
> On Thu, Jul 23, 2026 at 02:46:51PM +0800, Hongfu Li wrote:
>> From: Hongfu Li <lihongfu@kylinos.cn>
>>
>> Cache the folio with page_folio() at the start of the sg_table loop,
>> then use folio helpers directly to eliminate repeated compound_head()
>> lookups inside page API wrappers.
>>
>> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
> Hi,
>
> Is there any update on picking this up? It would be great to get this
> in, as it removes the last user of trylock_page() in the tree.
Hi Tal,
You are right, this one never got picked up. I have not received any
review comments on it. It is not abandoned on my side, and if there is
anything that needs fixing, I am happy to send a v2.
> Thanks,
> Tal
--
Best regards,
Hongfu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-30 3:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-23 6:46 [PATCH] drm/i915/userptr: Convert page APIs to folio equivalents in put_pages Hongfu Li
2026-10-29 13:46 ` Tal Zussman
2026-10-30 3:06 ` Hongfu Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®