[Crash-utility] [PATCH 3/3] Add support for TASK_NEW task state

Kazuhito Hagio k-hagio at ab.jp.nec.com
Thu Jul 19 14:51:50 UTC 2018


kernel commit 7dc603c902 ("sched/fair: Fix PELT integrity for new
tasks") introduced TASK_NEW state. This patch adds support for it
as 'NE' state.

Signed-off-by: Kazuhito Hagio <k-hagio at ab.jp.nec.com>
---
 help.c |  4 ++--
 task.c | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/help.c b/help.c
index 14cae8e..83cda7c 100644
--- a/help.c
+++ b/help.c
@@ -837,7 +837,7 @@ char *help_foreach[] = {
 "   kernel  perform the command(s) on all kernel threads.",
 "   active  perform the command(s) on the active thread on each CPU.",
 "    state  perform the command(s) on all tasks in the specified state, which",
-"           may be one of: RU, IN, UN, ST, ZO, TR, SW, DE, WA, PA or ID.\n",
+"           may be one of: RU, IN, UN, ST, ZO, TR, SW, DE, WA, PA, ID or NE.\n",
 "  If none of the task-identifying arguments above are entered, the command",
 "  will be performed on all tasks.\n",
 "  command  select one or more of the following commands to be run on the tasks",
@@ -1292,7 +1292,7 @@ char *help_ps[] = {
 "    3. the CPU number that the task ran on last.",
 "    4. the task_struct address or the kernel stack pointer of the process.",
 "       (see -s option below)",
-"    5. the task state (RU, IN, UN, ZO, ST, TR, DE, SW, WA, PA, ID).",
+"    5. the task state (RU, IN, UN, ZO, ST, TR, DE, SW, WA, PA, ID, NE).",
 "    6. the percentage of physical memory being used by this task.",
 "    7. the virtual address size of this task in kilobytes.",
 "    8. the resident set size of this task in kilobytes.",
diff --git a/task.c b/task.c
index 5412215..39fb0de 100644
--- a/task.c
+++ b/task.c
@@ -5172,6 +5172,7 @@ static long _WAKING_ = TASK_STATE_UNINITIALIZED;
 static long _NONINTERACTIVE_ = TASK_STATE_UNINITIALIZED;
 static long _PARKED_ = TASK_STATE_UNINITIALIZED;
 static long _NOLOAD_ = TASK_STATE_UNINITIALIZED;
+static long _NEW_ = TASK_STATE_UNINITIALIZED;
 
 #define valid_task_state(X) ((X) != TASK_STATE_UNINITIALIZED)
 
@@ -5249,6 +5250,10 @@ dump_task_states(void)
 	if (valid_task_state(_NOLOAD_))
 		fprintf(fp, "            NOLOAD: %3ld (0x%lx)\n", 
 			_NOLOAD_, _NOLOAD_);
+
+	if (valid_task_state(_NEW_))
+		fprintf(fp, "               NEW: %3ld (0x%lx)\n",
+			_NEW_, _NEW_);
 }
 
 
@@ -5332,6 +5337,9 @@ old_defaults:
 			case 'N':
 				_NOLOAD_ = (1 << (i-1));
 				break;
+			case 'n':
+				_NEW_ = (1 << (i-1));
+				break;
 			}
 		}
 
@@ -5401,6 +5409,7 @@ old_defaults:
 			_WAKEKILL_ = (bitpos << 2); /* TASK_WAKEKILL */
 			_WAKING_ = (bitpos << 3);   /* TASK_WAKING */
 			_NOLOAD_ = (bitpos << 4);   /* TASK_NOLOAD */
+			_NEW_ = (bitpos << 5);      /* TASK_NEW */
 		}
 	} else if (THIS_KERNEL_VERSION >= LINUX(2,6,32)) {
 		/*
@@ -5490,6 +5499,10 @@ task_state_string_verbose(ulong task, char *buf)
 		sprintf(&buf[strlen(buf)], "%sTASK_NOLOAD",
 			count++ ? "|" : "");
 
+	if (valid_task_state(_NEW_) && (state & _NEW_))
+		sprintf(&buf[strlen(buf)], "%sTASK_NEW",
+			count++ ? "|" : "");
+
 	if (valid_task_state(_NONINTERACTIVE_) &&
 	    (state & _NONINTERACTIVE_))
 		sprintf(&buf[strlen(buf)], "%sTASK_NONINTERACTIVE",
@@ -5589,6 +5602,11 @@ task_state_string(ulong task, char *buf, int verbose)
 		valid++;
 	}
 
+	if (state == _NEW_) {
+		sprintf(buf, "NE");
+		valid++;
+	}
+
 	if (valid && exclusive) 
 		strcat(buf, "EX");
 
@@ -6287,6 +6305,7 @@ cmd_foreach(void)
 		    STREQ(args[optind], "PA") ||
 		    STREQ(args[optind], "WA") ||
 		    STREQ(args[optind], "ID") ||
+		    STREQ(args[optind], "NE") ||
 		    STREQ(args[optind], "SW")) {
 
 			if (fd->flags & FOREACH_STATE)
@@ -6314,6 +6333,8 @@ cmd_foreach(void)
 				fd->state = _WAKING_;
 			else if (STREQ(args[optind], "ID"))
 				fd->state = _UNINTERRUPTIBLE_|_NOLOAD_;
+			else if (STREQ(args[optind], "NE"))
+				fd->state = _NEW_;
 
 			if (fd->state == TASK_STATE_UNINITIALIZED)
 				error(FATAL, 
-- 
1.8.3.1




More information about the Crash-utility mailing list