X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ofproto%2Fofproto-dpif-upcall.c;h=a2159afa25609b9d84d1ed20d4c6410339fd063b;hb=003ce655b7116d18c86a74c50391e54990346931;hp=84afc5600d7baaace2f85f330b0cb401a7531056;hpb=7d1700980b5dcf98003fdceb821d7967fad99786;p=sliver-openvswitch.git diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 84afc5600..a2159afa2 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -52,7 +52,6 @@ COVERAGE_DEFINE(upcall_duplicate_flow); struct handler { struct udpif *udpif; /* Parent udpif. */ pthread_t thread; /* Thread ID. */ - char *name; /* Thread name. */ uint32_t handler_id; /* Handler id. */ }; @@ -60,9 +59,8 @@ struct handler { * updates or removes them if necessary. */ struct revalidator { struct udpif *udpif; /* Parent udpif. */ - char *name; /* Thread name. */ - pthread_t thread; /* Thread ID. */ + unsigned int id; /* ovsthread_id_self(). */ struct hmap *ukeys; /* Points into udpif->ukeys for this revalidator. Used for GC phase. */ }; @@ -310,15 +308,11 @@ udpif_stop_threads(struct udpif *udpif) /* Delete ukeys, and delete all flows from the datapath to prevent * double-counting stats. */ revalidator_purge(revalidator); - free(revalidator->name); hmap_destroy(&udpif->ukeys[i].hmap); ovs_mutex_destroy(&udpif->ukeys[i].mutex); } - for (i = 0; i < udpif->n_handlers; i++) { - free(udpif->handlers[i].name); - } latch_poll(&udpif->exit_latch); xpthread_barrier_destroy(&udpif->reval_barrier); @@ -342,7 +336,7 @@ static void udpif_start_threads(struct udpif *udpif, size_t n_handlers, size_t n_revalidators) { - if (udpif && (!udpif->handlers && !udpif->revalidators)) { + if (udpif && n_handlers && n_revalidators) { size_t i; udpif->n_handlers = n_handlers; @@ -354,8 +348,8 @@ udpif_start_threads(struct udpif *udpif, size_t n_handlers, handler->udpif = udpif; handler->handler_id = i; - xpthread_create(&handler->thread, NULL, udpif_upcall_handler, - handler); + handler->thread = ovs_thread_create( + "handler", udpif_upcall_handler, handler); } xpthread_barrier_init(&udpif->reval_barrier, NULL, @@ -371,8 +365,8 @@ udpif_start_threads(struct udpif *udpif, size_t n_handlers, hmap_init(&udpif->ukeys[i].hmap); ovs_mutex_init(&udpif->ukeys[i].mutex); revalidator->ukeys = &udpif->ukeys[i].hmap; - xpthread_create(&revalidator->thread, NULL, udpif_revalidator, - revalidator); + revalidator->thread = ovs_thread_create( + "revalidator", udpif_revalidator, revalidator); } } } @@ -522,9 +516,6 @@ udpif_upcall_handler(void *arg) struct udpif *udpif = handler->udpif; struct hmap misses = HMAP_INITIALIZER(&misses); - handler->name = xasprintf("handler_%u", ovsthread_id_self()); - set_subprogram_name("%s", handler->name); - while (!latch_is_set(&handler->udpif->exit_latch)) { struct upcall upcalls[FLOW_MISS_MAX_BATCH]; struct flow_miss miss_buf[FLOW_MISS_MAX_BATCH]; @@ -569,8 +560,7 @@ udpif_revalidator(void *arg) unsigned int flow_limit = 0; size_t n_flows = 0; - revalidator->name = xasprintf("revalidator_%u", ovsthread_id_self()); - set_subprogram_name("%s", revalidator->name); + revalidator->id = ovsthread_id_self(); for (;;) { if (leader) { uint64_t reval_seq; @@ -1245,7 +1235,6 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey, push.n_bytes = stats->n_bytes > ukey->stats.n_bytes ? stats->n_bytes - ukey->stats.n_bytes : 0; - ukey->stats = *stats; if (!ukey->flow_exists) { /* Don't bother revalidating if the flow was already deleted. */ @@ -1258,6 +1247,8 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey, goto exit; } + /* We will push the stats, so update the ukey stats cache. */ + ukey->stats = *stats; if (!push.n_packets && !udpif->need_revalidate) { ok = true; goto exit; @@ -1618,8 +1609,8 @@ upcall_unixctl_show(struct unixctl_conn *conn, int argc OVS_UNUSED, struct revalidator *revalidator = &udpif->revalidators[i]; ovs_mutex_lock(&udpif->ukeys[i].mutex); - ds_put_format(&ds, "\t%s: (keys %"PRIuSIZE")\n", revalidator->name, - hmap_count(&udpif->ukeys[i].hmap)); + ds_put_format(&ds, "\t%u: (keys %"PRIuSIZE")\n", + revalidator->id, hmap_count(&udpif->ukeys[i].hmap)); ovs_mutex_unlock(&udpif->ukeys[i].mutex); } }