Re: [PATCH 1/2 v10] time: Make fast functions return 0 before timekeeping is initialized

2017-08-28 Thread Thomas Gleixner
On Mon, 28 Aug 2017, Prarit Bhargava wrote:
> +static struct tk_fast tk_fast_mono cacheline_aligned = {
> + .base = {
> + (struct tk_read_base){
> + .clock = _clock,
> + },
> + (struct tk_read_base){
> + .clock = _clock,
> + },
> + },
> +};

I think I complained about this ugly typecast before.

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

Hmm?

Thanks,

tglx


Re: [PATCH 1/2 v10] time: Make fast functions return 0 before timekeeping is initialized

2017-08-28 Thread Thomas Gleixner
On Mon, 28 Aug 2017, Prarit Bhargava wrote:
> +static struct tk_fast tk_fast_mono cacheline_aligned = {
> + .base = {
> + (struct tk_read_base){
> + .clock = _clock,
> + },
> + (struct tk_read_base){
> + .clock = _clock,
> + },
> + },
> +};

I think I complained about this ugly typecast before.

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

Hmm?

Thanks,

tglx


[PATCH 1/2 v10] time: Make fast functions return 0 before timekeeping is initialized

2017-08-28 Thread Prarit Bhargava
printk timestamps will be extended to include mono and boot time by using
the fast timekeeping functions ktime_get_mono|boot_fast_ns() functions.
The functions can return garbage before timekeeping is initialized
resulting in garbage timestamps.

The fast time functions must return 0 before timekeeping is initialized.

Signed-off-by: Prarit Bhargava 
Suggested-by: Peter Zijlstra 
Cc: John Stultz 
Cc: Thomas Gleixner 
Cc: Stephen Boyd 
---
 kernel/time/timekeeping.c | 47 +--
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index cedafa008de5..d111039e0245 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -60,8 +60,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){
+   .clock = _clock,
+   },
+   (struct tk_read_base){
+   .clock = _clock,
+   },
+   },
+};
+
+static struct tk_fast tk_fast_raw  cacheline_aligned = {
+   .base = {
+   (struct tk_read_base){
+   .clock = _clock,
+   },
+   (struct tk_read_base){
+   .clock = _clock,
+   },
+   },
+};
 
 /* flag for if timekeeping is suspended */
 int __read_mostly timekeeping_suspended;
@@ -477,18 +508,6 @@ u64 notrace ktime_get_boot_fast_ns(void)
 }
 EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
 
-/* 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,
-};
-
 /**
  * halt_fast_timekeeper - Prevent fast timekeeper from accessing clocksource.
  * @tk: Timekeeper to snapshot.
-- 
1.8.5.5



[PATCH 1/2 v10] time: Make fast functions return 0 before timekeeping is initialized

2017-08-28 Thread Prarit Bhargava
printk timestamps will be extended to include mono and boot time by using
the fast timekeeping functions ktime_get_mono|boot_fast_ns() functions.
The functions can return garbage before timekeeping is initialized
resulting in garbage timestamps.

The fast time functions must return 0 before timekeeping is initialized.

Signed-off-by: Prarit Bhargava 
Suggested-by: Peter Zijlstra 
Cc: John Stultz 
Cc: Thomas Gleixner 
Cc: Stephen Boyd 
---
 kernel/time/timekeeping.c | 47 +--
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index cedafa008de5..d111039e0245 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -60,8 +60,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){
+   .clock = _clock,
+   },
+   (struct tk_read_base){
+   .clock = _clock,
+   },
+   },
+};
+
+static struct tk_fast tk_fast_raw  cacheline_aligned = {
+   .base = {
+   (struct tk_read_base){
+   .clock = _clock,
+   },
+   (struct tk_read_base){
+   .clock = _clock,
+   },
+   },
+};
 
 /* flag for if timekeeping is suspended */
 int __read_mostly timekeeping_suspended;
@@ -477,18 +508,6 @@ u64 notrace ktime_get_boot_fast_ns(void)
 }
 EXPORT_SYMBOL_GPL(ktime_get_boot_fast_ns);
 
-/* 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,
-};
-
 /**
  * halt_fast_timekeeper - Prevent fast timekeeper from accessing clocksource.
  * @tk: Timekeeper to snapshot.
-- 
1.8.5.5