Skip to content

Commit ea417aa

Browse files
author
Martin Schwidefsky
committed
s390/debug: make debug event time stamps relative to the boot TOD clock
The debug features currently uses absolute TOD time stamps for the debug events. Given that the TOD clock can jump forward and backward due to STP sync checks the order of debug events can get obfuscated. Replace the absolute TOD time stamps with a delta to the IPL time stamp. On a STP sync check the TOD clock correction is added to the IPL time stamp as well to make the deltas unaffected by STP sync check. The readout of the debug feature entries will convert the deltas back to absolute time stamps based on the Unix epoch. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 8676caa commit ea417aa

3 files changed

Lines changed: 8 additions & 16 deletions

File tree

arch/s390/include/asm/timex.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,6 @@ int get_phys_clock(unsigned long long *clock);
178178
void init_cpu_timer(void);
179179
unsigned long long monotonic_clock(void);
180180

181-
void tod_to_timeval(__u64 todval, struct timespec64 *xt);
182-
183-
static inline
184-
void stck_to_timespec64(unsigned long long stck, struct timespec64 *ts)
185-
{
186-
tod_to_timeval(stck - TOD_UNIX_EPOCH, ts);
187-
}
188-
189181
extern u64 sched_clock_base_cc;
190182

191183
/**

arch/s390/kernel/debug.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ static inline void
866866
debug_finish_entry(debug_info_t * id, debug_entry_t* active, int level,
867867
int exception)
868868
{
869-
active->id.stck = get_tod_clock_fast();
869+
active->id.stck = get_tod_clock_fast() - sched_clock_base_cc;
870870
active->id.fields.cpuid = smp_processor_id();
871871
active->caller = __builtin_return_address(0);
872872
active->id.fields.exception = exception;
@@ -1455,23 +1455,24 @@ int
14551455
debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
14561456
int area, debug_entry_t * entry, char *out_buf)
14571457
{
1458-
struct timespec64 time_spec;
1458+
unsigned long sec, usec;
14591459
char *except_str;
14601460
unsigned long caller;
14611461
int rc = 0;
14621462
unsigned int level;
14631463

14641464
level = entry->id.fields.level;
1465-
stck_to_timespec64(entry->id.stck, &time_spec);
1465+
sec = (entry->id.stck >> 12) + (sched_clock_base_cc >> 12);
1466+
sec = sec - (TOD_UNIX_EPOCH >> 12);
1467+
usec = do_div(sec, USEC_PER_SEC);
14661468

14671469
if (entry->id.fields.exception)
14681470
except_str = "*";
14691471
else
14701472
except_str = "-";
14711473
caller = (unsigned long) entry->caller;
1472-
rc += sprintf(out_buf, "%02i %011lld:%06lu %1u %1s %02i %p ",
1473-
area, (long long)time_spec.tv_sec,
1474-
time_spec.tv_nsec / 1000, level, except_str,
1474+
rc += sprintf(out_buf, "%02i %011ld:%06lu %1u %1s %02i %p ",
1475+
area, sec, usec, level, except_str,
14751476
entry->id.fields.cpuid, (void *)caller);
14761477
return rc;
14771478
}

arch/s390/kernel/time.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ unsigned long long monotonic_clock(void)
110110
}
111111
EXPORT_SYMBOL(monotonic_clock);
112112

113-
void tod_to_timeval(__u64 todval, struct timespec64 *xt)
113+
static void tod_to_timeval(__u64 todval, struct timespec64 *xt)
114114
{
115115
unsigned long long sec;
116116

@@ -120,7 +120,6 @@ void tod_to_timeval(__u64 todval, struct timespec64 *xt)
120120
todval -= (sec * 1000000) << 12;
121121
xt->tv_nsec = ((todval * 1000) >> 12);
122122
}
123-
EXPORT_SYMBOL(tod_to_timeval);
124123

125124
void clock_comparator_work(void)
126125
{

0 commit comments

Comments
 (0)