Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751238AbdILGHN (ORCPT ); Tue, 12 Sep 2017 02:07:13 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:38744 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750751AbdILGHM (ORCPT ); Tue, 12 Sep 2017 02:07:12 -0400 X-Google-Smtp-Source: ADKCNb4rIsCjy9+xrAKh8u9b7PmBkHQ3G2gatUfYIUYT2VkzFyg+Ove5g2p3aaTwAmKNgbGdenjk+nqQVzYjDrButXs= MIME-Version: 1.0 In-Reply-To: <20170817010541.GA20907@jagdpanzerIV.localdomain> References: <1501421870-12042-1-git-send-email-vichy.kuo@gmail.com> <20170801024303.GA469@jagdpanzerIV.localdomain> <20170817010541.GA20907@jagdpanzerIV.localdomain> From: pierre kuo Date: Tue, 12 Sep 2017 14:07:09 +0800 Message-ID: Subject: Re: [RFC V2] printk: add warning while drop partial text in msg To: Sergey Senozhatsky Cc: Petr Mladek , Sergey Senozhatsky , rostedt@goodmis.org, linux-kernel@vger.kernel.org Content-Type: multipart/mixed; boundary="001a114b0a388f330e0558f7daa0" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5411 Lines: 148 --001a114b0a388f330e0558f7daa0 Content-Type: text/plain; charset="UTF-8" hi Sergey and Petr > Hi, > On (08/11/17 00:55), pierre kuo wrote: > [..] >> And people will be hard to find out some part of message is left behind. >> (since the tail of original message is elegantly dropped by "\n") >> That is the reason I try to add such warning in msg_print_text. > > have you ever seen it (the truncation) in real life? The experimental steps are list as follows. Feel free to give your comments. Prerequisite: a) kernel version: commit: a80099a152d0 ("Merge tag 'xfs-4.13-merge-6' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux") 1. Add below patch in log_store to tell the content and length of log that saved in log_text(msg) for below step #2 . @@ -629,6 +629,11 @@ static int log_store(int facility, int level, msg->len = size; /* insert message */ + if (msg->text_len > 512) { + trace_printk("%s\n", log_text(msg)); + trace_printk("msg->text_len %d\n", msg->text_len); + } + log_next_idx += msg->len; log_next_seq++; 2. Use below kernel thread sample for adding the string to msg. int per_cpu_thread_fn(void* data) { unsigned int index = 0; unsigned int len = 0; char* local_string = kzalloc(2048, GFP_KERNEL); do { len += sprintf((local_string + len), "this is the %d line\n", index++); }while(len < 576); printk_deferred("%s", local_string); return 0; } 3. After running above #2, here is trace output from #1 (from the output, total "29 lines" of local_string has successfully saved in log_buf) # cat /sys/kernel/debug/tracing/trace; # tracer: nop # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | per_cpu_thread-81 [000] d..1 26.555745: log_store: this is the 0 line this is the 1 line this is the 2 line this is the 3 line this is the 4 line this is the 5 line this is the 6 line this is the 7 line this is the 8 line this is the 9 line this is the 10 line this is the 11 line this is the 12 line this is the 13 line this is the 14 line this is the 15 line this is the 16 line this is the 17 line this is the 18 line this is the 19 line this is the 20 line this is the 21 line this is the 22 line this is the 23 line this is the 24 line this is the 25 line this is the 26 line this is the 27 line this is the 28 line this is the 29 line per_cpu_thread-81 [000] d..1 26.555753: log_store: msg->text_len 589 4. Write a user mode programs with buffer size 2MB, triple size bigger than the text length in msg we saved in above #2, and repeatedly calling SYSLOG_ACTION_READ for getting the log. Then the log we got will _NOT_ show over than "this is the 26 line" as below, that mean line#27 ~ line#29 are missing. (the source is attached as "simple_log.tar.bz2") <4>[ 39.467710] this is the 0 line <4>[ 39.467710] this is the 1 line <4>[ 39.467710] this is the 2 line <4>[ 39.467710] this is the 3 line <4>[ 39.467710] this is the 4 line <4>[ 39.467710] this is the 5 line <4>[ 39.467710] this is the 6 line <4>[ 39.467710] this is the 7 line <4>[ 39.467710] this is the 8 line <4>[ 39.467710] this is the 9 line <4>[ 39.467710] this is the 10 line <4>[ 39.467710] this is the 11 line <4>[ 39.467710] this is the 12 line <4>[ 39.467710] this is the 13 line <4>[ 39.467710] this is the 14 line <4>[ 39.467710] this is the 15 line <4>[ 39.467710] this is the 16 line <4>[ 39.467710] this is the 17 line <4>[ 39.467710] this is the 18 line <4>[ 39.467710] this is the 19 line <4>[ 39.467710] this is the 20 line <4>[ 39.467710] this is the 21 line <4>[ 39.467710] this is the 22 line <4>[ 39.467710] this is the 23 line <4>[ 39.467710] this is the 24 line <4>[ 39.467710] this is the 25 line <4>[ 39.467710] this is the 26 line --001a114b0a388f330e0558f7daa0 Content-Type: application/x-bzip2; name="simple_log.tar.bz2" Content-Disposition: attachment; filename="simple_log.tar.bz2" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j7gdzhqn1 QlpoOTFBWSZTWasRgEAAAvZ/pOmwAEBa9///P6ffNP/v3/oABAAAgAhAAr0tlgKahkiGphTNTTNE 9NIGJ6j1GnqaGmQaNDQA0NPU0GSTJqZT1P1TI9Qwyg0B6gGjACMgZAxBpjmE0BoDRowjQYjTEyYm gwjQMgGTARSIBDKCeQINNNNNAADTRoxMgaekGI5uDN/pwq3UqIa+xabFmERURAgQSYSsLyGWbKst IgCIEooEqICiKdmbp7ZIWCpdy65DVu7ssutchiiAPygAE8+LDzSLW0pxuYX0IGZ5Y2ShUcGpgtzt Pi86sBFBNtg4yBoUjoMXKWWF/0SVBndPcn+qizCMhCK2PkZUY6coIGseWin0VlUYWhjJXLtzEn/Q CDMIO2o/UcsL0cG4ERBOSKzgBnvyOHHJUZadzBSkAsjPaW+SLBIjoepkcfQuNEKcrYA9JgGCvhZS 6lU8bzuLKjG3+dg6YEXqypfShrtnI1z6NZPejmLWKPE+SHs5KsxB4QUQZAqb4pDyozCBjn5od8d8 z7vAk6YYrmP5zpCO2jcNeHMX1N9SNGzt014zFMAtuRtZWudHiJ02VuMuqqSQUpTMedGloX0ZZJ2M aPIll16N45+dH10xkSTA64QS3seQ2vd7KQm8DSRHc2qSCex/KvmUahC8m/vT7cGCwFdEM4x5Ohed GRZVwvwWQOinVQSNMumapliRdO1Hi0JnW6apnA8MH4oytbUm1hK+Iv19Vt1ExpCaSObRzVkBCRGK NVlrLxuJeq+7WoRGGoTPIMRcEWJPKFYGpJDVgi1h5saI1xmQbcu1NA7cjcdCbuHKWYXLgYWUEdfL J0KMrKUHTG5C6EIllUWs64ZQyLJXOlmnpUsIaLdgEE7jybVejBgXsRBAkEjQeEjFopSnAow2QKpZ Sl0NCANoaBRniERrV62nVZXcTku7KXFCUkQQYgkasWrBKCTOhxr2hKdmqI7A0tzO/UL4gEL5vC2Y wQB/i7kinChIVYjAIAA= --001a114b0a388f330e0558f7daa0--