On Wed, Nov 27, 2019 at 05:18:32PM +0100, Mark Kettenis wrote:
> The inteldrm(4) driver keeps a cache of graphics objects, allegedly to
> make things faster by avoiding cache flushes. But those graphics
> objects consume memory that we want to free if we need it for
> something else.
>
> The diff below hooks up the "shrinker" code in inteldrm(4) and calls
> it from the pagedeamon if it thinks it needs to free up memory.
>
> The diff still has some debug printfs such that we can tell that the
> code is actually called.
>
> Please test if you have inteldrm(4), esepcially on machines with
> limited amounts of physical memory.
unregister_shrinker() coming as well?
Here is an additional ttm diff for radeondrm/amdgpu.
Index: dev/pci/drm/ttm/ttm_page_alloc.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/drm/ttm/ttm_page_alloc.c,v
retrieving revision 1.16
diff -u -p -r1.16 ttm_page_alloc.c
--- dev/pci/drm/ttm/ttm_page_alloc.c 27 Apr 2019 08:10:32 -0000 1.16
+++ dev/pci/drm/ttm/ttm_page_alloc.c 28 Nov 2019 10:37:09 -0000
@@ -107,9 +107,7 @@ struct ttm_pool_opts {
**/
struct ttm_pool_manager {
struct kobject kobj;
-#ifdef notyet
struct shrinker mm_shrink;
-#endif
struct ttm_pool_opts options;
union {
@@ -388,7 +386,6 @@ out:
*
* This code is crying out for a shrinker per pool....
*/
-#ifdef notyet
static unsigned long
ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
{
@@ -441,17 +438,13 @@ ttm_pool_shrink_count(struct shrinker *s
return count;
}
-#endif
static int ttm_pool_mm_shrink_init(struct ttm_pool_manager *manager)
{
-#ifdef notyet
manager->mm_shrink.count_objects = ttm_pool_shrink_count;
manager->mm_shrink.scan_objects = ttm_pool_shrink_scan;
manager->mm_shrink.seeks = 1;
return register_shrinker(&manager->mm_shrink);
-#endif
- return 0;
}
static void ttm_pool_mm_shrink_fini(struct ttm_pool_manager *manager)