On 2023/07/31 11:08, HAGIO KAZUHITO(萩尾 一仁) wrote: > On 2023/07/28 20:15, Lianbo Jiang wrote: >> Currently, the "foreach DE ps -m" command may display "DE" as well as >> "ZO" state tasks as below: >> >> crash> foreach DE ps -m >> ... >> [0 00:00:00.040] [ZO] PID: 11458 TASK: ffff91c75680d280 CPU: 7 COMMAND: "ora_w01o_p01mci" >> [0 00:00:00.044] [ZO] PID: 49118 TASK: ffff91c7bf3e8000 CPU: 19 COMMAND: "oracle_49118_p0" >> [0 00:00:00.050] [ZO] PID: 28748 TASK: ffff91a7cbde3180 CPU: 2 COMMAND: "ora_imr0_p01sci" >> [0 00:00:00.050] [DE] PID: 28405 TASK: ffff91a7c8eb0000 CPU: 27 COMMAND: "ora_vktm_p01sci" >> [0 00:00:00.051] [ZO] PID: 31716 TASK: ffff91a7f7192100 CPU: 6 COMMAND: "ora_p001_p01sci" >> ... > > Could you elaborate on why this happens? > > I'm concerned about the difference of the conditions between printing > the "DE" state in task_state_string() and printing a "DE" task in the > foreach function in your patch: > > char * > task_state_string(ulong task, char *buf, int verbose) > { > ... > if ((state & _DEAD_) && !set) { > sprintf(buf, "DE"); > valid++; > set++; > } > > On the other hand, the following means that "state == _DEAD_" is the > "DE" state, not "state & _DEAD". So I'm wondering if "foreach DE" > command might drop some "DE" tasks with your patch? > > > + if (task_state(tc->task) != _DEAD_) > > + continue; Just an idea. It seems not good to have the two decision routines, we may be able to use the task_state_string() function here, too? For example, fd->state = arg[optind]; // fd->state is changed to char*. e.g. "DE" foreach() if (fd->flags & FOREACH_STATE) { if (!STREQ(fd->state, task_state_string(tc-task, buf, 0))) continue; Thanks, Kazu > > Thanks, > Kazu > >> >> That is not expected behavior, the "foreach" command needs to handle >> such cases. Let's add a check to determine if the task state identifier >> is specified and the task state identifier is equal to the "DE", so that >> it can filter out the non-"DE" state tasks. >> >> With the patch: >> crash> foreach DE ps -m >> [0 00:00:00.050] [DE] PID: 28405 TASK: ffff91a7c8eb0000 CPU: 27 COMMAND: "ora_vktm_p01sci" >> crash> >> >> Signed-off-by: Lianbo Jiang <lijiang@xxxxxxxxxx> >> --- >> task.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/task.c b/task.c >> index b9076da35565..4f40c396b195 100644 >> --- a/task.c >> +++ b/task.c >> @@ -7043,6 +7043,9 @@ foreach(struct foreach_data *fd) >> if (fd->state == _RUNNING_) { >> if (task_state(tc->task) != _RUNNING_) >> continue; >> + } else if (fd->state == _DEAD_) { >> + if (task_state(tc->task) != _DEAD_) >> + continue; >> } else if (fd->state & _UNINTERRUPTIBLE_) { >> if (!(task_state(tc->task) & _UNINTERRUPTIBLE_)) >> continue; > -- > Crash-utility mailing list > Crash-utility@xxxxxxxxxx > https://listman.redhat.com/mailman/listinfo/crash-utility > Contribution Guidelines: https://github.com/crash-utility/crash/wiki -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility Contribution Guidelines: https://github.com/crash-utility/crash/wiki