public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Verych <olecom@flower.upol.cz>
To: Nick Piggin <npiggin@suse.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Paul McKenney <paulmck@us.ibm.com>
Subject: Fast path efficiency (Re: [rfc][patch] dynamic data structure switching)
Date: Thu, 6 Sep 2007 01:05:40 +0200	[thread overview]
Message-ID: <E1IT3wK-0006Bh-22@flower> (raw)
In-Reply-To: <20070902183618.GB13145@wotan.suse.de>

* 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.
____

  reply	other threads:[~2007-09-05 22:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-02 18:27 [rfc][patch] dynamic data structure switching Nick Piggin
2007-09-02 18:36 ` Nick Piggin
2007-09-05 23:05   ` Oleg Verych [this message]
2007-09-06  7:14     ` Fast path efficiency (Re: [rfc][patch] dynamic data structure switching) Nick Piggin
2007-09-06 11:35     ` Andi Kleen
2007-09-10 11:55 ` [rfc][patch] dynamic data structure switching Peter Zijlstra
2007-09-10 13:39   ` Nick Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1IT3wK-0006Bh-22@flower \
    --to=olecom@flower.upol.cz \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=paulmck@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox