All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vmcore-dmesg: do not use logged_chars as dmesg length
@ 2015-10-28  5:38 Dangyi Liu
  2015-10-28  7:06 ` Dave Young
  0 siblings, 1 reply; 3+ messages in thread
From: Dangyi Liu @ 2015-10-28  5:38 UTC (permalink / raw)
  To: kexec; +Cc: 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.

Signed-off-by: Dangyi Liu <dliu@redhat.com>
---
 vmcore-dmesg/vmcore-dmesg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index f47ee11..ec2570f 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -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);
 }
 
-- 
2.4.3


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vmcore-dmesg: do not use logged_chars as dmesg length
  2015-10-28  5:38 [PATCH] vmcore-dmesg: do not use logged_chars as dmesg length Dangyi Liu
@ 2015-10-28  7:06 ` Dave Young
  2015-10-28  7:34   ` Dangyi Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Young @ 2015-10-28  7:06 UTC (permalink / raw)
  To: Dangyi Liu; +Cc: kexec

On 10/28/15 at 01:38pm, Dangyi Liu wrote:
> 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.
> 
> Signed-off-by: Dangyi Liu <dliu@redhat.com>
> ---
>  vmcore-dmesg/vmcore-dmesg.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
> index f47ee11..ec2570f 100644
> --- a/vmcore-dmesg/vmcore-dmesg.c
> +++ b/vmcore-dmesg/vmcore-dmesg.c
> @@ -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.
 */

> +	logged_chars = log_end < log_buf_len ? log_end : log_buf_len;
> +
>  	write_to_stdout(buf + (log_buf_len -  logged_chars), logged_chars);
>  }
>  
> -- 
> 2.4.3
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 
> 

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vmcore-dmesg: do not use logged_chars as dmesg length
  2015-10-28  7:06 ` Dave Young
@ 2015-10-28  7:34   ` Dangyi Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Dangyi Liu @ 2015-10-28  7:34 UTC (permalink / raw)
  To: Dave Young; +Cc: kexec

On Wed, 2015-10-28 at 15:06 +0800, Dave Young wrote:
> 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.
>  */

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


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-28  7:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-28  5:38 [PATCH] vmcore-dmesg: do not use logged_chars as dmesg length Dangyi Liu
2015-10-28  7:06 ` Dave Young
2015-10-28  7:34   ` Dangyi Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.