Re: [PATCH 3/3 v12] printk: Add monotonic, boottime, and realtime timestamps
From: Petr Mladek
Date: Tue Sep 26 2017 - 07:48:53 EST
On Mon 2017-09-18 13:51:00, Prarit Bhargava wrote:
> printk.time=1/CONFIG_PRINTK_TIME=1 adds a unmodified local hardware clock
> timestamp to printk messages. The local hardware clock loses time each
> day making it difficult to determine exactly when an issue has occurred in
> the kernel log, and making it difficult to determine how kernel and
> hardware issues relate to each other in real time.
>
> Make printk output different timestamps by adding options for no
> timestamp, the local hardware clock, the monotonic clock, the boottime
> clock, and the real clock. Allow a user to pick one of the clocks by
> using the printk.time kernel parameter. Output the type of clock in
> /sys/module/printk/parameters/time so userspace programs can interpret the
> timestamp.
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 512f7c2baedd..5e0bf2ef02f7 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1201,14 +1204,130 @@ static inline void boot_delay_msec(int level)
> +static int printk_time = CONFIG_PRINTK_TIME_TYPE;
> +
> +static int printk_set_ts_source(enum timestamp_sources ts_source)
> +{
> + int err = 0;
> @@ -1861,6 +1980,7 @@ static size_t msg_print_text(const struct printk_log *msg,
> bool syslog, char *buf, size_t size) { return 0; }
> static bool suppress_message_printing(int level) { return false; }
>
> +static int printk_time;
I worried if the variable should have got initialized. But it seems to
be a relic from an older version. The variable is not longer used and
needed when CONFIG_PRINTK is not defined. It is proved by gcc:
CC kernel/printk/printk.o
kernel/printk/printk.c:1983:12: warning: âprintk_timeâ defined but not used [-Wunused-variable]
static int printk_time;
> #endif /* CONFIG_PRINTK */
>
> #ifdef CONFIG_EARLY_PRINTK
Otherwise that patch looks fine. With the unused variable removed,
feel free to use:
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Best Regards,
Petr