Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4825343imj; Wed, 13 Feb 2019 01:34:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IZrDDEC82eLMOczH623pcbsOWC37ThnSWOPezpL+qs2Ro6JHhllf64vh6LWwzVf3goSYv/a X-Received: by 2002:a17:902:e090:: with SMTP id cb16mr8559642plb.32.1550050496261; Wed, 13 Feb 2019 01:34:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550050496; cv=none; d=google.com; s=arc-20160816; b=st+OcFA9MAxU7A5SDDIEN2AcMLRP7RRPQHqWLj1hP7cwRvUPRwQ/nXCa/7YxbjoP0H JUcLTS87qLswrTWeVT9NLxeePzU8yfxREMKrutqxU9+7bG0uqm9vU1CjmCMptyWYYISR mPt2aUlaZ9Gv6ALO9vp5GCb4obGg4VN4yzaCDJMfIsr81TyALnefiSQuOrC7M+8bFvhX BKbEQE5kNPBXEOeHnLQjZquTrcBYjK3qz16rTOYvpF+JVWf9fWKpHTkXGrSqpeZB5vRn +S2AvKkK2IKMT3mRBTb9EL3B4yr+qDFQf5+UO2apRv1hHp3nRXCvhRbqmfOA4PLEZ9Xh 2p9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8ro2jC56O54+ic/AwGOG3252SMG5Rzo6rjWDESRSYSI=; b=zsDHxPSZA5JRijSljZBBAVJ4ZnzwV0iix7WqJa6QvS86f9ZE2dMs7Ud/1oJ9XJdvAN EagB8aZ/daKrqdaShwT6byan3JSoOt2u/1jqrF+5j720R3Y0CT9oZRW3hf8vw7845mJO tw8+so1yspPtvOZqwIhxjGvDir47775q2m72MIyEPfZd86GBCIdtm8v/iFED5Pop6jb0 6jA76cPThwj11TV+rjV9Ojh91kADFUk/9fm1cfCJUobXnbldm6/eJmSVtfjOFYL2T84w jCx+nsSBMm8xi6TUnptbikjrNqbjyUuH6SFIkD3v2Qge4F1+j4+OL07Bcs+IS4vD8jbb Qnsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="WN/ROOmU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23si14377972pgu.151.2019.02.13.01.34.40; Wed, 13 Feb 2019 01:34:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="WN/ROOmU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730402AbfBMGTW (ORCPT + 99 others); Wed, 13 Feb 2019 01:19:22 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:42596 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbfBMGTW (ORCPT ); Wed, 13 Feb 2019 01:19:22 -0500 Received: by mail-qk1-f194.google.com with SMTP id y140so699941qkb.9 for ; Tue, 12 Feb 2019 22:19:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8ro2jC56O54+ic/AwGOG3252SMG5Rzo6rjWDESRSYSI=; b=WN/ROOmUgTQrWMVyajb5VQ3pJ9Hvqo5r/tLhmm5YbdLtUuQTqSAjJSYwc1osYZlunt JO81HC8i3YSFLuaTY7XEbBHUt5UPrvmWhH6ISwlWdfSUYsXIHYODaOEkMa1iFlpY1NK8 Yv27LbrZjQ3mXnAko5Tht54GhwJCq6c4ctJFSBt5XlTHE7xe5tAfxO23UJpuAOrgQywr z48iowljPOfQ1DlvrhgPGKNtLkZdQWvQh+6o28Nw6+qr3vyiQHT4jObr1RCiNkkU+wDe DdwdL4/CnLJJL5pnG9zWILoIOWpZku0QixGqkqP4UdSS3He+ba6FnKAUQSt7QVa89sQh 0HRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8ro2jC56O54+ic/AwGOG3252SMG5Rzo6rjWDESRSYSI=; b=Nh1sqCn9bIaJq0e/LtGHHGHyZMTXbOegkCW6oWq4OW4CMUgYaH7VuQpkQb4050iVuT omwkeZpRI41Uwdoj+/mn3oQKecS9n/dTtixQZrjkEmShJX+FP8f31yqv+Id3BcyaWDh9 xMw43tQHEmAIKNhgNXFmNBEswGy7ewAXH62tVaphJDSkOGbbsHWMv0XrMOeSBn5otyOL Yf5VRUNGPh+iHsMgfdHl0Mk/1S9en+MsfA5BmtIU/NQsSBke3A3vOms+KAi3zUMOIa2w 62laoBtTrvuUDAsYzE2fvh0/ZTRrgSpVBmFPLmCR2DebqVRItyyJqSVj5QBLj8D29XYe sugw== X-Gm-Message-State: AHQUAuZbL9iQ2OetqDqoth2Ny3sh/MXjCxKd+9yTRgnsZiR08r49J17R B4ETMYoZqRQ0ix1vWvZfR4Jsaw/WdJD/E8QEkBc= X-Received: by 2002:ae9:ed12:: with SMTP id c18mr67773qkg.39.1550038761265; Tue, 12 Feb 2019 22:19:21 -0800 (PST) MIME-Version: 1.0 References: <1549995065-27597-1-git-send-email-xiaoxiang@xiaomi.com> <20190212144606.4b7cf0f8@gandalf.local.home> In-Reply-To: <20190212144606.4b7cf0f8@gandalf.local.home> From: xiang xiao Date: Wed, 13 Feb 2019 14:19:01 +0800 Message-ID: Subject: Re: [PATCH] printk: add KERN_NOTIME to skip the timestamp To: Steven Rostedt Cc: Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Xiang Xiao Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 13, 2019 at 3:46 AM Steven Rostedt wrote: > > On Wed, 13 Feb 2019 02:11:05 +0800 > Xiang Xiao wrote: > > > Because log may already add the timestamp sometime > > Can you be a bit more detailed on this. When and where does this > happen? Here is my case: 1.A small MCU(Cortex M4) in SoC run RTOS 2.RTOS append timestamp to log for the accurate timing 3.RTOS send log to Linux kernel when buffer exceed the threshold 4.Kernel call printk to dump the received buffer So I want that printk skip the timestamp here. > If anything, I would probably prefer that we export whether > time is being printed, and have the caller not print time if printk is > doing it already, than to add the complexity into printk itself. Actually, the timestamp of our initial implementation like your suggestion come from printk, but we found that timestamp from kernel isn't accurate as from RTOS due the buffer and IPC. > > -- Steve > > > > > Signed-off-by: Xiang Xiao > > --- > > include/linux/kern_levels.h | 2 ++ > > include/linux/printk.h | 1 + > > kernel/printk/printk.c | 7 ++++++- > > 3 files changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/kern_levels.h b/include/linux/kern_levels.h > > index d237fe8..ed2aec6 100644 > > --- a/include/linux/kern_levels.h > > +++ b/include/linux/kern_levels.h > > @@ -23,6 +23,8 @@ > > */ > > #define KERN_CONT KERN_SOH "c" > > > > +#define KERN_NOTIME KERN_SOH "t" /* don't print the timestamp */ > > + > > /* integer equivalents of KERN_ */ > > #define LOGLEVEL_SCHED -2 /* Deferred messages from sched code > > * are set to this special level */ > > diff --git a/include/linux/printk.h b/include/linux/printk.h > > index 77740a5..be12ac4 100644 > > --- a/include/linux/printk.h > > +++ b/include/linux/printk.h > > @@ -20,6 +20,7 @@ static inline int printk_get_level(const char *buffer) > > case '0' ... '7': > > case 'd': /* KERN_DEFAULT */ > > case 'c': /* KERN_CONT */ > > + case 't': /* KERN_NOTIME */ > > return buffer[1]; > > } > > } > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > > index d3d1703..0688cf2 100644 > > --- a/kernel/printk/printk.c > > +++ b/kernel/printk/printk.c > > @@ -346,6 +346,7 @@ enum log_flags { > > LOG_NEWLINE = 2, /* text ended with a newline */ > > LOG_PREFIX = 4, /* text started with a prefix */ > > LOG_CONT = 8, /* text is a fragment of a continuation line */ > > + LOG_NOTIME = 16, /* don't print the timestamp */ > > }; > > > > struct printk_log { > > @@ -1247,7 +1248,7 @@ static size_t print_prefix(const struct printk_log *msg, bool syslog, > > > > if (syslog) > > len = print_syslog((msg->facility << 3) | msg->level, buf); > > - if (time) > > + if (time && !(msg->flags & LOG_NOTIME)) > > len += print_time(msg->ts_nsec, buf + len); > > return len; > > } > > @@ -1873,6 +1874,10 @@ int vprintk_store(int facility, int level, > > break; > > case 'c': /* KERN_CONT */ > > lflags |= LOG_CONT; > > + break; > > + case 't': /* KERN_NOTIME */ > > + lflags |= LOG_NOTIME; > > + break; > > } > > > > text_len -= 2; >