Source-Changes-HG archive

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

[src/trunk]: src/sys/kern make the KASSERTMSG/panic strings consistent as '%s...



details:   https://anonhg.NetBSD.org/src/rev/6f209624460a
branches:  trunk
changeset: 357402:6f209624460a
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 09 15:53:40 2017 +0000

description:
make the KASSERTMSG/panic strings consistent as '%s: [%s], __func__, wchan'

diffstat:

 sys/kern/subr_pool.c |  60 ++++++++++++++++++++++++++--------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)

diffs (184 lines):

diff -r 6f8930d3e28a -r 6f209624460a sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c      Thu Nov 09 15:46:48 2017 +0000
+++ b/sys/kern/subr_pool.c      Thu Nov 09 15:53:40 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pool.c,v 1.212 2017/11/09 15:40:23 christos Exp $ */
+/*     $NetBSD: subr_pool.c,v 1.213 2017/11/09 15:53:40 christos Exp $ */
 
 /*-
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.212 2017/11/09 15:40:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.213 2017/11/09 15:53:40 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -487,7 +487,7 @@
         */
        TAILQ_FOREACH(pp1, &pool_head, pr_poollist) {
                if (pp == pp1)
-                       panic("pool_init: pool %s already initialised",
+                       panic("%s: [%s] already initialised", __func__,
                            wchan);
        }
        if (__predict_true(!cold))
@@ -528,8 +528,8 @@
 
        prsize = roundup(prsize, align);
        KASSERTMSG((prsize <= palloc->pa_pagesz),
-           "pool_init: pool item size (%zu) larger than page size (%u)",
-           prsize, palloc->pa_pagesz);
+           "%s: [%s] pool item size (%zu) larger than page size (%u)",
+           __func__, wchan, prsize, palloc->pa_pagesz);
 
        /*
         * Initialize the pool structure.
@@ -612,7 +612,8 @@
                         * if you see this panic, consider to tweak
                         * PHPOOL_MAX and PHPOOL_FREELIST_NELEM.
                         */
-                       panic("%s: too large itemsperpage(%d) for PR_NOTOUCH",
+                       panic("%s: [%s] too large itemsperpage(%d) for "
+                           "PR_NOTOUCH", __func__,
                            pp->pr_wchan, pp->pr_itemsperpage);
                }
                pp->pr_phpool = &phpool[idx];
@@ -700,7 +701,7 @@
 
        KASSERT(pp->pr_cache == NULL);
        KASSERTMSG((pp->pr_nout == 0),
-           "pool_destroy: pool busy: still out: %u", pp->pr_nout);
+           "%s: pool busy: still out: %u", __func__, pp->pr_nout);
        KASSERT(LIST_EMPTY(&pp->pr_fullpages));
        KASSERT(LIST_EMPTY(&pp->pr_partpages));
 
@@ -722,7 +723,7 @@
 
        /* XXX no locking -- must be used just after pool_init() */
        KASSERTMSG((pp->pr_drain_hook == NULL),
-           "pool_set_drain_hook(%s): already set", pp->pr_wchan);
+           "%s: [%s] already set", __func__, pp->pr_wchan);
        pp->pr_drain_hook = fn;
        pp->pr_drain_hook_arg = arg;
 }
@@ -733,7 +734,7 @@
        struct pool_item_header *ph;
 
        if ((pp->pr_roflags & PR_PHINPAGE) != 0)
-               ph = (struct pool_item_header *) ((char *)storage + pp->pr_phoffset);
+               ph = (void *)((char *)storage + pp->pr_phoffset);
        else
                ph = pool_get(pp->pr_phpool, flags);
 
@@ -751,12 +752,12 @@
        void *v;
 
        KASSERTMSG((pp->pr_itemsperpage != 0),
-           "pool_get: pool '%s': pr_itemsperpage is zero, "
-           "pool not initialized?", pp->pr_wchan);
+           "%s: [%s] pr_itemsperpage is zero, "
+           "pool not initialized?", __func__, pp->pr_wchan);
        KASSERTMSG((!(cpu_intr_p() || cpu_softintr_p())
                || pp->pr_ipl != IPL_NONE || cold || panicstr != NULL),
-           "pool '%s' is IPL_NONE, but called from interrupt context",
-           pp->pr_wchan);
+           "%s: [%s] is IPL_NONE, but called from interrupt context",
+           __func__, pp->pr_wchan);
        if (flags & PR_WAITOK) {
                ASSERT_SLEEPABLE();
        }
