Fix an assertion introduced in r356348. On architectures without

UMA_MD_SMALL_ALLOC vmem has a more complicated startup sequence that
violated the new assert.  Resolve this by rewriting the COLD asserts to
look at the per-cpu allocation counts for evidence of api activity.

Discussed with:	rlibby
Reviewed by:	markj
Reported by:	lwhsu
This commit is contained in:
Jeff Roberson 2020-01-04 19:29:25 +00:00
parent 0cb4586a0b
commit 31c251a046
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=356353
2 changed files with 21 additions and 2 deletions

View File

@ -294,7 +294,10 @@ static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS);
static int sysctl_handle_uma_slab_efficiency(SYSCTL_HANDLER_ARGS);
static int sysctl_handle_uma_zone_items(SYSCTL_HANDLER_ARGS);
static uint64_t uma_zone_get_allocs(uma_zone_t zone);
#ifdef INVARIANTS
static uint64_t uma_keg_get_allocs(uma_keg_t zone);
static inline struct noslabbits *slab_dbg_bits(uma_slab_t slab, uma_keg_t keg);
static bool uma_dbg_kskip(uma_keg_t keg, void *mem);
@ -4185,6 +4188,22 @@ uma_zone_get_frees(uma_zone_t zone)
return (nitems);
}
#ifdef INVARIANTS
/* Used only for KEG_ASSERT_COLD(). */
static uint64_t
uma_keg_get_allocs(uma_keg_t keg)
{
uma_zone_t z;
uint64_t nitems;
nitems = 0;
LIST_FOREACH(z, &keg->uk_zones, uz_link)
nitems += uma_zone_get_allocs(z);
return (nitems);
}
#endif
/* See uma.h */
void
uma_zone_set_init(uma_zone_t zone, uma_init uminit)

View File

@ -305,7 +305,7 @@ typedef struct uma_keg * uma_keg_t;
#ifdef _KERNEL
#define KEG_ASSERT_COLD(k) \
KASSERT((k)->uk_domain[0].ud_pages == 0, \
KASSERT(uma_keg_get_allocs((k)) == 0, \
("keg %s initialization after use.", (k)->uk_name))
/*
@ -529,7 +529,7 @@ struct uma_zone {
#define UZ_ITEMS_SLEEPER (1LL << UZ_ITEMS_SLEEPER_SHIFT)
#define ZONE_ASSERT_COLD(z) \
KASSERT((z)->uz_bkt_count == 0, \
KASSERT(uma_zone_get_allocs((z)) == 0, \
("zone %s initialization after use.", (z)->uz_name))
#undef UMA_ALIGN