From f77ca71313a77887dfd289f107782b579be08517 Mon Sep 17 00:00:00 2001 From: skrll Date: Thu, 9 May 2019 08:16:14 +0000 Subject: [PATCH] Avoid KASSERT(!cpu_intr_p()) when breaking into ddb and issuing show uvmexp --- sys/kern/subr_pool.c | 17 +++++++++++++---- sys/sys/pool.h | 3 ++- sys/uvm/uvm_stat.c | 6 +++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index 8f23be71e295..a7fc024f26eb 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.249 2019/04/13 08:41:36 maxv Exp $ */ +/* $NetBSD: subr_pool.c,v 1.250 2019/05/09 08:16:14 skrll Exp $ */ /* * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018 @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.249 2019/04/13 08:41:36 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.250 2019/05/09 08:16:14 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1634,11 +1634,21 @@ pool_drain(struct pool **ppp) */ int pool_totalpages(void) +{ + + mutex_enter(&pool_head_lock); + int pages = pool_totalpages_locked(); + mutex_exit(&pool_head_lock); + + return pages; +} + +int +pool_totalpages_locked(void) { struct pool *pp; uint64_t total = 0; - mutex_enter(&pool_head_lock); TAILQ_FOREACH(pp, &pool_head, pr_poollist) { uint64_t bytes = pp->pr_npages * pp->pr_alloc->pa_pagesz; @@ -1646,7 +1656,6 @@ pool_totalpages(void) bytes -= (pp->pr_nout * pp->pr_size); total += bytes; } - mutex_exit(&pool_head_lock); return atop(total); } diff --git a/sys/sys/pool.h b/sys/sys/pool.h index 9a63a0e422f1..552f12a399b9 100644 --- a/sys/sys/pool.h +++ b/sys/sys/pool.h @@ -1,4 +1,4 @@ -/* $NetBSD: pool.h,v 1.88 2019/04/13 08:41:37 maxv Exp $ */ +/* $NetBSD: pool.h,v 1.89 2019/05/09 08:16:15 skrll Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2000, 2007 The NetBSD Foundation, Inc. @@ -320,6 +320,7 @@ void pool_sethiwat(struct pool *, int); void pool_sethardlimit(struct pool *, int, const char *, int); bool pool_drain(struct pool **); int pool_totalpages(void); +int pool_totalpages_locked(void); /* * Debugging and diagnostic aides. diff --git a/sys/uvm/uvm_stat.c b/sys/uvm/uvm_stat.c index e765d5bf0a32..487a604b1370 100644 --- a/sys/uvm/uvm_stat.c +++ b/sys/uvm/uvm_stat.c @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_stat.c,v 1.39 2017/12/02 08:15:43 mrg Exp $ */ +/* $NetBSD: uvm_stat.c,v 1.40 2019/05/09 08:16:15 skrll Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.39 2017/12/02 08:15:43 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.40 2019/05/09 08:16:15 skrll Exp $"); #include "opt_readahead.h" #include "opt_ddb.h" @@ -61,7 +61,7 @@ uvmexp_print(void (*pr)(const char *, ...) struct cpu_info *ci; uvm_estimatepageable(&active, &inactive); - poolpages = pool_totalpages(); + poolpages = pool_totalpages_locked(); (*pr)("Current UVM status:\n"); (*pr)(" pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d, ncolors=%d\n",