Re: [PATCH v4] drm/gem: Make the GEM LRU lock part of drm_device
On Thu, May 21, 2026 at 11:07:32AM +0200, Simona Vetter wrote: > The assumption is that committers will ask maintainers for help if they're > trying to push a patch that results in tons of conflicts when applying > (since development should happen on top of linux-next or drm-tip). Could > probably improve that a bit. But also, often it's only clear after > applying that a fixup is needed, and then it's pushed already. And with > committers there's no undoing pushed patches. So it's just part of the > deal with having lots of committers imo that history is a bit more a mess > at times. What I see frequently in -next is people just cherry picking the fixes into the development branch instead of doing a merge, this leads to pointless conflicts as soon as someone adds new code on top of the fix. I gather the stable people also aren't terribly enthusiastic about this workflow. There also seem to be repeated situations where people mail me saying they're going to introduce a bunch of conflicts that are sufficiently non-obvious they're sending me fixups in whatever random form, even where people seem to think it's a big problem themselves there seems to be a helplessness about actually doing the merge. signature.asc Description: PGP signature
Re: [PATCH v4] drm/gem: Make the GEM LRU lock part of drm_device
On Tue, May 19, 2026 at 01:51:53PM +0200, Boris Brezillon wrote: > On Tue, 19 May 2026 12:37:16 +0100 > Mark Brown wrote: > > > On Mon, May 18, 2026 at 04:52:25PM +0200, Boris Brezillon wrote: > > > +Mark for the silent conflict resolution needed to reconcile > > > drm-misc-fixes and drm-next/drm-misc-next. > > > > This doesn't appear to be a drm-misc thing, I was seeing issues on the > > DRM tree. The patch does seem to ahve resolved things though. Please > > consider topic branches! > > I'm just following the dim guide for resolution of conflicts between > drm trees[1], so that's probably something to discuss with the > DRM/DRM-misc maintainers. As for the suggestion to use topic branches, > I've never heard of it being used for -fixes vs -next conflict > resolution, every time I've gone through this process it was for > xxx-next vs yyy-next conflict (xxx and yyy being different subsystem > trees). > > Maxime, Thomas, Maarteen, Sima and/or Dave, any suggestion/opinion? Yeah, in general we do substantially fewer topic branches than other subsystems. That's fallout from the committer model, which just want a branch to push their patches and be done with it all - they're not full maintainers, we don't magically have more of those. And sometimes that results in more of a mess than necessary. We try to keep the mess in check by doing backmerges as needed, ideally before applying a patch. It's not super well documented since when/how to backmerge is part of the section for maintainers: https://drm.pages.freedesktop.org/maintainer-tools/maintainer/maintainer-drm-misc.html The assumption is that committers will ask maintainers for help if they're trying to push a patch that results in tons of conflicts when applying (since development should happen on top of linux-next or drm-tip). Could probably improve that a bit. But also, often it's only clear after applying that a fixup is needed, and then it's pushed already. And with committers there's no undoing pushed patches. So it's just part of the deal with having lots of committers imo that history is a bit more a mess at times. Cheers, Sima > [1]https://drm.pages.freedesktop.org/maintainer-tools/committer/conflict-resolution.html -- Simona Vetter Software Engineer http://blog.ffwll.ch
Re: [PATCH v4] drm/gem: Make the GEM LRU lock part of drm_device
On Tue, 19 May 2026 12:37:16 +0100 Mark Brown wrote: > On Mon, May 18, 2026 at 04:52:25PM +0200, Boris Brezillon wrote: > > +Mark for the silent conflict resolution needed to reconcile > > drm-misc-fixes and drm-next/drm-misc-next. > > This doesn't appear to be a drm-misc thing, I was seeing issues on the > DRM tree. The patch does seem to ahve resolved things though. Please > consider topic branches! I'm just following the dim guide for resolution of conflicts between drm trees[1], so that's probably something to discuss with the DRM/DRM-misc maintainers. As for the suggestion to use topic branches, I've never heard of it being used for -fixes vs -next conflict resolution, every time I've gone through this process it was for xxx-next vs yyy-next conflict (xxx and yyy being different subsystem trees). Maxime, Thomas, Maarteen, Sima and/or Dave, any suggestion/opinion? [1]https://drm.pages.freedesktop.org/maintainer-tools/committer/conflict-resolution.html
Re: [PATCH v4] drm/gem: Make the GEM LRU lock part of drm_device
On Mon, May 18, 2026 at 04:52:25PM +0200, Boris Brezillon wrote: > +Mark for the silent conflict resolution needed to reconcile > drm-misc-fixes and drm-next/drm-misc-next. This doesn't appear to be a drm-misc thing, I was seeing issues on the DRM tree. The patch does seem to ahve resolved things though. Please consider topic branches! signature.asc Description: PGP signature
Re: [PATCH v4] drm/gem: Make the GEM LRU lock part of drm_device
On Mon, 18 May 2026 16:52:25 +0200
Boris Brezillon wrote:
> +Mark for the silent conflict resolution needed to reconcile
> drm-misc-fixes and drm-next/drm-misc-next.
>
> On Mon, 18 May 2026 13:41:45 +0200
> Boris Brezillon wrote:
>
> > Recently, a few races have been discovered in the GEM LRU logic, all
> > of them caused by the fact the LRU lock is accessed through
> > gem->lru->lock, and that very same lock also protects changes to
> > gem->lru, leading to situations where gem->lru needs to first be
> > accessed without the lock held, to then get the lru to access the lock
> > through and finally take the lock and do the expected operation.
> >
> > Currently, the only driver making use of this API (MSM) declares a
> > device-wide lock, and the user we're about to add (panthor) will
> > do the same. There's no evidence that we will ever have a driver
> > that wants different pools of LRUs protected by different locks under
> > the same drm_device. So we're better off moving this lock to drm_device
> > and always locking it through obj->dev->gem_lru_mutex, or directly
> > through dev->gem_lru_mutex.
> >
> > If anyone ever needs more fine-grained locking, this can be revisited
> > to pass some drm_gem_lru_pool object representing the pool of LRUs
> > under a specific lock, but for now, the per-device lock seems to be
> > enough.
> >
> > Fixes: e7c2af13f811 ("drm/gem: Add LRU/shrinker helper")
> > Reported-by: Chia-I Wu
> > Closes: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/86
> > Reviewed-by: Rob Clark
> > Reviewed-by: Liviu Dudau
> > Reviewed-by: Steven Price
> > Reviewed-by: Chia-I Wu
> > Signed-off-by: Boris Brezillon
>
> Queued to drm-misc-next.
s/drm-misc-next/drm-misc-fixes/, sorry for the typo.
>
> Note for the linux-next maintainers: below is the conflict
> resolution currently stored in drm-tip.
>
> Note for the drm-misc maintainers: we'll need a backmerge of the
> next -rc into drm-misc-next so we can resolve the conflict there.
>
> --->8---
> diff --git a/drivers/gpu/drm/panthor/panthor_device.h
> b/drivers/gpu/drm/panthor/panthor_device.h
> index 4e4607bca7cc..a412a50eec76 100644
> --- a/drivers/gpu/drm/panthor/panthor_device.h
> +++ b/drivers/gpu/drm/panthor/panthor_device.h
> @@ -187,9 +187,6 @@ struct panthor_device {
> /** @reclaim.shrinker: Shrinker instance */
> struct shrinker *shrinker;
>
> - /** @reclaim.lock: Lock protecting all LRUs */
> - struct mutex lock;
> -
> /**
>* @reclaim.unused: BOs with unused pages
>*
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.c
> b/drivers/gpu/drm/panthor/panthor_gem.c
> index 13295d7a593d..abe0c5bb1bca 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.c
> +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> @@ -1495,13 +1495,13 @@ panthor_gem_shrinker_scan(struct shrinker *shrinker,
> struct shrink_control *sc)
> if (!can_swap())
> goto out;
>
> - freed += drm_gem_lru_scan(&ptdev->reclaim.unused,
> + freed += drm_gem_lru_scan(&ptdev->base, &ptdev->reclaim.unused,
> sc->nr_to_scan - freed, &remaining,
> panthor_gem_try_evict_no_resv_wait, NULL);
> if (freed >= sc->nr_to_scan)
> goto out;
>
> - freed += drm_gem_lru_scan(&ptdev->reclaim.mmapped,
> + freed += drm_gem_lru_scan(&ptdev->base, &ptdev->reclaim.mmapped,
> sc->nr_to_scan - freed, &remaining,
> panthor_gem_try_evict_no_resv_wait, NULL);
> if (freed >= sc->nr_to_scan)
> @@ -1515,7 +1515,7 @@ panthor_gem_shrinker_scan(struct shrinker *shrinker,
> struct shrink_control *sc)
> if (freed >= sc->nr_to_scan)
> goto out;
>
> - freed += drm_gem_lru_scan(&ptdev->reclaim.gpu_mapped_shared,
> + freed += drm_gem_lru_scan(&ptdev->base,
> &ptdev->reclaim.gpu_mapped_shared,
> sc->nr_to_scan - freed, &remaining,
> panthor_gem_try_evict, NULL);
>
> @@ -1544,21 +1544,16 @@ panthor_gem_shrinker_scan(struct shrinker *shrinker,
> struct shrink_control *sc)
> int panthor_gem_shrinker_init(struct panthor_device *ptdev)
> {
> struct shrinker *shrinker;
> - int ret;
> -
> - ret = drmm_mutex_init(&ptdev->base, &ptdev->reclaim.lock);
> - if (ret)
> - return ret;
>
> INIT_LIST_HEAD(&ptdev->reclaim.vms);
> - drm_gem_lru_init(&ptdev->reclaim.unused, &ptdev->reclaim.lock);
> - drm_gem_lru_init(&ptdev->reclaim.mmapped, &ptdev->reclaim.lock);
> - drm_gem_lru_init(&ptdev->reclaim.gpu_mapped_shared,
> &ptdev->reclaim.lock);
> + drm_gem_lru_init(&ptdev->reclaim.unused);
> + drm_gem_lru_init(&ptdev->reclaim.mmapped);
> + drm_gem_lru_init(&ptdev->reclaim.gpu_mapped_shared);
> ptdev->reclaim.gpu_mapped_count = 0;
>
> /* Teach
Re: [PATCH v4] drm/gem: Make the GEM LRU lock part of drm_device
+Mark for the silent conflict resolution needed to reconcile
drm-misc-fixes and drm-next/drm-misc-next.
On Mon, 18 May 2026 13:41:45 +0200
Boris Brezillon wrote:
> Recently, a few races have been discovered in the GEM LRU logic, all
> of them caused by the fact the LRU lock is accessed through
> gem->lru->lock, and that very same lock also protects changes to
> gem->lru, leading to situations where gem->lru needs to first be
> accessed without the lock held, to then get the lru to access the lock
> through and finally take the lock and do the expected operation.
>
> Currently, the only driver making use of this API (MSM) declares a
> device-wide lock, and the user we're about to add (panthor) will
> do the same. There's no evidence that we will ever have a driver
> that wants different pools of LRUs protected by different locks under
> the same drm_device. So we're better off moving this lock to drm_device
> and always locking it through obj->dev->gem_lru_mutex, or directly
> through dev->gem_lru_mutex.
>
> If anyone ever needs more fine-grained locking, this can be revisited
> to pass some drm_gem_lru_pool object representing the pool of LRUs
> under a specific lock, but for now, the per-device lock seems to be
> enough.
>
> Fixes: e7c2af13f811 ("drm/gem: Add LRU/shrinker helper")
> Reported-by: Chia-I Wu
> Closes: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/86
> Reviewed-by: Rob Clark
> Reviewed-by: Liviu Dudau
> Reviewed-by: Steven Price
> Reviewed-by: Chia-I Wu
> Signed-off-by: Boris Brezillon
Queued to drm-misc-next.
Note for the linux-next maintainers: below is the conflict
resolution currently stored in drm-tip.
Note for the drm-misc maintainers: we'll need a backmerge of the
next -rc into drm-misc-next so we can resolve the conflict there.
--->8---
diff --git a/drivers/gpu/drm/panthor/panthor_device.h
b/drivers/gpu/drm/panthor/panthor_device.h
index 4e4607bca7cc..a412a50eec76 100644
--- a/drivers/gpu/drm/panthor/panthor_device.h
+++ b/drivers/gpu/drm/panthor/panthor_device.h
@@ -187,9 +187,6 @@ struct panthor_device {
/** @reclaim.shrinker: Shrinker instance */
struct shrinker *shrinker;
- /** @reclaim.lock: Lock protecting all LRUs */
- struct mutex lock;
-
/**
* @reclaim.unused: BOs with unused pages
*
diff --git a/drivers/gpu/drm/panthor/panthor_gem.c
b/drivers/gpu/drm/panthor/panthor_gem.c
index 13295d7a593d..abe0c5bb1bca 100644
--- a/drivers/gpu/drm/panthor/panthor_gem.c
+++ b/drivers/gpu/drm/panthor/panthor_gem.c
@@ -1495,13 +1495,13 @@ panthor_gem_shrinker_scan(struct shrinker *shrinker,
struct shrink_control *sc)
if (!can_swap())
goto out;
- freed += drm_gem_lru_scan(&ptdev->reclaim.unused,
+ freed += drm_gem_lru_scan(&ptdev->base, &ptdev->reclaim.unused,
sc->nr_to_scan - freed, &remaining,
panthor_gem_try_evict_no_resv_wait, NULL);
if (freed >= sc->nr_to_scan)
goto out;
- freed += drm_gem_lru_scan(&ptdev->reclaim.mmapped,
+ freed += drm_gem_lru_scan(&ptdev->base, &ptdev->reclaim.mmapped,
sc->nr_to_scan - freed, &remaining,
panthor_gem_try_evict_no_resv_wait, NULL);
if (freed >= sc->nr_to_scan)
@@ -1515,7 +1515,7 @@ panthor_gem_shrinker_scan(struct shrinker *shrinker,
struct shrink_control *sc)
if (freed >= sc->nr_to_scan)
goto out;
- freed += drm_gem_lru_scan(&ptdev->reclaim.gpu_mapped_shared,
+ freed += drm_gem_lru_scan(&ptdev->base,
&ptdev->reclaim.gpu_mapped_shared,
sc->nr_to_scan - freed, &remaining,
panthor_gem_try_evict, NULL);
@@ -1544,21 +1544,16 @@ panthor_gem_shrinker_scan(struct shrinker *shrinker,
struct shrink_control *sc)
int panthor_gem_shrinker_init(struct panthor_device *ptdev)
{
struct shrinker *shrinker;
- int ret;
-
- ret = drmm_mutex_init(&ptdev->base, &ptdev->reclaim.lock);
- if (ret)
- return ret;
INIT_LIST_HEAD(&ptdev->reclaim.vms);
- drm_gem_lru_init(&ptdev->reclaim.unused, &ptdev->reclaim.lock);
- drm_gem_lru_init(&ptdev->reclaim.mmapped, &ptdev->reclaim.lock);
- drm_gem_lru_init(&ptdev->reclaim.gpu_mapped_shared,
&ptdev->reclaim.lock);
+ drm_gem_lru_init(&ptdev->reclaim.unused);
+ drm_gem_lru_init(&ptdev->reclaim.mmapped);
+ drm_gem_lru_init(&ptdev->reclaim.gpu_mapped_shared);
ptdev->reclaim.gpu_mapped_count = 0;
/* Teach lockdep about lock ordering wrt. shrinker: */
fs_reclaim_acquire(GFP_KERNEL);
- might_lock(&ptdev->reclaim.lock);
+ might_lock(&ptdev->base.gem_lru_mutex);
fs_reclaim_release(GFP_KERNEL);
shrinker = shrinker_alloc(0,
