lkml.org 
[lkml]   [2007]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Fast path efficiency (Re: [rfc][patch] dynamic data structure switching)
On Thu, Sep 06, 2007 at 01:05:40AM +0200, Oleg Verych wrote:
> * Sun, 2 Sep 2007 20:36:19 +0200
> >
>
> I see, that in many places all pre-checks are done in negative form
> with resulting return or jump out. In this case, if function was called,
> what likely() path is?
>
> > +static void resize_pid_hash(void)
> > +{
> > + unsigned int old_shift, new_shift;
> > +
> > + if (system_state != SYSTEM_RUNNING)
> > + return;
> > +
> > + old_shift = cur_pid_hash->shift;
> > + new_shift = ilog2(nr_pids * 2 - 1);
> > + if (new_shift == old_shift)
> > + return;
> > +
> > + if (!mutex_trylock(&dyn_pidhash.resize_mutex))
> > + return;
>
> that one or this?
>
> ==
> if (system_state == SYSTEM_RUNNING) {
> old_shift = cur_pid_hash->shift;
> new_shift = ilog2(nr_pids * 2 - 1);
> if (new_shift != old_shift && mutex_trylock(&dyn_pidhash.resize_mutex)) {
> ==
> > + old_shift = cur_pid_hash->shift;
> > + new_shift = ilog2(nr_pids * 2 - 1);
>
> /* hope this repetition is needed by design */
>
> ...
>
> > + mutex_unlock(&dyn_pidhash.resize_mutex);
> }
>
> What is more efficient in general sense,
> as opposed to s,3,2,1,0 Optimized?

I'm not too sure, but I'd guess that most of the time the compiler will
be able to figure out they are the same.

resize_pid_hash() fortunately isn't a fastpath anyway -- it calls
dyn_data_replace which ends up calling synchronize_rcu() 3 times,
each of which is likely to take a long time!

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-09-06 09:17    [W:0.073 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site