All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] big IRQ lock removal, 2.5.27-G0
@ 2002-07-23 16:26 Ingo Molnar
  0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2002-07-23 16:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds


the -G0 irqlock patch can be found at:

   http://redhat.com/~mingo/remove-irqlock-patches/remove-irqlock-2.5.27-G0

Changes in -G0:

 - fix buggy in_softirq(). Fortunately the bug made the test broader,
   which didnt result in algorithmical breakage, just suboptimal
   performance.

 - move do_softirq() processing into irq_exit() => this also fixes the
   softirq processing bugs present in apic.c IRQ handlers that did not
   test for softirqs after irq_exit().

 - simplify local_bh_enable().

Changes in -F9:

 - replace all instances of:

	local_save_flags(flags);
	local_irq_disable();

   with the shorter form of:

	local_irq_save(flags);

  about 30 files are affected by this change.

Changes in -F8:

 - preempt/hardirq/softirq count separation, cleanups.

 - skbuff.c fix.

 - use irq_count() in scheduler_tick()

Changes in -F3:

 - the entry.S cleanups/speedups by Oleg Nesterov.

 - a rather critical synchronize_irq() bugfix: if a driver frees an 
   interrupt that is still being probed then synchronize_irq() locks up.
   This bug has caused a spurious boot-lockup on one of my testsystems,
   ifconfig would lock up trying to close eth0.

 - remove duplicate definitions from asm-i386/system.h, this fixes 
   compiler warnings.

	Ingo



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] big IRQ lock removal, 2.5.27-G0
@ 2002-07-23 23:40 Oleg Nesterov
  2002-07-23 23:50 ` Ingo Molnar
  0 siblings, 1 reply; 7+ messages in thread
From: Oleg Nesterov @ 2002-07-23 23:40 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel

Hello.

I can't understand the preempt_count() check in irq_exit()
and local_bh_enable(). Did you meant irq_count() instead?
I beleive preempt_disable() should not disable soft interrupts.

In local_bh_enable() it is probably unneeded at all, because
nested local_bh_disable() is rare (i think), and do_softirq()
checks in_interrupt().

Now suppose preempt_count() & PREEMPT_MASK == 0.

Then local_bh_enable() has a small preemptible window between
__local_bh_enable() and do_softirq()->local_irq_save(flags).
It is only latency problem.

But in irq_exit() case interrupt context may be preempted
while doing wakeup_softirqd(cpu) after __local_bh_enable()
in do_softirq().

So i suggest something like this pseudo code:

__preempt_hack(offset)
{
        barrier();
        preempt_count() -= offset
#ifdef  CONFIG_PREEMPT
                        - 1
#endif
        ;
}

irq_exit()
{
        __preempt_hack(HARDIRQ_OFFSET);
        if (unlikely(!irq_count() &&
                        softirq_pending(smp_processor_id())))
                do_softirq();
        preempt_enable_no_resched();
}

local_bh_enable()
{
        __preempt_hack(SOFTIRQ_OFFSET);
        if (unlikely(!irq_count() &&
                        softirq_pending(smp_processor_id())))
                do_softirq();
        preempt_enable();
}

Or just add extra preempt_disable() in both functions to kill
terrible __preempt_hack().

Sorry, i have no remove-irqlock patches applied, so can't
suggest diff.

Oleg.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] big IRQ lock removal, 2.5.27-G0
  2002-07-23 23:40 [patch] big IRQ lock removal, 2.5.27-G0 Oleg Nesterov
@ 2002-07-23 23:50 ` Ingo Molnar
  2002-07-23 23:54   ` Ingo Molnar
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ingo Molnar @ 2002-07-23 23:50 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Linus Torvalds


On Wed, 24 Jul 2002, Oleg Nesterov wrote:

> I can't understand the preempt_count() check in irq_exit() and
> local_bh_enable(). Did you meant irq_count() instead? I beleive
> preempt_disable() should not disable soft interrupts.

yes, you are right, and i fixed them in -G3.

doh, i *thought* i fixed both places in -G3, but i only fixed irq_exit().  
the local_bh_enable() fix is in -G4:

  http://redhat.com/~mingo/remove-irqlock-patches/remove-irqlock-2.5.27-G4

> In local_bh_enable() it is probably unneeded at all, because nested
> local_bh_disable() is rare (i think), and do_softirq() checks
> in_interrupt().

but still we dont want to call do_softirq() all the time. local_bh_enable
is used in quite performance-sensitive networking code.

> Now suppose preempt_count() & PREEMPT_MASK == 0.
> 
> Then local_bh_enable() has a small preemptible window between
> __local_bh_enable() and do_softirq()->local_irq_save(flags).
> It is only latency problem.

i dont think getting a preemption before softirqs are processed is a big
problem. Such type of preemption comes in form of an interrupt, which 
handles softirqs in irq_exit() anyway, so there's no delay.

> But in irq_exit() case interrupt context may be preempted
> while doing wakeup_softirqd(cpu) after __local_bh_enable()
> in do_softirq().

okay - i've fixed irq_exit() once more in -G4, could you double-check it?

	Ingo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] big IRQ lock removal, 2.5.27-G0
  2002-07-23 23:50 ` Ingo Molnar
