[ovs-dev] [urcu v2 13/15] ovs-thread: Replace ovsthread_counter by more general ovsthread_stats.

Ben Pfaff blp at nicira.com
Tue Mar 18 23:40:02 UTC 2014


On Fri, Mar 14, 2014 at 03:06:19PM -0700, Andy Zhou wrote:
> Acked-by: Andy Zhou <azhou at nicira.com>
> 
> 
> On Tue, Mar 11, 2014 at 1:56 PM, Ben Pfaff <blp at 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.



More information about the dev mailing list