public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Milton Miller <miltonm@bga.com>
To: Andrew Morton <akpm@osdl.org>, Jes Sorensen <jes@sgi.com>
Cc: Anton Blanchard <anton@samba.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: [patch] reduce IPI noise due to /dev/cdrom open/close
Date: Tue, 4 Jul 2006 04:13:13 -0500	[thread overview]
Message-ID: <49ec8bf1c51da1b651be8a630b4dd1f8@bga.com> (raw)
In-Reply-To: 20060703234134.786944f1.akpm@osdl.org


On Jul 4, 2006, at 1:39 AM, Andrew Morton wrote:

>
> I expect raw_smp_processor_id() is used here as a a microoptimisation -
> avoid a might_sleep() which obviously will never trigger.
>
> But I think it'd be better to do just a single raw_smp_processor_id() 
> for this entire function:
>
> static void bh_lru_install(struct buffer_head *bh)
> {
> struct buffer_head *evictee = NULL;
> struct bh_lru *lru;
> + int cpu;
>
> check_irqs_on();
> bh_lru_lock();
> + cpu = raw_smp_processor_id();
> - lru = &__get_cpu_var(bh_lrus);
> + lru = per_cpu(bh_lrus, cpu);
>

The problem with this style is that it is an disoptimizatoin for 
architectures who hold their per-cpu data offset in a register, put the 
smp_processor_id in the per-cpu data (or similar) and per_cpu data 
offsets in a global lookup.

Do we need a new macro? (what is that gcc macro function syntax?)

#ifdef PER_CPU_IS_SLOW
#define my_cpu_var(bh_lrus, cpu) \
	({ BUG_ON(cpu != smp_processor_id()); 	&__get_cpu_var(bh_lrus); })
#else
#define my_cpu_var(bh_lrus, cpu) \
	({ BUG_ON(cpu != smp_processor_id()); per_cpu(bh_lrus, cpu); })
#endif

(and yes, the BUG_ON would be for debug checking).

milton


  parent reply	other threads:[~2006-07-04  9:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-03 15:33 [patch] reduce IPI noise due to /dev/cdrom open/close Jes Sorensen
2006-07-03 15:37 ` [PATCH] simplfy bh_lru_install Milton Miller
2006-07-03 15:37   ` Milton Miller
2006-07-03 15:37 ` [patch] reduce IPI noise due to /dev/cdrom open/close Milton Miller
2006-07-04  7:47   ` Jes Sorensen
2006-07-04  7:53     ` Arjan van de Ven
2006-07-04  8:12       ` Jes Sorensen
2006-07-04  8:23         ` Arjan van de Ven
2006-07-04  8:33           ` Jes Sorensen
2006-07-04 13:02         ` Helge Hafting
2006-07-04  8:42     ` Milton Miller
2006-07-04  8:59       ` Jes Sorensen
2006-07-04  9:30         ` Milton Miller
2006-07-04  5:32 ` Keith Owens
2006-07-04  6:41   ` Andrew Morton
2006-07-04  7:51     ` Jes Sorensen
2006-07-04  9:13     ` Milton Miller [this message]
2006-07-04 17:33     ` Nick Piggin
2006-07-05  7:30       ` Jes Sorensen
2006-07-05 18:26         ` Nick Piggin
2006-07-05  0:10     ` Paul Mackerras
2006-07-04  7:49   ` Jes Sorensen
2006-07-04  8:04     ` Andrew Morton

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=49ec8bf1c51da1b651be8a630b4dd1f8@bga.com \
    --to=miltonm@bga.com \
    --cc=akpm@osdl.org \
    --cc=anton@samba.org \
    --cc=jes@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    /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