* 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?

> +     if (new_shift != old_shift) {
> +             struct pid_hash *ph, *ret;
> +             unsigned int idx = ph_cur_idx ^ 1;
> +             ph = &pid_hashes[idx];
> +             if (!init_pid_hash(ph, new_shift)) {
> +                     ph_cur_idx = idx;
> +
> +                     ret = dyn_data_replace(&dyn_pidhash, dd_transfer_pids, 
> ph);
> +                     BUG_ON(ret == ph);
> +                     BUG_ON(ret != &pid_hashes[idx ^ 1]);
> +                     /* XXX: kfree(ret->table) */
> +                     ret->shift = -1;
> +                     ret->table = NULL;
> +             }
> +     }
> +     mutex_unlock(&dyn_pidhash.resize_mutex);
> +}
> +

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

Reply via email to