Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/subr_pool.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/subr_pool.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.152 retrieving revision 1.156.2.1 diff -u -p -r1.152 -r1.156.2.1 --- src/sys/kern/subr_pool.c 2008/03/02 12:19:58 1.152 +++ src/sys/kern/subr_pool.c 2008/05/18 12:35:09 1.156.2.1 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.152 2008/03/02 12:19:58 yamt Exp $ */ +/* $NetBSD: subr_pool.c,v 1.156.2.1 2008/05/18 12:35:09 yamt Exp $ */ /*- * Copyright (c) 1997, 1999, 2000, 2002, 2007 The NetBSD Foundation, Inc. @@ -16,13 +16,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -38,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.152 2008/03/02 12:19:58 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.156.2.1 2008/05/18 12:35:09 yamt Exp $"); #include "opt_ddb.h" #include "opt_pool.h" @@ -612,10 +605,10 @@ pool_subsystem_init(void) pa_reclaim_register(pa); } - pool_init(&cache_pool, sizeof(struct pool_cache), CACHE_LINE_SIZE, + pool_init(&cache_pool, sizeof(struct pool_cache), coherency_unit, 0, 0, "pcache", &pool_allocator_nointr, IPL_NONE); - pool_init(&cache_cpu_pool, sizeof(pool_cache_cpu_t), CACHE_LINE_SIZE, + pool_init(&cache_cpu_pool, sizeof(pool_cache_cpu_t), coherency_unit, 0, 0, "pcachecpu", &pool_allocator_nointr, IPL_NONE); } @@ -814,14 +807,7 @@ pool_init(struct pool *pp, size_t size, pp->pr_entered_file = NULL; pp->pr_entered_line = 0; - /* - * XXXAD hack to prevent IP input processing from blocking. - */ - if (ipl == IPL_SOFTNET) { - mutex_init(&pp->pr_lock, MUTEX_DEFAULT, IPL_VM); - } else { - mutex_init(&pp->pr_lock, MUTEX_DEFAULT, ipl); - } + mutex_init(&pp->pr_lock, MUTEX_DEFAULT, ipl); cv_init(&pp->pr_cv, wchan); pp->pr_ipl = ipl; @@ -855,12 +841,12 @@ pool_init(struct pool *pp, size_t size, size = sizeof(pcg_t) + (PCG_NOBJECTS_NORMAL - 1) * sizeof(pcgpair_t); - pool_init(&pcg_normal_pool, size, CACHE_LINE_SIZE, 0, 0, + pool_init(&pcg_normal_pool, size, coherency_unit, 0, 0, "pcgnormal", &pool_allocator_meta, IPL_VM); size = sizeof(pcg_t) + (PCG_NOBJECTS_LARGE - 1) * sizeof(pcgpair_t); - pool_init(&pcg_large_pool, size, CACHE_LINE_SIZE, 0, 0, + pool_init(&pcg_large_pool, size, coherency_unit, 0, 0, "pcglarge", &pool_allocator_meta, IPL_VM); } @@ -995,8 +981,9 @@ pool_get(struct pool *pp, int flags) #endif /* DIAGNOSTIC */ #ifdef LOCKDEBUG - if (flags & PR_WAITOK) - ASSERT_SLEEPABLE(NULL, "pool_get(PR_WAITOK)"); + if (flags & PR_WAITOK) { + ASSERT_SLEEPABLE(); + } #endif mutex_enter(&pp->pr_lock); @@ -1628,9 +1615,8 @@ pool_reclaim(struct pool *pp) } /* - * XXXSMP Because mutexes at IPL_SOFTXXX are still spinlocks, - * and we are called from the pagedaemon without kernel_lock. - * Does not apply to IPL_SOFTBIO. + * XXXSMP Because we do not want to cause non-MPSAFE code + * to block. */ if (pp->pr_ipl == IPL_SOFTNET || pp->pr_ipl == IPL_SOFTCLOCK || pp->pr_ipl == IPL_SOFTSERIAL) { @@ -2073,15 +2059,7 @@ pool_cache_bootstrap(pool_cache_t pc, si if (palloc == NULL && ipl == IPL_NONE) palloc = &pool_allocator_nointr; pool_init(pp, size, align, align_offset, flags, wchan, palloc, ipl); - - /* - * XXXAD hack to prevent IP input processing from blocking. - */ - if (ipl == IPL_SOFTNET) { - mutex_init(&pc->pc_lock, MUTEX_DEFAULT, IPL_VM); - } else { - mutex_init(&pc->pc_lock, MUTEX_DEFAULT, ipl); - } + mutex_init(&pc->pc_lock, MUTEX_DEFAULT, ipl); if (ctor == NULL) { ctor = (int (*)(void *, void *, int))nullop; @@ -2205,7 +2183,6 @@ pool_cache_cpu_init1(struct cpu_info *ci index = ci->ci_index; KASSERT(index < MAXCPUS); - KASSERT(((uintptr_t)pc->pc_cpus & (CACHE_LINE_SIZE - 1)) == 0); if ((cc = pc->pc_cpus[index]) != NULL) { KASSERT(cc->cc_cpuindex == index); @@ -2392,13 +2369,12 @@ pool_cache_cpu_enter(pool_cache_t pc, in * CPU-local data. To avoid touching shared state, we * pull the neccessary information from CPU local data. */ - crit_enter(); + KPREEMPT_DISABLE(curlwp); cc = pc->pc_cpus[curcpu()->ci_index]; KASSERT(cc->cc_cache == pc); if (cc->cc_ipl != IPL_NONE) { *s = splraiseipl(cc->cc_iplcookie); } - KASSERT(((uintptr_t)cc & (CACHE_LINE_SIZE - 1)) == 0); return cc; } @@ -2411,7 +2387,7 @@ pool_cache_cpu_exit(pool_cache_cpu_t *cc if (cc->cc_ipl != IPL_NONE) { splx(*s); } - crit_exit(); + KPREEMPT_ENABLE(curlwp); } #if __GNUC_PREREQ__(3, 0) @@ -2521,8 +2497,9 @@ pool_cache_get_paddr(pool_cache_t pc, in int s; #ifdef LOCKDEBUG - if (flags & PR_WAITOK) - ASSERT_SLEEPABLE(NULL, "pool_cache_get(PR_WAITOK)"); + if (flags & PR_WAITOK) { + ASSERT_SLEEPABLE(); + } #endif cc = pool_cache_cpu_enter(pc, &s); @@ -3062,7 +3039,7 @@ found: snprintf(cpucachestr, sizeof(cpucachestr), "cached by CPU %u", - (u_int)ci->ci_cpuid); + ci->ci_index); goto print; } }