mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: linux-kernel@vger.kernel.org, anton@samba.org
Subject: Re: [PATCH] In-kernel module loader 3/7
Date: Thu, 19 Sep 2002 12:05:05 +1000	[thread overview]
Message-ID: <20020919020654.A70802C07C@lists.samba.org> (raw)
In-Reply-To: Your message of "Thu, 19 Sep 2002 01:07:16 +0200." <Pine.LNX.4.44.0209190042370.8911-100000@serv>

In message <Pine.LNX.4.44.0209190042370.8911-100000@serv> you write:
> Hi,
> 
> On Wed, 18 Sep 2002, Rusty Russell wrote:
> 
> > +/* Stopping interrupts faster than atomics on many archs (and more
> > +   easily optimized if they're not) */
> > +static inline void bigref_inc(struct bigref *ref)
> > +{
> > +	unsigned long flags;
> > +	struct bigref_percpu *cpu;
> > +
> > +	local_irq_save(flags);
> > +	cpu = &ref->ref[smp_processor_id()];
> > +	if (likely(!cpu->slow_mode))
> > +		cpu->counter++;
> 
> Did you benchmark this? On most UP machines an inc/dec should be cheaper
> than irq enable/disable.

Oops, I forgot to test that: I had both implementations.

Doing a million loop (so there's loop overhead):

	350MHz dual Pentium II, atomic is almost twice as fast
	PPC 500MHz G4: atomic is 3.5 times as fast.
	Power3 4-way 375MHz machine: atomic is 10% faster.
	Power4 4-way 1.3GHz machine: atomic was 20% slower (depending
	       on version if irq_restore).

I suspect a P4 might get similar pro-irq results (code below,
anyone?)

Ideally we'd have a "local_inc()" and "local_dec()".  Architectures
which do soft interrupts enabling should see a real win from the
save/restore version.

Meanwhile, I'll revert to atomics, since it's sometimes dramatically
faster.

Thanks!
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

static void test(void)
{
	struct timeval start, end;
	atomic_t x;
	unsigned int tmp, i, diff;
	unsigned long flags;

	/* Atomic test. */
	atomic_set(&x, 0);
	do_gettimeofday(&start);
	for (i = 0; i < 1000000; i++)
		atomic_dec(&x);
	do_gettimeofday(&end);

	diff = (end.tv_sec - start.tv_sec) * 1000000
		+ (end.tv_usec - start.tv_usec);
	
	printk("Atomic test: %u usec\n", diff);

	/* Interrupt test (interrupts enabled) */
	tmp = 0;
	do_gettimeofday(&start);
	for (i = 0; i < 1000000; i++) {
		local_irq_save(flags);
		tmp++;
		local_irq_restore(flags);
	}
	do_gettimeofday(&end);

	diff = (end.tv_sec - start.tv_sec) * 1000000
		+ (end.tv_usec - start.tv_usec);
	
	printk("Interrupt test: %u usec\n", diff);

	/* Interrupt test (interrupts disabled) */
	tmp = 0;
	local_irq_disable();
	do_gettimeofday(&start);
	for (i = 0; i < 1000000; i++) {
		local_irq_save(flags);
		tmp++;
		local_irq_restore(flags);
	}
	do_gettimeofday(&end);
	local_irq_enable();

	diff = (end.tv_sec - start.tv_sec) * 1000000
		+ (end.tv_usec - start.tv_usec);
	
	printk("Interrupt test (interrupts disabled): %u usec\n", diff);
}

      parent reply	other threads:[~2002-09-19  2:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-18  2:07 Rusty Russell
2002-09-18 23:07 ` Roman Zippel
2002-09-18 23:11   ` Robert Love
2002-09-19  2:05   ` Rusty Russell [this message]

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=20020919020654.A70802C07C@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=anton@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zippel@linux-m68k.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

all inboxes | Powered by JetHome®