Re: [PATCH v5] printk: Add monotonic, boottime, and realtime timestamps

2017-08-15 Thread Thomas Gleixner
On Thu, 10 Aug 2017, Prarit Bhargava wrote:
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index cedafa008de5..1ddf04201047 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 

That's needed because?

>  #include "tick-internal.h"
>  #include "ntp_internal.h"
> @@ -60,8 +61,39 @@ struct tk_fast {
>   struct tk_read_base base[2];
>  };
>  
> -static struct tk_fast tk_fast_mono cacheline_aligned;
> -static struct tk_fast tk_fast_raw  cacheline_aligned;
> +/* Suspend-time cycles value for halted fast timekeeper. */
> +static u64 cycles_at_suspend;
> +
> +static u64 dummy_clock_read(struct clocksource *cs)
> +{
> + return cycles_at_suspend;
> +}
> +
> +static struct clocksource dummy_clock = {
> + .read = dummy_clock_read,
> +};
> +
> +static struct tk_fast tk_fast_mono cacheline_aligned = {
> + .base = {
> + (struct tk_read_base){

Eew.

> + .clock = _clock,
> + },

.base[0] = {
.clock = _clock,
},

.base[1] = {
.clock = _clock,
},

Hmm?

> -static struct clocksource dummy_clock = {
> - .read = dummy_clock_read,
> -};
> -

Can we please have that timekeeping change as a seperate patch?

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5] printk: Add monotonic, boottime, and realtime timestamps

2017-08-10 Thread Prarit Bhargava
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 timestampes 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.

Real clock & 32-bit systems:  Selecting the real clock printk timestamp may
lead to unlikely situations where a timestamp is wrong because the real time
offset is read without the protection of a sequence lock in the call to
ktime_get_log_ts() in printk_get_ts().

v2: Use peterz's suggested Kconfig options.  Merge patchset together.
Fix i386 !CONFIG_PRINTK builds.

v3: Fixed x86_64_defconfig. Added printk_time_type enum and
printk_time_str for better output. Added BOOTTIME clock functionality.

v4: Fix messages, add additional printk.time options, and fix configs.

v5: Renaming of structures, and allow printk_time_set() to
evaluate substrings of entries (eg: allow 'r', 'real', 'realtime').  From
peterz, make fast functinos return 0 until timekeeping is initialized
(removes timekeeping_active & ktime_get_boot|real_log_ts() suggested by
 tglx and adds ktime_get_real_offset()).  Switch to a function pointer
for printk_get_ts() and reference fast functions.  Make timestamp_sources enum
match choice options for CONFIG_PRINTK_TIME (adds PRINTK_TIME_UNDEFINED).

Signed-off-by: Prarit Bhargava 
Cc: Mark Salyzyn 
Cc: Jonathan Corbet 
Cc: Petr Mladek 
Cc: Sergey Senozhatsky 
Cc: Steven Rostedt 
Cc: John Stultz 
Cc: Thomas Gleixner 
Cc: Stephen Boyd 
Cc: Andrew Morton 
Cc: Greg Kroah-Hartman 
Cc: "Paul E. McKenney" 
Cc: Christoffer Dall 
Cc: Deepa Dinamani 
Cc: Ingo Molnar 
Cc: Joel Fernandes 
Cc: Prarit Bhargava 
Cc: Kees Cook 
Cc: Peter Zijlstra 
Cc: Geert Uytterhoeven 
Cc: "Luis R. Rodriguez" 
Cc: Nicholas Piggin 
Cc: "Jason A. Donenfeld" 
Cc: Olof Johansson 
Cc: Josh Poimboeuf 
Cc: linux-doc@vger.kernel.org
---
 Documentation/admin-guide/kernel-parameters.txt|   6 +-
 arch/arm/configs/aspeed_g4_defconfig   |   2 +-
 arch/arm/configs/aspeed_g5_defconfig   |   2 +-
 arch/arm/configs/axm55xx_defconfig |   2 +-
 arch/arm/configs/bcm2835_defconfig |   2 +-
 arch/arm/configs/colibri_pxa270_defconfig  |   2 +-
 arch/arm/configs/colibri_pxa300_defconfig  |   2 +-
 arch/arm/configs/dove_defconfig|   2 +-
 arch/arm/configs/efm32_defconfig   |   2 +-
 arch/arm/configs/exynos_defconfig  |   2 +-
 arch/arm/configs/ezx_defconfig |   2 +-
 arch/arm/configs/h5000_defconfig   |   2 +-
 arch/arm/configs/hisi_defconfig|   2 +-
 arch/arm/configs/imote2_defconfig  |   2 +-
 arch/arm/configs/imx_v6_v7_defconfig   |   2 +-
 arch/arm/configs/keystone_defconfig|   2 +-
 arch/arm/configs/lpc18xx_defconfig |   2 +-
 arch/arm/configs/magician_defconfig|   2 +-
 arch/arm/configs/mmp2_defconfig|   2 +-
 arch/arm/configs/moxart_defconfig  |   2 +-
 arch/arm/configs/mps2_defconfig|   2 +-
 arch/arm/configs/multi_v7_defconfig|   2 +-
 arch/arm/configs/mvebu_v7_defconfig|   2 +-
 arch/arm/configs/mxs_defconfig |   2 +-
 arch/arm/configs/omap2plus_defconfig   |   2 +-
 arch/arm/configs/pxa168_defconfig  |   2 +-
 arch/arm/configs/pxa3xx_defconfig  |   2 +-
 arch/arm/configs/pxa910_defconfig  |   2 +-
 arch/arm/configs/pxa_defconfig |   2 +-
 arch/arm/configs/qcom_defconfig|   2 +-
 arch/arm/configs/raumfeld_defconfig|   2 +-
 arch/arm/configs/shmobile_defconfig|   2 +-
 arch/arm/configs/socfpga_defconfig |   2 +-
 arch/arm/configs/stm32_defconfig   |   2 +-
 arch/arm/configs/sunxi_defconfig   |