The patch titled Subject: printk: add clear_idx symbol to vmcoreinfo has been added to the -mm tree. Its filename is printk-add-clear_idx-symbol-to-vmcoreinfo.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/printk-add-clear_idx-symbol-to-vmcoreinfo.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/printk-add-clear_idx-symbol-to-vmcoreinfo.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ivan Delalande <colona@xxxxxxxxxx> Subject: printk: add clear_idx symbol to vmcoreinfo This allows us to extract from the vmcore only the messages emitted since the last time the ring buffer was cleared. We just have to make sure its value is always up-to-date, when old messages are discarded to free space in log_make_free_space() for example. Signed-off-by: Zeyu Zhao <zzy8200@xxxxxxxxx> Signed-off-by: Ivan Delalande <colona@xxxxxxxxxx> Cc: Kay Sievers <kay@xxxxxxxx> Cc: Neil Horman <nhorman@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/printk/printk.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff -puN kernel/printk/printk.c~printk-add-clear_idx-symbol-to-vmcoreinfo kernel/printk/printk.c --- a/kernel/printk/printk.c~printk-add-clear_idx-symbol-to-vmcoreinfo +++ a/kernel/printk/printk.c @@ -368,16 +368,20 @@ static int logbuf_has_space(u32 msg_size static int log_make_free_space(u32 msg_size) { - while (log_first_seq < log_next_seq) { - if (logbuf_has_space(msg_size, false)) - return 0; + while (log_first_seq < log_next_seq && + !logbuf_has_space(msg_size, false)) { /* drop old messages until we have enough contiguous space */ log_first_idx = log_next(log_first_idx); log_first_seq++; } + if (clear_seq < log_first_seq) { + clear_seq = log_first_seq; + clear_idx = log_first_idx; + } + /* sequence numbers are equal, so the log buffer is empty */ - if (logbuf_has_space(msg_size, true)) + if (logbuf_has_space(msg_size, log_first_seq == log_next_seq)) return 0; return -ENOMEM; @@ -855,6 +859,7 @@ void log_buf_kexec_setup(void) VMCOREINFO_SYMBOL(log_buf); VMCOREINFO_SYMBOL(log_buf_len); VMCOREINFO_SYMBOL(log_first_idx); + VMCOREINFO_SYMBOL(clear_idx); VMCOREINFO_SYMBOL(log_next_idx); /* * Export struct printk_log size and field offsets. User space tools can @@ -1217,12 +1222,6 @@ static int syslog_print_all(char __user u32 idx; enum log_flags prev; - if (clear_seq < log_first_seq) { - /* messages are gone, move to first available one */ - clear_seq = log_first_seq; - clear_idx = log_first_idx; - } - /* * Find first record that fits, including all following records, * into the user-provided buffer for this dump. _ Patches currently in -mm which might be from colona@xxxxxxxxxx are printk-add-clear_idx-symbol-to-vmcoreinfo.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html