Re: PROBLEM: possible proceses leak

From: Linus Torvalds
Date: Mon Dec 08 2003 - 14:09:36 EST




On Mon, 8 Dec 2003, Andrew Volkov wrote:
>
> In all kernels (up to 2.6-test11) next sequence of code
> in __down/__down_interruptible function
> (arch/i386/kernel/semaphore.c) may cause processes or threads leaking.

Nope. Quite the reverse, in fact. Having the "state" setting above the
wait-queue is usually a good idea, since it means that there are less
races to worry about.

> |-----tsk->state = TASK_UNINTERRUPTIBLE; <----- BUG:
> | -- If "do_schedule" from kernel/schedule will calling
> | at this point, due to expire of time slice,
> | then current task will removed from run_queue,
> | but doesn't added to any waiting queue, and hence
> | will never run again. --

No.

Kernel preemption is special, and it will preempt the process WITHOUT
CHANGING the state of it. See the PREEMPT_ACTIVE test in schedule(). The
process will still be left on the run-queue, and it will be run again,
even if it is marked sleeping.

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