public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Owens <kaos@sgi.com>
To: Jes Sorensen <jes@sgi.com>
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] reduce IPI noise due to /dev/cdrom open/close
Date: Tue, 04 Jul 2006 15:32:19 +1000	[thread overview]
Message-ID: <21169.1151991139@kao2.melbourne.sgi.com> (raw)
In-Reply-To: Your message of "03 Jul 2006 11:33:54 -0400." <yq0mzbqhfdp.fsf@jaguar.mkp.net>

Jes Sorensen (on 03 Jul 2006 11:33:54 -0400) wrote:
>Anyway, this patch reduces the IPI noise by keeping a cpumask of CPUs
>which have items in the bh lru and only flushing on the relevant
>CPUs. On systems with larger CPU counts it's quite normal that only a
>few CPUs are actively doing block IO, so spewing IPIs everywhere to
>flush this is unnecessary.
>
>Index: linux-2.6/fs/buffer.c
>===================================================================
>--- linux-2.6.orig/fs/buffer.c
>+++ linux-2.6/fs/buffer.c
>@@ -1323,6 +1323,7 @@ struct bh_lru {
> };
> 
> static DEFINE_PER_CPU(struct bh_lru, bh_lrus) = {{ NULL }};
>+static cpumask_t lru_in_use;
> 
> #ifdef CONFIG_SMP
> #define bh_lru_lock()	local_irq_disable()
>@@ -1352,9 +1353,14 @@ static void bh_lru_install(struct buffer
> 	lru = &__get_cpu_var(bh_lrus);
> 	if (lru->bhs[0] != bh) {
> 		struct buffer_head *bhs[BH_LRU_SIZE];
>-		int in;
>-		int out = 0;
>+		int in, out, cpu;
> 
>+		cpu = raw_smp_processor_id();

Why raw_smp_processor_id?  That normally indicates code that wants a
lazy cpu number, but this code requires the exact cpu number, IMHO
using raw_smp_processor_id is confusing.  smp_processor_id can safely
be used here, bh_lru_lock has disabled irq or preempt.

>+		/* Test first to avoid cache lines bouncing around */
>+		if (!cpu_isset(cpu, lru_in_use))
>+			cpu_set(cpu, lru_in_use);
>+
>+		out = 0;
> 		get_bh(bh);
> 		bhs[out++] = bh;
> 		for (in = 0; in < BH_LRU_SIZE; in++) {
>@@ -1500,19 +1506,28 @@ EXPORT_SYMBOL(__bread);
>  */
> static void invalidate_bh_lru(void *arg)
> {
>-	struct bh_lru *b = &get_cpu_var(bh_lrus);
>+	struct bh_lru *b;
> 	int i;
> 
>+	local_irq_disable();
>+	b = &get_cpu_var(bh_lrus);
> 	for (i = 0; i < BH_LRU_SIZE; i++) {
> 		brelse(b->bhs[i]);
> 		b->bhs[i] = NULL;
> 	}
> 	put_cpu_var(bh_lrus);
>+	local_irq_enable();
> }
> 	
> static void invalidate_bh_lrus(void)
> {
>-	on_each_cpu(invalidate_bh_lru, NULL, 1, 1);
>+	/*
>+	 * Need to hand down a copy of the mask or we wouldn't be run
>+	 * anywhere due to the original mask being cleared
>+	 */
>+	cpumask_t mask = lru_in_use;
>+	cpus_clear(lru_in_use);
>+	schedule_on_each_cpu_mask(invalidate_bh_lru, NULL, mask);
> }

Racy?  Start with an empty lru_in_use.

Cpu A                         Cpu B
invalidate_bh_lrus()
mask = lru_in_use;
preempted
                              block I/O
			      bh_lru_install()
			      cpu_set(cpu, lru_in_use);
resume
cpus_clear(lru_in_use);
schedule_on_each_cpu_mask() - does not send IPI to cpu B


  parent reply	other threads:[~2006-07-04  5:32 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 [this message]
2006-07-04  6:41   ` Andrew Morton
2006-07-04  7:51     ` Jes Sorensen
2006-07-04  9:13     ` Milton Miller
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=21169.1151991139@kao2.melbourne.sgi.com \
    --to=kaos@sgi.com \
    --cc=akpm@osdl.org \
    --cc=jes@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=viro@zeniv.linux.org.uk \
    /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