On Fri, Mar 14, 2014 at 03:06:19PM -0700, Andy Zhou wrote: > Acked-by: Andy Zhou <az...@nicira.com> > > > On Tue, Mar 11, 2014 at 1:56 PM, Ben Pfaff <b...@nicira.com> wrote: > > +void * > > +ovsthread_stats_bucket_get(struct ovsthread_stats *stats, > > + void *(*new_bucket)(void)) > > { > > - c = &c[hash_int(ovsthread_id_self(), 0) % N_COUNTERS]; > > - > > - ovs_mutex_lock(&c->c.mutex); > > - c->c.value += n; > > - ovs_mutex_unlock(&c->c.mutex); > > + unsigned int hash = hash_int(ovsthread_id_self(), 0); > > + unsigned int idx = hash & (ARRAY_SIZE(stats->buckets) - 1); > > > > What's the advantage of using hashing over mod here ?
Do you mean, of hashing ovsthread_id_self() over just using it raw? I guess I just hadn't considered using it raw. It is probably good enough, so if that's what you mean then I'll use it that way. > > > + void *bucket = stats->buckets[idx]; > > > What's the advantage You didn't finish the thought there. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev