mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Xiang Xiao <xiaoxiang781216@gmail.com>
Cc: pmladek@suse.com, sergey.senozhatsky@gmail.com,
	linux-kernel@vger.kernel.org, Xiang Xiao <xiaoxiang@xiaomi.com>
Subject: Re: [PATCH] printk: add KERN_NOTIME to skip the timestamp
Date: Tue, 12 Feb 2019 14:46:06 -0500	[thread overview]
Message-ID: <20190212144606.4b7cf0f8@gandalf.local.home> (raw)
In-Reply-To: <1549995065-27597-1-git-send-email-xiaoxiang@xiaomi.com>

On Wed, 13 Feb 2019 02:11:05 +0800
Xiang Xiao <xiaoxiang781216@gmail.com> wrote:

> Because log may already add the timestamp sometime

Can you be a bit more detailed on this. When and where does this
happen? 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.

-- Steve

> 
> Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
> ---
>  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_<LEVEL> */
>  #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;


  reply	other threads:[~2019-02-12 19:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 18:11 Xiang Xiao
2019-02-12 19:46 ` Steven Rostedt [this message]
2019-02-13  6:19   ` xiang xiao
2019-02-13  6:29     ` Sergey Senozhatsky
2019-02-13  6:38       ` Sergey Senozhatsky
2019-02-13  7:14         ` xiang xiao
2019-02-13  8:08           ` Sergey Senozhatsky
2019-02-13  8:52             ` xiang xiao
2019-02-13 13:19     ` Petr Mladek
2019-02-13 13:49       ` xiang xiao
2019-02-13 13:47     ` Steven Rostedt
2019-02-13 14:00       ` xiang xiao
2019-02-13 14:31         ` Steven Rostedt
2019-02-13 16:25           ` xiang xiao
2019-02-14  1:26           ` Sergey Senozhatsky
2019-02-14  8:48           ` Petr Mladek
2019-02-13  0:48 ` Sergey Senozhatsky
2019-02-13  6:25   ` xiang xiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190212144606.4b7cf0f8@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=xiaoxiang781216@gmail.com \
    --cc=xiaoxiang@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®