Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Jan 2020 19:29:26 +0000 (UTC)
From:      Jeff Roberson <jeff@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r356353 - head/sys/vm
Message-ID:  <202001041929.004JTQ7M032617@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jeff
Date: Sat Jan  4 19:29:25 2020
New Revision: 356353
URL: https://svnweb.freebsd.org/changeset/base/356353

Log:
  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

Modified:
  head/sys/vm/uma_core.c
  head/sys/vm/uma_int.h

Modified: head/sys/vm/uma_core.c
==============================================================================
--- head/sys/vm/uma_core.c	Sat Jan  4 18:59:46 2020	(r356352)
+++ head/sys/vm/uma_core.c	Sat Jan  4 19:29:25 2020	(r356353)
@@ -294,7 +294,10 @@ static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER
 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);
@@ -4184,6 +4187,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

Modified: head/sys/vm/uma_int.h
==============================================================================
--- head/sys/vm/uma_int.h	Sat Jan  4 18:59:46 2020	(r356352)
+++ head/sys/vm/uma_int.h	Sat Jan  4 19:29:25 2020	(r356353)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001041929.004JTQ7M032617>