[Crash-utility] [PATCH] Fix machdep->HZ calculation for kernel versions > 2.6.0

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Fri Apr 23 09:44:11 UTC 2021


-----Original Message-----
> > As for the 'write_expire' way, I found that it can be printed after
> > "set scope dd_init_queue" or "set scope deadline_init_queue" on old kernels.
> >
> > crash> p write_expire
> > No symbol "write_expire" in current context.
> > p: gdb request failed: p write_expire
> > crash> set scope dd_init_queue
> > scope: ffffffffa43e3f80 (dd_init_queue)
> > crash> p write_expire
> > $1 = 5000
> >
> > Maybe we can make use of gdb_set_crash_scope() and gdb_pass_through() to
> > get this value?
> >
> 
> The 'write_expire' is a static variable, which needs to get its value from
> gdb. Seems that it is a bit complicated.
> 
> But It's worth having a try.

The following is a draft patch.  It worked for some dumpfiles I have
from 2.6.16 to 5.11 including RHEL8.0 one.  What do you think?

diff --git a/task.c b/task.c
index 423cd454502b..654df6b1220c 100644
--- a/task.c
+++ b/task.c
@@ -417,7 +417,33 @@ task_init(void)
 
 	STRUCT_SIZE_INIT(cputime_t, "cputime_t");
 
-	if (symbol_exists("cfq_slice_async")) {
+	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);
+			while (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);
+		}
+		fprintf(fp, "write_expire = %d, machdep->hz = %d\n", write_expire, machdep->hz);
+		gdb_set_crash_scope(0, NULL);
+
+	} else if (symbol_exists("cfq_slice_async")) {
 		uint cfq_slice_async;
 
 		get_symbol_data("cfq_slice_async", sizeof(int),





More information about the Crash-utility mailing list