Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/uvm In the current code, CPU_COUNT_FREEPAGES counts page...



details:   https://anonhg.NetBSD.org/src/rev/8293ba3668c8
branches:  trunk
changeset: 941098:8293ba3668c8
user:      chs <chs%NetBSD.org@localhost>
date:      Sun Oct 18 18:31:31 2020 +0000

description:
In the current code, CPU_COUNT_FREEPAGES counts pages in the global
freelists AND the per-CPU pgflcache free pages caches, and that is the
number of pages that the pagedaemon considers to be available.
However, most pages in the pgflcache per-CPU free page caches are NOT
actually available for any particular allocation, and thus allocating
a page can fail even though the pagedaemon thinks enough pages are
available.  This change makes CPU_COUNT_FREEPAGES only count pages in
the global freelists and not pages in the pgflcache per-CPU free page
caches, thus better aligning the pagedaemon's view of how many pages
are available with the number of pages that can actually be allocated
by any particular request.  This fixes a hang that Christos was hitting.

diffstat:

 sys/uvm/uvm_page.c      |  8 ++++----
 sys/uvm/uvm_pgflcache.c |  6 ++++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diffs (84 lines):

diff -r 6ad65696df13 -r 8293ba3668c8 sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Sun Oct 18 18:22:29 2020 +0000
+++ b/sys/uvm/uvm_page.c        Sun Oct 18 18:31:31 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.248 2020/10/18 18:22:29 chs Exp $       */
+/*     $NetBSD: uvm_page.c,v 1.249 2020/10/18 18:31:31 chs Exp $       */
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.248 2020/10/18 18:22:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.249 2020/10/18 18:31:31 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvm.h"
@@ -1069,6 +1069,7 @@
                        KASSERT(pg->flags == PG_FREE);
                        pg->flags = PG_BUSY | PG_CLEAN | PG_FAKE;
                        pgb->pgb_nfree--;
+                       CPU_COUNT(CPU_COUNT_FREEPAGES, -1);
 
                        /*
                         * While we have the bucket locked and our data
@@ -1270,7 +1271,6 @@
         * while still at IPL_VM, update allocation statistics.
         */
 
-       CPU_COUNT(CPU_COUNT_FREEPAGES, -1);
        if (anon) {
                CPU_COUNT(CPU_COUNT_ANONCLEAN, 1);
        }
@@ -1567,7 +1567,6 @@
 
        /* Try to send the page to the per-CPU cache. */
        s = splvm();
-       CPU_COUNT(CPU_COUNT_FREEPAGES, 1);
        ucpu = curcpu()->ci_data.cpu_uvm;
        bucket = uvm_page_get_bucket(pg);
        if (bucket == ucpu->pgflbucket && uvm_pgflcache_free(ucpu, pg)) {
@@ -1585,6 +1584,7 @@
        pg->flags = PG_FREE;
        LIST_INSERT_HEAD(&pgb->pgb_colors[VM_PGCOLOR(pg)], pg, pageq.list);
        pgb->pgb_nfree++;
+       CPU_COUNT(CPU_COUNT_FREEPAGES, 1);
        mutex_spin_exit(lock);
        splx(s);
 }
diff -r 6ad65696df13 -r 8293ba3668c8 sys/uvm/uvm_pgflcache.c
--- a/sys/uvm/uvm_pgflcache.c   Sun Oct 18 18:22:29 2020 +0000
+++ b/sys/uvm/uvm_pgflcache.c   Sun Oct 18 18:31:31 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_pgflcache.c,v 1.5 2020/06/14 21:41:42 ad Exp $     */
+/*     $NetBSD: uvm_pgflcache.c,v 1.6 2020/10/18 18:31:31 chs Exp $    */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_pgflcache.c,v 1.5 2020/06/14 21:41:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pgflcache.c,v 1.6 2020/10/18 18:31:31 chs Exp $");
 
 #include "opt_uvm.h"
 #include "opt_multiprocessor.h"
@@ -151,6 +151,7 @@
                pg->pageq.list.le_prev = &head->lh_first;
        }
        pgb->pgb_nfree -= (count - pcc->count);
+       CPU_COUNT(CPU_COUNT_FREEPAGES, -(count - pcc->count));
        pcc->count = count;
 }
 
@@ -188,6 +189,7 @@
                LIST_INSERT_HEAD(head, pcc->pages[pcc->count], pageq.list);
        }
        pgb->pgb_nfree += adj;
+       CPU_COUNT(CPU_COUNT_FREEPAGES, adj);
        mutex_spin_exit(lock);
 }
 



Home | Main Index | Thread Index | Old Index