The kdb code will print the monotonic time by ktime_get_ts(), but the ktime_get_ts() will be protected by a sequence lock, that will introduce one deadlock risk if the lock was already held in the context from which we entered the debugger. Thus we can use the ktime_get_mono_fast_ns() to get the monotonic time, which is NMI safe access to clock monotonic. Moreover we can remove the 'struct timespec', which is not y2038 safe.
Showing the changes to kernel/debug (1 of 1 file). Show all
Unified · Split
| @@ -2512,10 +2512,10 @@ static int kdb_kill(int argc, const char **argv) · 2511 unmodified lines | |||
| 2512 | */ | 2512 | */ |
| 2513 | static void kdb_sysinfo(struct sysinfo *val) | 2513 | static void kdb_sysinfo(struct sysinfo *val) |
| 2514 | { | 2514 | { |
| 2515 | struct timespec uptime; | 2515 | u64 uptime = ktime_get_mono_fast_ns(); |
| 2516 | ktime_get_ts(&uptime); | 2516 | |
| 2517 | memset(val, 0, sizeof(*val)); | 2517 | memset(val, 0, sizeof(*val)); |
| 2518 | val->uptime = uptime.tv_sec; | 2518 | val->uptime = div_u64(uptime, NSEC_PER_SEC); |
| 2519 | val->loads[0] = avenrun[0]; | 2519 | val->loads[0] = avenrun[0]; |
| 2520 | val->loads[1] = avenrun[1]; | 2520 | val->loads[1] = avenrun[1]; |
| 2521 | val->loads[2] = avenrun[2]; | 2521 | val->loads[2] = avenrun[2]; |