Skip to contentSkip to conversation

cleanup ptrace stops and remove notify_parent

PATCH Albert Cahalan 3 participants 3 messages Aug 31, 2004 – Sep 1, 2004

lore
Share & tools
lore
#0 lore raw

fs/proc/array.c 2004-08-30 18:43:29.000000000 -0700 static const char *task_state_array[] = · line 136

Quoted 13 lines · Roland McGrath

diff -rBzpu linux-2.6.9/fs/proc/array.c linux-2.6-ptracefix/fs/proc/array.c

fs/proc/array.c 2004-08-30 18:43:29.000000000 -0700 renamed from fs/proc/array.c 2004-08-30 20:10:50.000000000 -0700 +3 -2
@@ -130,8 +130,9 @@ static const char *task_state_array[] = 
  "S (sleeping)",  /*  1 */
  "D (disk sleep)", /*  2 */
  "T (stopped)",  /*  4 */
- "Z (zombie)",  /*  8 */
- "X (dead)"  /* 16 */
+ "T (tracing stop)", /*  8 */
+ "Z (zombie)",  /* 16 */
+ "X (dead)"  /* 32 */
 };

For TASK_DEAD and TASK_TRACED, might you be hiding some underlying state? I want to display stuff like:

T    stopped (not traced)
TX   stopped, and being traced
RX   running or runnable, and being traced
ZE   zombie, and trying to exit
RXE  running, trying to exit, and traced

It's troubling the way TASK_DEAD and TASK_TRACED show up as actual states and hide any other stuff. I'd much prefer them to be flags of some sort.

kernel/power/process.c 2004-08-30 18:20:05.000000000 -0700 static inline int freezeable(struct task · line 29

Quoted 10 lines

diff -rBzpu linux-2.6.9/kernel/power/process.c linux-2.6-ptracefix/kernel/power/process.c

kernel/power/process.c 2004-08-30 18:20:05.000000000 -0700 renamed from kernel/power/process.c 2004-08-30 20:10:51.000000000 -0700 +2 -1
@@ -25,7 +25,8 @@ static inline int freezeable(struct task
      (p->flags & PF_NOFREEZE) ||
      (p->state == TASK_ZOMBIE) ||
      (p->state == TASK_DEAD) ||
-     (p->state == TASK_STOPPED))
+     (p->state == TASK_STOPPED) ||
+     (p->state == TASK_TRACED))

(p->state & (TASK_ZOMBIE|TASK_DEAD|TASK_STOPPED|TASK_TRACED))

kernel/power/process.c 2004-08-30 18:20:05.000000000 -0700 int freeze_processes(void) · line 76

Quoted 7 lines
kernel/power/process.c 2004-08-30 18:20:05.000000000 -0700 renamed from kernel/power/process.c 2004-08-30 20:10:51.000000000 -0700 +1 -0
@@ -70,6 +71,7 @@ int freeze_processes(void)
    if (!freezeable(p))
     continue;
    if ((p->flags & PF_FROZEN) ||
+       (p->state == TASK_TRACED) ||
        (p->state == TASK_STOPPED))
     continue;

(p->state & (TASK_TRACED|TASK_STOPPED))

kernel/power/process.c 2004-08-30 18:20:05.000000000 -0700 static void show_task(task_t * p) · line 3673

Quoted 6 lines
kernel/power/process.c 2004-08-30 18:20:05.000000000 -0700 renamed from kernel/power/process.c 2004-08-30 20:10:51.000000000 -0700 +1 -1
@@ -3670,7 +3670,7 @@ static void show_task(task_t * p)
  task_t *relative;
  unsigned state;
  unsigned long free = 0;
- static const char *stat_nam[] = { "R", "S", "D", "T", "Z", "W" };
+ static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };

The 't' doesn't match what you do elsewhere. Try "TX" for that. I think "ZX" would be right for an exiting process.

#1 lore raw
Quoted 1 line

For TASK_DEAD and TASK_TRACED, might you be hiding some underlying state?

Not really.

Quoted 7 lines

I want to display stuff like:

T    stopped (not traced)
TX   stopped, and being traced
RX   running or runnable, and being traced
ZE   zombie, and trying to exit
RXE  running, trying to exit, and traced

These distinctions don't exist in any data structures, except for the PF_EXITING flag.

Quoted 3 lines

It's troubling the way TASK_DEAD and TASK_TRACED show up as actual states and hide any other stuff. I'd much prefer them to be flags of some sort.

That's a different implementation than what we've got now. Feel free to try to make it work. Linus has talked before about treating the state as a bitmask, but the code is not actually written that way now.

#2 lore raw
Quoted 4 lines · Roland McGrath

That's a different implementation than what we've got now. Feel free to try to make it work. Linus has talked before about treating the state as a bitmask, but the code is not actually written that way now.

The state itself shouldn't be a bitmask, but the _values_ get used for masks in quite a few places (ie "task->state & (TASK_DEAD | TASK_ZOMBIE)").

Linus