public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix TASK_STOPPED vs TASK_NONINTERACTIVE interaction
@ 2005-09-29 15:58 Oleg Nesterov
  2005-09-29 16:02 ` Linus Torvalds
  0 siblings, 1 reply; 12+ messages in thread
From: Oleg Nesterov @ 2005-09-29 15:58 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Linus Torvalds, Andrew Morton

do_signal_stop:

	for_each_thread(t) {
		if (t->state < TASK_STOPPED)
			++sig->group_stop_count;
	}

However, TASK_NONINTERACTIVE > TASK_STOPPED, so this loop will not
count TASK_INTERRUPTIBLE | TASK_NONINTERACTIVE threads.

See also wait_task_stopped(), which checks ->state > TASK_STOPPED.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.14-rc2/include/linux/sched.h~6_NONINT	2005-09-24 18:33:51.000000000 +0400
+++ 2.6.14-rc2/include/linux/sched.h	2005-09-29 23:42:25.000000000 +0400
@@ -110,11 +110,11 @@ extern unsigned long nr_iowait(void);
 #define TASK_RUNNING		0
 #define TASK_INTERRUPTIBLE	1
 #define TASK_UNINTERRUPTIBLE	2
-#define TASK_STOPPED		4
-#define TASK_TRACED		8
-#define EXIT_ZOMBIE		16
-#define EXIT_DEAD		32
-#define TASK_NONINTERACTIVE	64
+#define TASK_NONINTERACTIVE	4
+#define TASK_STOPPED		8
+#define TASK_TRACED		16
+#define EXIT_ZOMBIE		32
+#define EXIT_DEAD		64
 
 #define __set_task_state(tsk, state_value)		\
 	do { (tsk)->state = (state_value); } while (0)

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [PATCH] fix TASK_STOPPED vs TASK_NONINTERACTIVE interaction
@ 2005-09-29 21:54 Roland McGrath
  2005-09-29 22:15 ` Linus Torvalds
  2005-09-30 16:51 ` Oleg Nesterov
  0 siblings, 2 replies; 12+ messages in thread
From: Roland McGrath @ 2005-09-29 21:54 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton; +Cc: linux-kernel, Oleg Nesterov

I am dubious about this change.  I don't see a corresponding change to
fs/proc/array.c where it knows what all the bit values are.  I am not at
all sure there aren't other places that know these values and need a fixup
if you change them.

Any tests using < TASK_STOPPED or the like are left over from the time when
the TASK_ZOMBIE and TASK_DEAD bits were in the same word, and it served to
check for "stopped or dead".  I think this one in do_signal_stop is the
only such case.  It has been buggy ever since exit_state was separated.
Changing the bit values doesn't fix the bug that it isn't checking the
exit_state value.  This patch is probably the right fix for that, but I
have not tested it.

Signed-off-by: Roland McGrath <roland@redhat.com>

--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1775,7 +1775,8 @@ do_signal_stop(int signr)
 				 * stop is always done with the siglock held,
 				 * so this check has no races.
 				 */
-				if (t->state < TASK_STOPPED) {
+				if (!t->exit_state &&
+				    !(t->state & (TASK_STOPPED|TASK_TRACED))) {
 					stop_count++;
 					signal_wake_up(t, 0);
 				}


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [PATCH] fix TASK_STOPPED vs TASK_NONINTERACTIVE interaction
@ 2005-10-03 23:49 linux
  0 siblings, 0 replies; 12+ messages in thread
From: linux @ 2005-10-03 23:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: torvalds

> Any CPU I can think of has a "and + compare against zero". x86 calls it 
> "test", although a regular "and" will do it too. ppc has "andi.". alpha 
> comparisons are against registers being zero or not, so again it's an 
> "and".

About the only one for which "cmp" is faster than "test" is the 680x0.
"cmp" is a subtract that doesn't write the result (except to the condition
codes).  "tst" (called "bit" on the VAX and 6502) is a similar AND.

The 68k doesn't have that.  You have to obliterate one of the operands,
and it can't be the immediate operand, so it's often two instructions.

The 68k does have an instruction called "test", but it just sets the
condition codes based on a single operand (since it doesn't set the
condition codes on a simple move).

It *does* have a single-bit test instruction, which evaluates
"if (x & 1<<y)" in one cycle, but that doesn't help for multi-bit masks
like "if (x % 4096 == 0)"

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

end of thread, other threads:[~2005-10-03 23:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-29 15:58 [PATCH] fix TASK_STOPPED vs TASK_NONINTERACTIVE interaction Oleg Nesterov
2005-09-29 16:02 ` Linus Torvalds
2005-09-29 16:25   ` Paulo Marques
2005-10-03  2:54   ` Coywolf Qi Hunt
2005-10-03  3:24     ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2005-09-29 21:54 Roland McGrath
2005-09-29 22:15 ` Linus Torvalds
2005-09-30 16:51 ` Oleg Nesterov
2005-09-30 17:18   ` Linus Torvalds
2005-10-01 11:32     ` Oleg Nesterov
2005-10-02  1:12     ` Roland McGrath
2005-10-03 23:49 linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox