slab: warn about duplicated KMC names when tracing
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 30 Sep 2019 18:42:53 +0000 (14:42 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 8 Oct 2019 21:11:11 +0000 (17:11 -0400)
Instead of during creation.  The IOAT driver creates a KMC call
'completion_pool' for every device.  I'm not going to bother giving them
separate names.  The only thing we used duplicate names for was
debugging and slab_trace.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/drivers/dev/mem.c
kern/src/slab.c

index 5711c24..5379c50 100644 (file)
@@ -424,7 +424,7 @@ static void slab_trace_cmd(struct chan *c, struct cmdbuf *cb)
 {
        ERRSTACK(1);
        struct sized_alloc *sza, *old_sza;
-       struct kmem_cache *kc;
+       struct kmem_cache *kc = NULL, *kc_i;
 
        if (cb->nf < 2)
                error(EFAIL, SLAB_TRACE_USAGE);
@@ -434,9 +434,16 @@ static void slab_trace_cmd(struct chan *c, struct cmdbuf *cb)
                qunlock(&arenas_and_slabs_lock);
                nexterror();
        }
-       TAILQ_FOREACH(kc, &all_kmem_caches, all_kmc_link)
-               if (!strcmp(kc->name, cb->f[1]))
-                       break;
+       TAILQ_FOREACH(kc_i, &all_kmem_caches, all_kmc_link) {
+               if (!strcmp(kc_i->name, cb->f[1])) {
+                       if (kc) {
+                               printk("[kernel] Multiple KC's named %s, tracing the first one\n",
+                                      kc->name);
+                               break;
+                       }
+                       kc = kc_i;
+               }
+       }
        if (!kc)
                error(ENOENT, "No such slab %s", cb->f[1]);
        /* Note that the only time we have a real sza is when printing.
index 0ebc730..eba20b5 100644 (file)
@@ -104,11 +104,6 @@ static void kmc_track(struct kmem_cache *kc)
        struct kmem_cache *kc_i;
 
        qlock(&arenas_and_slabs_lock);
-       TAILQ_FOREACH(kc_i, &all_kmem_caches, all_kmc_link) {
-               if (!strcmp(kc->name, kc_i->name))
-                       warn("Creatgin KMC %s, but one with that name exists!",
-                            kc->name);
-       }
        TAILQ_INSERT_TAIL(&all_kmem_caches, kc, all_kmc_link);
        qunlock(&arenas_and_slabs_lock);
 }