[Crash-utility] [PATCH] Add alternate HZ calculation using write_expire

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Mon Apr 26 01:37:08 UTC 2021


Linux 4.8 and later kernels that contain kernel commit 9a7f38c42c2b
("cfq-iosched: Convert from jiffies to nanoseconds") changed the
definition of cfq_slice_async, and it cannot be used to calculate
the HZ value.

Add alternate HZ calculation using write_expire, which depends on
CONFIG_MQ_IOSCHED_DEADLINE or CONFIG_IOSCHED_DEADLINE.

Signed-off-by: Kazuhito Hagio <k-hagio-ab at nec.com>
---
 task.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/task.c b/task.c
index ce2b55f430e0..36cf259e5d7b 100644
--- a/task.c
+++ b/task.c
@@ -432,6 +432,29 @@ task_init(void)
 			    	    "cfq_slice_async exists: setting hz to %d\n", 
 					machdep->hz);
 		}
+	} else if ((symbol_exists("dd_init_queue") &&
+	    gdb_set_crash_scope(symbol_value("dd_init_queue"), "dd_init_queue")) ||
+	    (symbol_exists("deadline_init_queue") &&
+	    gdb_set_crash_scope(symbol_value("deadline_init_queue"), "deadline_init_queue"))) {
+		char buf[BUFSIZE];
+		uint write_expire = 0;
+
+		open_tmpfile();
+		sprintf(buf, "printf \"%%d\", write_expire");
+		if (gdb_pass_through(buf, pc->tmpfile, GNU_RETURN_ON_ERROR)) {
+			rewind(pc->tmpfile);
+			if (fgets(buf, BUFSIZE, pc->tmpfile))
+				sscanf(buf, "%d", &write_expire);
+		}
+		close_tmpfile();
+
+		if (write_expire) {
+			machdep->hz = write_expire / 5;
+			if (CRASHDEBUG(2))
+				fprintf(fp, "write_expire exists: setting hz to %d\n",
+					machdep->hz);
+		}
+		gdb_set_crash_scope(0, NULL);
 	}
 
 	if (VALID_MEMBER(runqueue_arrays)) 
-- 
2.18.4





More information about the Crash-utility mailing list