Return number of freed pages in uvm_pmr_cache_drain().
authormpi <mpi@openbsd.org>
Wed, 2 Oct 2024 10:17:28 +0000 (10:17 +0000)
committermpi <mpi@openbsd.org>
Wed, 2 Oct 2024 10:17:28 +0000 (10:17 +0000)
ok kettenis@

sys/uvm/uvm_pmemrange.c
sys/uvm/uvm_pmemrange.h

index 0830fd4..66ecab5 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uvm_pmemrange.c,v 1.67 2024/08/18 08:18:49 mpi Exp $  */
+/*     $OpenBSD: uvm_pmemrange.c,v 1.68 2024/10/02 10:17:28 mpi Exp $  */
 
 /*
  * Copyright (c) 2024 Martin Pieuchot <mpi@openbsd.org>
@@ -2279,7 +2279,7 @@ uvm_pmr_cache_get(int flags)
        return pg;
 }
 
-void
+unsigned int
 uvm_pmr_cache_free(struct uvm_pmr_cache_item *upci)
 {
        struct pglist pgl;
@@ -2296,6 +2296,8 @@ uvm_pmr_cache_free(struct uvm_pmr_cache_item *upci)
        atomic_sub_int(&uvmexp.percpucaches, upci->upci_npages);
        upci->upci_npages = 0;
        memset(upci->upci_pages, 0, sizeof(upci->upci_pages));
+
+       return i;
 }
 
 void
@@ -2337,16 +2339,19 @@ uvm_pmr_cache_put(struct vm_page *pg)
        splx(s);
 }
 
-void
+unsigned int
 uvm_pmr_cache_drain(void)
 {
        struct uvm_pmr_cache *upc = &curcpu()->ci_uvm;
+       unsigned int freed = 0;
        int s;
 
        s = splvm();
-       uvm_pmr_cache_free(&upc->upc_magz[0]);
-       uvm_pmr_cache_free(&upc->upc_magz[1]);
+       freed += uvm_pmr_cache_free(&upc->upc_magz[0]);
+       freed += uvm_pmr_cache_free(&upc->upc_magz[1]);
        splx(s);
+
+       return freed;
 }
 
 #else /* !(MULTIPROCESSOR && __HAVE_UVM_PERCPU) */
@@ -2363,8 +2368,9 @@ uvm_pmr_cache_put(struct vm_page *pg)
        uvm_pmr_freepages(pg, 1);
 }
 
-void
+unsigned int
 uvm_pmr_cache_drain(void)
 {
+       return 0;
 }
 #endif
index 45912df..3a06d60 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uvm_pmemrange.h,v 1.17 2024/05/01 12:54:27 mpi Exp $  */
+/*     $OpenBSD: uvm_pmemrange.h,v 1.18 2024/10/02 10:17:28 mpi Exp $  */
 
 /*
  * Copyright (c) 2009 Ariane van der Steldt <ariane@stack.nl>
@@ -149,7 +149,7 @@ struct vm_page              *uvm_pmr_extract_range(struct uvm_pmemrange *,
                            struct pglist *);
 struct vm_page         *uvm_pmr_cache_get(int);
 void                    uvm_pmr_cache_put(struct vm_page *);
-void                    uvm_pmr_cache_drain(void);
+unsigned int            uvm_pmr_cache_drain(void);
 
 
 #endif /* _UVM_UVM_PMEMRANGE_H_ */