From 789ce988665d6ccf785190de9175a06ff4d34174 Mon Sep 17 00:00:00 2001 From: mpi Date: Mon, 30 Sep 2024 08:09:39 +0000 Subject: [PATCH] Return the number of freed pages and handle SHRINK_STOP in drmbackoff(). ok jsg@ --- sys/dev/pci/drm/drm_linux.c | 11 ++++++++--- sys/uvm/uvm_pdaemon.c | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index b914a9eba94..f7a7a106e32 100644 --- a/sys/dev/pci/drm/drm_linux.c +++ b/sys/dev/pci/drm/drm_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.c,v 1.116 2024/09/30 03:55:46 jsg Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.117 2024/09/30 08:09:39 mpi Exp $ */ /* * Copyright (c) 2013 Jonathan Gray * Copyright (c) 2015, 2016 Mark Kettenis @@ -2942,20 +2942,25 @@ unregister_shrinker(struct shrinker *shrinker) TAILQ_REMOVE(&shrinkers, shrinker, next); } -void +unsigned long drmbackoff(long npages) { struct shrink_control sc; struct shrinker *shrinker; - u_long ret; + u_long ret, freed = 0; shrinker = TAILQ_FIRST(&shrinkers); while (shrinker && npages > 0) { sc.nr_to_scan = npages; ret = shrinker->scan_objects(shrinker, &sc); + if (ret == SHRINK_STOP) + break; npages -= ret; + freed += ret; shrinker = TAILQ_NEXT(shrinker, next); } + + return freed; } void * diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 700d4206ed2..be32a5ab635 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.114 2024/05/01 12:54:27 mpi Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.115 2024/09/30 08:09:39 mpi Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -84,7 +84,7 @@ #include "drm.h" #if NDRM > 0 -extern void drmbackoff(long); +extern unsigned long drmbackoff(long); #endif /* -- 2.20.1