Seems like a race or unhandled situation with ksoftirqd scheduling/management

Seems like a race or unhandled situation with ksoftirqd scheduling/management

Post by C Hanish Meno » Thu, 23 May 2002 02:40:09



Hi,

On a mips target to which I have added HAL for linux, I found that the
system time wasn't going forward. On further look, I found that jiffies
is getting updated properly (as expected), but ksoftirqd (and all its
siblings tasklets, soft timers, bottom halves ...) aren't working.

This is the sequence of events that lead to the situation where
ksoftirqd is left out in the cold.

   a) ksoftirqd gets scheduled

   b) ksoftirqd doesn't find any pending softirqs

   c) ksoftirqd gives back control to scheduler

   d) schedular REMOVES ksoftirqd from run_queue
        (TASK_INTERRUPTIBLE but no signal pending)

   e) timer interrupt occurs.

   f) timer interrupt handler sets mark_bh for TIMER_BH

   g) mark_bh inturn task_hi_schedules TIMER_BH related tasklet

   h) task_hi_schedule adds the tasklet to its list to process

   i) task_hi_schedule calls cpu_raise_softirq for this
        cpu and HI_SOFTIRQ

   j) cpu_raise_softirq sets the corresponding pending bit.

   k) cpu_raise_softirq DOESNOT wakeup_softirqd
      because currently its in INTERRUPT_CONTEXT. (local_irq_count)

   So if no other events occur with inturn could lead to the
wakeup_softirqd being called, then ksoftirqd doesn't get into
run_queue and doesn't run. In my target currently only the
TIMER_BH uses the softirq based mechanism. And it won't trigger
ksoftirqd to be woken up.

   According to the comment in cpu_raise_softirq it doesn't
wakeup_softirqd in irq context because on returning from a irq
softirqd will be run,  but it doesn't seem to be valid in any
architectures (have varified x86, mips). Because on returning
from irq context, just the scheduler gets called, but as
the ksoftirqd is not in the run queue, it won't get scheduled.

Only way ksoftirqd can get into the runqueue is if, wakeup_softirqd
gets called, which inturn occurs only from cpu_raise_softirqd. Which
can occur for my target only as part of mark_bh(TIMER_BH) (that to
only the 1st time it occurs), but which won't trigger wakeup_softirqd
because of interrupt context.

_Am I_ missing some other way ksoftirqd could endup in the run_queue. I
have looked around to some extent, but cann't see any other way how
ksoftirqd could get into the runqueue. Have to admit, haven't looked
fully into the linux scheduling logic, but logically I don't seem to
have left out any possibility.

My current Solution:

Currenlty I have just commented out the check for Interrupt and BH
context in cpu_raise_softirqd before calling wakeup_softirqd. It works
fine now. Also it doesn't seem to be a problem, because
cpu_raise_softirqd seems to get called only if required and also there
seems to be enough checks and bounds so that it doesn't get called
repeatedly.

NOTE:

I am using 2.4.16 with linux-mips patchs (from sourceforge) for my linux
port to the target. Regarding this problem, I have looked into linux
2.4.18 and also linux-2.4.19pre4, the code leading to this situation
hasn't changed in them, so the problem should/will still be there.

Keep :-)
HanishKVC

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Seems like a race or unhandled situation with ksoftirqd scheduling/management

Post by Andi Klee » Thu, 23 May 2002 03:30:09



Quote:>    According to the comment in cpu_raise_softirq it doesn't
> wakeup_softirqd in irq context because on returning from a irq
> softirqd will be run,  but it doesn't seem to be valid in any
> architectures (have varified x86, mips). Because on returning
> from irq context, just the scheduler gets called, but as
> the ksoftirqd is not in the run queue, it won't get scheduled.

At least i386 runs the softirqs at the end of do_IRQ.

ksoftirqd is just supposed to be a fallback mechanism for the case
of soft irqs eating excessive runtime or one softirq triggering another
(common case is networking and serial softirq for BH). It is not
the primary way to run softirqs.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Seems like a race or unhandled situation with ksoftirqd scheduling/management

Post by C Hanish Meno » Thu, 23 May 2002 04:00:10


Hi Andi


> At least i386 runs the softirqs at the end of do_IRQ.

> ksoftirqd is just supposed to be a fallback mechanism for the case
> of soft irqs eating excessive runtime or one softirq triggering another
> (common case is networking and serial softirq for BH). It is not
> the primary way to run softirqs.

Oops, You are right, i386 and also the generic mips irq.c has code in
do_IRQ to call do_softirq.

But most of the target specific irq.c in mips, don't seem to follow this
convention. Even when I started my port, I had based my interrupt
subsystem after looking into some of these target specific irq.c's.

So I was expecting this call to softirqs occuring from within
kernel/entry.S after ret_from_irq. And as there is no code there to this
end, I came to my flawed conclusion.

Sorry about this wrong assumption.
I have got the solution to my problem. However have to check out with
the mips target guys has to how they are taking care of softirqs. When
they aren't calling do_softirq from do_IRQ or any other part of
interrupt subsystem.

Keep :-)
HanishKVC

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. Fix vmtruncate race and distributed filesystem race

Paul McKenney and I sat down today and hashed out just what the races are
for both  vmtruncate and the distributed filesystems.  We took Andrea's
idea of using seqlocks and came up with a simple solution that definitely
fixes the race in vmtruncate, as well as most likely the invalidate race in
distributed filesystems.  Paul is going to discuss it with the DFS folks to
verify that it's a complete fix for them, but neither of us can see a hole.

Anyway, here's the patch.

Dave McCracken

======================================================================
Dave McCracken          IBM Linux Base Kernel Team      1-512-838-3059

  trunc-2.5.70-mm8-1.diff
4K Download

2. Compaq Proliant 1600 with RAID and RH 5.1

3. schedule() seems to have changed.

4. Gatewayed bandwidth Limitations

5. FSS scheduling class & ressource management

6. Huge console switching lags

7. Looking for tape management & job scheduling systems

8. sound card problems with sblive

9. description of process scheduling and memory management

10. Help re: filesystem/block-I/O scheduling or memory management please

11. Job Scheduling/Management

12. Help re: filesystem/block-I/O scheduling and/or memory management please

13. Calendar-Scheduling-Time management