Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137375737
D22759.id65487.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D22759.id65487.diff
View Options
Index: sys/vm/uma_core.c
===================================================================
--- sys/vm/uma_core.c
+++ sys/vm/uma_core.c
@@ -292,6 +292,8 @@
static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS);
#ifdef INVARIANTS
+static struct noslabbits *slab_debugfree(uma_slab_t slab, uma_keg_t keg);
+
static bool uma_dbg_kskip(uma_keg_t keg, void *mem);
static bool uma_dbg_zskip(uma_zone_t zone, void *mem);
static void uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *item);
@@ -1136,6 +1138,9 @@
keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int domain, int flags,
int aflags)
{
+#ifdef INVARIANTS
+ struct noslabbits *debugfree;
+#endif
uma_alloc allocf;
uma_slab_t slab;
unsigned long size;
@@ -1201,7 +1206,8 @@
slab->us_domain = domain;
BIT_FILL(keg->uk_ipers, &slab->us_free);
#ifdef INVARIANTS
- BIT_ZERO(SLAB_MAX_SETSIZE, &slab->us_debugfree);
+ debugfree = slab_debugfree(slab, keg);
+ BIT_ZERO(keg->uk_ipers, debugfree);
#endif
if (keg->uk_init != NULL) {
@@ -1484,6 +1490,15 @@
return (0);
}
+#ifdef INVARIANTS
+struct noslabbits *
+slab_debugfree(uma_slab_t slab, uma_keg_t keg)
+{
+
+ return (void *)((char *)&slab->us_free + BITSET_SIZE(keg->uk_ipers));
+}
+#endif
+
/*
* Actual size of embedded struct slab (!OFFPAGE).
*/
@@ -1492,7 +1507,7 @@
{
size_t s;
- s = sizeof(struct uma_slab) + BITSET_SIZE(nitems);
+ s = sizeof(struct uma_slab) + BITSET_SIZE(nitems) * SLAB_BITSETS;
return (roundup(s, UMA_ALIGN_PTR + 1));
}
@@ -4514,12 +4529,10 @@
keg = zone->uz_keg;
freei = slab_item_index(slab, keg, item);
- if (BIT_ISSET(SLAB_MAX_SETSIZE, freei, &slab->us_debugfree))
+ if (BIT_ISSET(keg->uk_ipers, freei, slab_debugfree(slab, keg)))
panic("Duplicate alloc of %p from zone %p(%s) slab %p(%d)\n",
item, zone, zone->uz_name, slab, freei);
- BIT_SET_ATOMIC(SLAB_MAX_SETSIZE, freei, &slab->us_debugfree);
-
- return;
+ BIT_SET_ATOMIC(keg->uk_ipers, freei, slab_debugfree(slab, keg));
}
/*
@@ -4550,11 +4563,11 @@
panic("Unaligned free of %p from zone %p(%s) slab %p(%d)\n",
item, zone, zone->uz_name, slab, freei);
- if (!BIT_ISSET(SLAB_MAX_SETSIZE, freei, &slab->us_debugfree))
+ if (!BIT_ISSET(keg->uk_ipers, freei, slab_debugfree(slab, keg)))
panic("Duplicate free of %p from zone %p(%s) slab %p(%d)\n",
item, zone, zone->uz_name, slab, freei);
- BIT_CLR_ATOMIC(SLAB_MAX_SETSIZE, freei, &slab->us_debugfree);
+ BIT_CLR_ATOMIC(keg->uk_ipers, freei, slab_debugfree(slab, keg));
}
#endif /* INVARIANTS */
Index: sys/vm/uma_int.h
===================================================================
--- sys/vm/uma_int.h
+++ sys/vm/uma_int.h
@@ -271,17 +271,25 @@
uint16_t us_freecount; /* How many are free? */
uint8_t us_flags; /* Page flags see uma.h */
uint8_t us_domain; /* Backing NUMA domain. */
-#ifdef INVARIANTS
- struct slabbits us_debugfree; /* Debug bitmask. */
-#endif
- struct noslabbits us_free; /* Free bitmask. */
+ struct noslabbits us_free; /* Free bitmask, flexible. */
};
+CTASSERT(sizeof(struct uma_slab) == offsetof(struct uma_slab, us_free));
#if MAXMEMDOM >= 255
#error "Slab domain type insufficient"
#endif
typedef struct uma_slab * uma_slab_t;
+/*
+ * On INVARIANTS builds, the slab contains a second bitset of the same size,
+ * "debugfree", which is laid out immediately after us_free.
+ */
+#ifdef INVARIANTS
+#define SLAB_BITSETS 2
+#else
+#define SLAB_BITSETS 1
+#endif
+
/* These three functions are for embedded (!OFFPAGE) use only. */
size_t slab_sizeof(int nitems);
size_t slab_space(int nitems);
@@ -293,7 +301,10 @@
*/
struct uma_hash_slab {
struct uma_slab uhs_slab; /* Must be first. */
- struct slabbits uhs_bits; /* Must be second. */
+ struct slabbits uhs_bits1; /* Must be second. */
+#ifdef INVARIANTS
+ struct slabbits uhs_bits2; /* Must be third. */
+#endif
LIST_ENTRY(uma_hash_slab) uhs_hlink; /* Link for hash table */
uint8_t *uhs_data; /* First item */
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 23, 9:49 PM (55 m, 7 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26034735
Default Alt Text
D22759.id65487.diff (3 KB)
Attached To
Mode
D22759: uma dbg: flexible size for slab debugfree bitset too
Attached
Detach File
Event Timeline
Log In to Comment