@@ -769,7 +770,7 @@
         * the pool.
         */
        KASSERTMSG((pp->pr_nout <= pp->pr_hardlimit),
-           "pool_get: %s: crossed hard limit", pp->pr_wchan);
+           "%s: %s: crossed hard limit", __func__, pp->pr_wchan);
        if (__predict_false(pp->pr_nout == pp->pr_hardlimit)) {
                if (pp->pr_drain_hook != NULL) {
                        /*
@@ -821,9 +822,8 @@
                int error;
 
                KASSERTMSG((pp->pr_nitems == 0),
-                   "pool_get: nitems inconsistent"
-                   ": %s: curpage NULL, nitems %u",
-                   pp->pr_wchan, pp->pr_nitems);
+                   "%s: [%s] curpage NULL, inconsistent nitems %u",
+                   __func__, pp->pr_wchan, pp->pr_nitems);
 
                /*
                 * Call the back-end page allocator for more memory.
@@ -860,21 +860,20 @@
        }
        if (pp->pr_roflags & PR_NOTOUCH) {
                KASSERTMSG((ph->ph_nmissing < pp->pr_itemsperpage),
-                   "pool_get: %s: page empty", pp->pr_wchan);
+                   "%s: %s: page empty", __func__, pp->pr_wchan);
                v = pr_item_notouch_get(pp, ph);
        } else {
                v = pi = LIST_FIRST(&ph->ph_itemlist);
                if (__predict_false(v == NULL)) {
                        mutex_exit(&pp->pr_lock);
-                       panic("pool_get: %s: page empty", pp->pr_wchan);
+                       panic("%s: [%s] page empty", __func__, pp->pr_wchan);
                }
                KASSERTMSG((pp->pr_nitems > 0),
-                   "pool_get: nitems inconsistent"
-                   ": %s: items on itemlist, nitems %u",
-                   pp->pr_wchan, pp->pr_nitems);
+                   "%s: [%s] nitems %u inconsistent on itemlist",
+                   __func__, pp->pr_wchan, pp->pr_nitems);
                KASSERTMSG((pi->pi_magic == PI_MAGIC),
-                   "pool_get(%s): free list modified: "
-                   "magic=%x; page %p; item addr %p",
+                   "%s: [%s] free list modified: "
+                   "magic=%x; page %p; item addr %p", __func__,
                    pp->pr_wchan, pi->pi_magic, ph->ph_page, pi);
 
                /*
@@ -899,7 +898,8 @@
        if (ph->ph_nmissing == pp->pr_itemsperpage) {
                KASSERTMSG(((pp->pr_roflags & PR_NOTOUCH) ||
                        LIST_EMPTY(&ph->ph_itemlist)),
-                   "pool_get: %s: nmissing inconsistent", pp->pr_wchan);
+                   "%s: [%s] nmissing (%u) inconsistent", __func__,
+                       pp->pr_wchan, ph->ph_nmissing);
                /*
                 * This page is now full.  Move it to the full list
                 * and select a new current page.
@@ -945,10 +945,10 @@
        LOCKDEBUG_MEM_CHECK(v, pp->pr_size);
 
        KASSERTMSG((pp->pr_nout > 0),
-           "pool_put: pool %s: putting with none out", pp->pr_wchan);
+           "%s: [%s] putting with none out", __func__, pp->pr_wchan);
 
        if (__predict_false((ph = pr_find_pagehead(pp, v)) == NULL)) {
-               panic("pool_put: %s: page header missing", pp->pr_wchan);
+               panic("%s: [%s] page header missing", __func__,  pp->pr_wchan);
        }
 
        /*
@@ -1157,7 +1157,7 @@
        KASSERT(mutex_owned(&pp->pr_lock));
        KASSERTMSG(((pp->pr_roflags & PR_NOALIGN) ||
                (((uintptr_t)cp & (pp->pr_alloc->pa_pagesz - 1)) == 0)),
-           "pool_prime_page: %s: unaligned page: %p", pp->pr_wchan, cp);
+           "%s: [%s] unaligned page: %p", __func__, pp->pr_wchan, cp);
 
        /*
         * Insert page header.
@@ -2228,8 +2228,8 @@
 
        KASSERTMSG((!cpu_intr_p() && !cpu_softintr_p()) ||
            (pc->pc_pool.pr_ipl != IPL_NONE || cold || panicstr != NULL),
-           "pool '%s' is IPL_NONE, but called from interrupt context\n",
-           pc->pc_pool.pr_wchan);
+           "%s: [%s] is IPL_NONE, but called from interrupt context",
+           __func__, pc->pc_pool.pr_wchan);
 
        if (flags & PR_WAITOK) {
                ASSERT_SLEEPABLE();



Home | Main Index | Thread Index | Old Index