Skip to contentSkip to conversation

vmcore-dmesg: do not use logged_chars as dmesg length

PATCH In review Dangyi Liu 2 participants 3 messages Oct 28, 2015

Subsystems (2)
lore
Share & tools
lore

Dangyi Liu

author
#0 lore raw

PATCH 1/1 vmcore-dmesg: do not use logged_chars as dmesg length

logged_chars would be set to 0 by dmesg -c, but we want to get the full dmesg after crash. So instead of using logged_chars directly, we calculate it by ourselves.

Now logged_chars is set to the minimum of log_end and log_buf_len, which is coherent to how crash utility deals with dmesg length.

---
 vmcore-dmesg/vmcore-dmesg.c | 3 +++
 1 file changed, 3 insertions(+)
vmcore-dmesg/vmcore-dmesg.c +3 -0
index f47ee11..ec2570f 100644
@@ -540,6 +540,9 @@ static void dump_dmesg_legacy(int fd)
 		exit(53);
 	}
 
+	// `dmesg -c` would set logged_chars to 0, then we cannot get a full dmesg.
+	logged_chars = log_end < log_buf_len ? log_end : log_buf_len;
+
 	write_to_stdout(buf + (log_buf_len -  logged_chars), logged_chars);
 }
 
Signature · 7 lines
2.4.3


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 17 lines · Dangyi Liu

logged_chars would be set to 0 by dmesg -c, but we want to get the full dmesg after crash. So instead of using logged_chars directly, we calculate it by ourselves.

Now logged_chars is set to the minimum of log_end and log_buf_len, which is coherent to how crash utility deals with dmesg length.

---
 vmcore-dmesg/vmcore-dmesg.c | 3 +++
 1 file changed, 3 insertions(+)
vmcore-dmesg/vmcore-dmesg.c +0 -0
index f47ee11..ec2570f 100644

vmcore-dmesg/vmcore-dmesg.c static void dump_dmesg_legacy(int fd) · line 543

Quoted 4 lines
vmcore-dmesg/vmcore-dmesg.c +1 -0
@@ -540,6 +540,9 @@ static void dump_dmesg_legacy(int fd)
 		exit(53);
 	}
 
+	// `dmesg -c` would set logged_chars to 0, then we cannot get a full dmesg.

Please use /* */ style comment, also it is not a bug because
In theroy it is ok for only showing later dmesg after dmesg -c in current code. But crash utils and vmcore-dmesg in new log buf format support dumping all kernel messages which includes the part before dmesg -c. It is not harm to keep same behavior with them.

So the comment should be changed to something like below:
/*
* To collect full dmesg including the part before dmesg -c is useful for
* later debugging. Use same logic as what crash utility is using. */

Quoted 15 lines
vmcore-dmesg/vmcore-dmesg.c +2 -0
+	logged_chars = log_end < log_buf_len ? log_end : log_buf_len;
+
 	write_to_stdout(buf + (log_buf_len -  logged_chars), logged_chars);
 }
 
Signature · 7 lines
2.4.3


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#2 lore raw
Quoted 9 lines · Dave Young

Please use /* */ style comment, also it is not a bug because In theroy it is ok for only showing later dmesg after dmesg -c in current code.
But crash utils and vmcore-dmesg in new log buf format support dumping all
kernel messages which includes the part before dmesg -c. It is not harm to
keep same behavior with them.

Quoted 6 lines

So the comment should be changed to something like below:
/*
* To collect full dmesg including the part before dmesg -c is
useful for
* later debugging. Use same logic as what crash utility is using. */

OK, I'll update the comment and send again.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec