Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-08 Thread Dmitry Osipenko
On 10/3/23 12:00, Boris Brezillon wrote: >> I'd prefer to keep refcounting as is, don't see how to implement your >> suggestion. > Can you be more specific? I don't really see what the problem is with > decrementing pages_use_count when you free the sgt (eviction), and > re-incrementing it when the

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-05 Thread Dmitry Osipenko
On 10/3/23 14:09, Boris Brezillon wrote: > Unmap tends to refer to a VM related operation (removing a mapping in > the CPU or GPU VM), so it's confusing too IMHO. What we do here is > return pages to the shmem file logic, so they can be reclaimed. > > Given the drm_gem function doing that is calle

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-03 Thread Boris Brezillon
On Mon, 2 Oct 2023 22:28:13 +0300 Dmitry Osipenko wrote: > On 9/26/23 10:35, Boris Brezillon wrote: > >> On 9/15/23 11:46, Boris Brezillon wrote: > >>> The naming becomes quite confusing, with drm_gem_shmem_unpin_locked() > >>> and drm_gem_shmem_unpin_pages_locked(). By the look of it, it seems

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-03 Thread Boris Brezillon
Hello Dmitry, On Tue, 3 Oct 2023 03:31:32 +0300 Dmitry Osipenko wrote: > On 9/26/23 10:35, Boris Brezillon wrote: > +__drm_gem_shmem_release_pages(shmem); > >>> Make sure you drop the implicit pages_use_count ref the sgt had, this > >>> way you can still tie the necessity to dro

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-02 Thread Dmitry Osipenko
On 9/26/23 10:35, Boris Brezillon wrote: + __drm_gem_shmem_release_pages(shmem); >>> Make sure you drop the implicit pages_use_count ref the sgt had, this >>> way you can still tie the necessity to drop the pages to sgt != NULL in >>> drm_gem_shmem_free(). >> This will require further ref

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-10-02 Thread Dmitry Osipenko
On 9/26/23 10:35, Boris Brezillon wrote: >> On 9/15/23 11:46, Boris Brezillon wrote: >>> The naming becomes quite confusing, with drm_gem_shmem_unpin_locked() >>> and drm_gem_shmem_unpin_pages_locked(). By the look of it, it seems to >>> do exactly the opposite of drm_gem_shmem_swapin_locked(), exc

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-26 Thread Boris Brezillon
On Tue, 26 Sep 2023 03:37:22 +0300 Dmitry Osipenko wrote: > On 9/15/23 11:46, Boris Brezillon wrote: > >> -static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object > >> *shmem) > >> +static int > >> +drm_gem_shmem_acquire_pages(struct drm_gem_shmem_object *shmem, bool init) > >> {

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-26 Thread Boris Brezillon
On Tue, 26 Sep 2023 03:30:35 +0300 Dmitry Osipenko wrote: > On 9/15/23 11:46, Boris Brezillon wrote: > > The naming becomes quite confusing, with drm_gem_shmem_unpin_locked() > > and drm_gem_shmem_unpin_pages_locked(). By the look of it, it seems to > > do exactly the opposite of drm_gem_shmem_sw

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-25 Thread Dmitry Osipenko
On 9/15/23 11:46, Boris Brezillon wrote: >> -static int drm_gem_shmem_get_pages_locked(struct drm_gem_shmem_object >> *shmem) >> +static int >> +drm_gem_shmem_acquire_pages(struct drm_gem_shmem_object *shmem, bool init) >> { >> struct drm_gem_object *obj = &shmem->base; >> struct page *

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-25 Thread Dmitry Osipenko
On 9/15/23 11:46, Boris Brezillon wrote: > The naming becomes quite confusing, with drm_gem_shmem_unpin_locked() > and drm_gem_shmem_unpin_pages_locked(). By the look of it, it seems to > do exactly the opposite of drm_gem_shmem_swapin_locked(), except for > the missing ->evicted = true, which we c

Re: [PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-15 Thread Boris Brezillon
On Fri, 15 Sep 2023 02:27:16 +0300 Dmitry Osipenko wrote: > Introduce common drm-shmem shrinker for DRM drivers. > > To start using drm-shmem shrinker drivers should do the following: > > 1. Implement evict() callback of GEM object where driver should check >whether object is purgeable or e

[PATCH v17 13/18] drm/shmem-helper: Add memory shrinker

2023-09-14 Thread Dmitry Osipenko
Introduce common drm-shmem shrinker for DRM drivers. To start using drm-shmem shrinker drivers should do the following: 1. Implement evict() callback of GEM object where driver should check whether object is purgeable or evictable using drm-shmem helpers and perform the shrinking action 2.