]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, pimd: Convert timer_wheel to use thread_execute_name 3018/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 30 Nov 2017 00:36:26 +0000 (19:36 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 13 Sep 2018 14:51:13 +0000 (10:51 -0400)
Allow at timer wheel creation time the ability to specify a
name for what we want the 'show thread cpu' to show up as.

Modify pim to note this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/wheel.c
lib/wheel.h
pimd/pim_upstream.c

index b1a3e89fc74ed440391c77c609900c2733b666cb..722b02424a30ebf7b64ad3f6703eccd117e13ef9 100644 (file)
@@ -29,7 +29,9 @@ DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL_LIST, "Timer Wheel Slot List")
 
 static int debug_timer_wheel = 0;
 
-static int wheel_timer_thread(struct thread *t)
+static int wheel_timer_thread(struct thread *t);
+
+static int wheel_timer_thread_helper(struct thread *t)
 {
        struct listnode *node, *nextnode;
        unsigned long long curr_slot;
@@ -65,15 +67,29 @@ static int wheel_timer_thread(struct thread *t)
        return 0;
 }
 
+static int wheel_timer_thread(struct thread *t)
+{
+       struct timer_wheel *wheel;
+
+       wheel = THREAD_ARG(t);
+
+       thread_execute_name(wheel->master, wheel_timer_thread_helper,
+                           wheel, 0, wheel->name);
+
+       return 0;
+}
+
 struct timer_wheel *wheel_init(struct thread_master *master, int period,
                               size_t slots, unsigned int (*slot_key)(void *),
-                              void (*slot_run)(void *))
+                              void (*slot_run)(void *),
+                              const char *run_name)
 {
        struct timer_wheel *wheel;
        size_t i;
 
        wheel = XCALLOC(MTYPE_TIMER_WHEEL, sizeof(struct timer_wheel));
 
+       wheel->name = XSTRDUP(MTYPE_TIMER_WHEEL, run_name);
        wheel->slot_key = slot_key;
        wheel->slot_run = slot_run;
 
@@ -104,6 +120,7 @@ void wheel_delete(struct timer_wheel *wheel)
 
        THREAD_OFF(wheel->timer);
        XFREE(MTYPE_TIMER_WHEEL_LIST, wheel->wheel_slot_lists);
+       XFREE(MTYPE_TIMER_WHEEL, wheel->name);
        XFREE(MTYPE_TIMER_WHEEL, wheel);
 }
 
index 1f9f95ed31382ebd7b3450f47a2d8a3d2c547919..c8e83fafcb81ea3f4753121d0158554f754276ad 100644 (file)
@@ -21,6 +21,7 @@
 #define __WHEEL_H__
 
 struct timer_wheel {
+       char *name;
        struct thread_master *master;
        int slots;
        long long curr_slot;
@@ -76,7 +77,8 @@ struct timer_wheel {
  */
 struct timer_wheel *wheel_init(struct thread_master *master, int period,
                               size_t slots, unsigned int (*slot_key)(void *),
-                              void (*slot_run)(void *));
+                              void (*slot_run)(void *),
+                              const char *run_name);
 
 /*
  * Delete the specified timer wheel created
index 15cbf6fbc331f5ac464c118063c81237e9a9e889..cc255a51e26840e491d3b99dcb5963276ee8a506 100644 (file)
@@ -1764,15 +1764,18 @@ void pim_upstream_remove_lhr_star_pimreg(struct pim_instance *pim,
 
 void pim_upstream_init(struct pim_instance *pim)
 {
-       char hash_name[64];
+       char name[64];
 
+       snprintf(name, 64, "PIM %s Timer Wheel",
+                pim->vrf->name);
        pim->upstream_sg_wheel =
                wheel_init(master, 31000, 100, pim_upstream_hash_key,
-                          pim_upstream_sg_running);
+                          pim_upstream_sg_running, name);
 
-       snprintf(hash_name, 64, "PIM %s Upstream Hash", pim->vrf->name);
+       snprintf(name, 64, "PIM %s Upstream Hash",
+                pim->vrf->name);
        pim->upstream_hash = hash_create_size(8192, pim_upstream_hash_key,
-                                             pim_upstream_equal, hash_name);
+                                             pim_upstream_equal, name);
 
        pim->upstream_list = list_new();
        pim->upstream_list->cmp = pim_upstream_compare;