@ 2002-07-23 23:54   ` Ingo Molnar
  2002-07-24  1:00   ` Oleg Nesterov
  2002-07-24  3:07   ` Oleg Nesterov
  2 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2002-07-23 23:54 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Linus Torvalds


On Wed, 24 Jul 2002, Ingo Molnar wrote:

> > local_bh_disable() is rare (i think), and do_softirq() checks
> > in_interrupt().
> 
> but still we dont want to call do_softirq() all the time. local_bh_enable
> is used in quite performance-sensitive networking code.

in fact the in_interrupt() check in do_softirq() should never trigger with
the latest patch applied - i'll put a debugging printk there and we can
remove it after some time. This will speed things up a bit.

	Ingo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] big IRQ lock removal, 2.5.27-G0
  2002-07-23 23:50 ` Ingo Molnar
  2002-07-23 23:54   ` Ingo Molnar
@ 2002-07-24  1:00   ` Oleg Nesterov
  2002-07-24  7:19     ` Ingo Molnar
  2002-07-24  3:07   ` Oleg Nesterov
  2 siblings, 1 reply; 7+ messages in thread
From: Oleg Nesterov @ 2002-07-24  1:00 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Linus Torvalds

Hello.

> > Then local_bh_enable() has a small preemptible window between
>
> i dont think getting a preemption before softirqs are processed is a big
> problem. Such type of preemption comes in form of an interrupt, which

Ah, yes...

> > But in irq_exit() case interrupt context may be preempted
>
> okay - i've fixed irq_exit() once more in -G4

found G5, your forgot to add preempt_disable() in irq_exit()

 #define irq_exit()
 do {
+               preempt_disable();
                preempt_count() -= IRQ_EXIT_OFFSET;
                if (!in_interrupt() && softirq_pending(smp_processor_id()))

Oleg.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] big IRQ lock removal, 2.5.27-G0
  2002-07-23 23:50 ` Ingo Molnar
  2002-07-23 23:54   ` Ingo Molnar
  2002-07-24  1:00   ` Oleg Nesterov
@ 2002-07-24  3:07   ` Oleg Nesterov
  2 siblings, 0 replies; 7+ messages in thread
From: Oleg Nesterov @ 2002-07-24  3:07 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Linus Torvalds

Hello.

> > Then local_bh_enable() has a small preemptible window between
> > __local_bh_enable() and do_softirq()->local_irq_save(flags).
> > It is only latency problem.
> 
> i dont think getting a preemption before softirqs are processed is a big
> problem. Such type of preemption comes in form of an interrupt, which
> handles softirqs in irq_exit() anyway, so there's no delay.

Well, no. Not all smp_xxx_interrupt() use irq_enter/exit().
Reschedule interrupt, for example, do not. But indeed, it is not
big problem.

Oleg.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] big IRQ lock removal, 2.5.27-G0
  2002-07-24  1:00   ` Oleg Nesterov
@ 2002-07-24  7:19     ` Ingo Molnar
  0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2002-07-24  7:19 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Linus Torvalds


On Wed, 24 Jul 2002, Oleg Nesterov wrote:

> > okay - i've fixed irq_exit() once more in -G4
> 
> found G5, your forgot to add preempt_disable() in irq_exit()
> 
>  #define irq_exit()
>  do {
> +               preempt_disable();
>                 preempt_count() -= IRQ_EXIT_OFFSET;
>                 if (!in_interrupt() && softirq_pending(smp_processor_id()))
> 
> Oleg.

nope, it's tricky, check out the define of IRQ_EXIT_OFFSET, it has the
plus 1 count added already.

using preempt_disable() has the problem of putting a barrier() between the
++ and the -IRQ_OFFSET, causing one more instruction to be generated.

but there was another (not too critical) bug here - irq_enter() needs to
have a barrier() after manipulating the preemption count, irq_exit() needs
to have a barrier() before. Fixed in my tree.

	Ingo


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-07-24  7:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-23 23:40 [patch] big IRQ lock removal, 2.5.27-G0 Oleg Nesterov
2002-07-23 23:50 ` Ingo Molnar
2002-07-23 23:54   ` Ingo Molnar
2002-07-24  1:00   ` Oleg Nesterov
2002-07-24  7:19     ` Ingo Molnar
2002-07-24  3:07   ` Oleg Nesterov
  -- strict thread matches above, loose matches on Subject: below --
2002-07-23 16:26 Ingo Molnar

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.