Skip to content

Commit 40b90ef

Browse files
wangbaolin719jwessel
authored andcommitted
kdb: use ktime_get_mono_fast_ns() instead of ktime_get_ts()
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. Signed-off-by: Baolin Wang <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: Jason Wessel <[email protected]>
1 parent 33f765f commit 40b90ef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/debug/kdb/kdb_main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,10 +2512,10 @@ static int kdb_kill(int argc, const char **argv)
25122512
*/
25132513
static void kdb_sysinfo(struct sysinfo *val)
25142514
{
2515-
struct timespec uptime;
2516-
ktime_get_ts(&uptime);
2515+
u64 uptime = ktime_get_mono_fast_ns();
2516+
25172517
memset(val, 0, sizeof(*val));
2518-
val->uptime = uptime.tv_sec;
2518+
val->uptime = div_u64(uptime, NSEC_PER_SEC);
25192519
val->loads[0] = avenrun[0];
25202520
val->loads[1] = avenrun[1];
25212521
val->loads[2] = avenrun[2];

0 commit comments

Comments
 (0)