All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Arnaldo Carvalho de Melo <acme@conectiva.com.br>,
	linux-kernel@vger.kernel.org
Subject: Re: [ANNOUNCE] Kernel Janitor's TODO list
Date: Wed, 31 Jan 2001 20:15:42 +0100	[thread overview]
Message-ID: <3A78645E.D336F44A@colorfullife.com> (raw)
In-Reply-To: <E14O1Vp-0002mv-00@the-village.bc.nu>

Alan Cox wrote:
> 
> > And one more point for the Janitor's list:
> > Get rid of superflous irqsave()/irqrestore()'s - in 90% of the cases
> > either spin_lock_irq() or spin_lock() is sufficient. That's both faster
> > and better readable.
> 
> Expect me to drop any submissions that do this. I'd rather take the two
> clock hit in most cases because the effect of spin_lock_irq() being used
> and people then changing which functions call each other and producing
> impossible to debug irq mishandling cases is unacceptable.
>

IMHO the main problem of spin_lock_irqsave is not the lost cpu cycles,
but readability:

void public_function()
{
	spin_lock_irqsave();
	if(rare_event)
		internal_function()
	spin_unlock_irqrestore();
}

static void internal_function()
{
	...
	spin_unlock_irq();
	kmalloc(GFP_KERNEL);
	spin_lock_irq();
}

IMHO functions that are not irq safe somewhere hidden in internal
functions should never use spin_lock_irqsave().
make_request() in 2.2 falls into that category, and the irqsave() was
removed.

Obviously spin_lock_irq() instead of spin_lock_irqsave() should only be
done if the implementation doesn't support disabled interrupts, not if
currently noone calls a function with disabled interrupts.

(make_request(), down(), smp_call_function()...)

> The original Linux network code did this with sti() not save/restore flags.
> I've been there before, I am not going to allow a rerun of that disaster for
> a few cycles

I hope that during 2.5 we can add debugging into spin_lock_irq():
BUG() if it's called with disabled interrupts.
It's not yet possible due to schedule() with disabled interrupts (I
tried it a few months ago)

--
	Manfred
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2001-01-31 19:16 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-28 16:14 [ANNOUNCE] Kernel Janitor's TODO list Manfred Spraul
2001-01-28 14:36 ` Arnaldo Carvalho de Melo
2001-01-28 16:45   ` Manfred Spraul
2001-01-28 17:07     ` David Woodhouse
2001-01-28 17:40       ` Manfred Spraul
2001-01-28 18:51         ` Roman Zippel
2001-01-29 17:01         ` Timur Tabi
2001-01-29 17:10           ` John Levon
2001-01-29 18:27             ` David D.W. Downey
2001-01-29 20:44               ` davej
2001-01-29 20:51               ` Timur Tabi
2001-01-29 20:56                 ` Rasmus Andersen
2001-01-30  0:29                 ` Peter Samuelson
2001-01-30  0:20               ` Ingo Oeser
2001-01-30 11:11               ` David Woodhouse
2001-01-30 16:52               ` Timur Tabi
2001-01-31  0:06                 ` Daniel Phillips
2001-01-31  0:09                 ` Timur Tabi
2001-01-31  9:14                   ` David Woodhouse
2001-01-30 17:10               ` David Woodhouse
2001-01-29 17:26           ` Andi Kleen
2001-01-29 19:47             ` Roman Zippel
2001-01-29 20:35               ` Andi Kleen
2001-02-16 14:29                 ` Andrea Arcangeli
2001-02-16 14:26               ` Andrea Arcangeli
2001-01-31 17:57         ` Alan Cox
2001-01-31 19:15           ` Manfred Spraul [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-01-30  1:22 Rusty Russell
2001-01-30  3:08 ` Andrew Morton
2001-01-27 17:11 Arnaldo Carvalho de Melo
2001-01-28 15:20 ` David Woodhouse
2001-01-28 14:03   ` Arnaldo Carvalho de Melo
2001-01-28 15:49   ` Michael H. Warfield
2001-01-28 16:13 ` Andrew Morton
2001-01-28 14:28   ` Arnaldo Carvalho de Melo
2001-01-28 14:33     ` Arnaldo Carvalho de Melo
2001-01-30  1:05   ` Rusty Russell
2001-01-30 11:19     ` Daniel Phillips
2001-01-30 17:49       ` Daniel Phillips

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=3A78645E.D336F44A@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=acme@conectiva.com.br \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.