History

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.

Baolin Wang committed 8 years ago

Commit 40b90ef1 parent 33f765f1 file · +3 −3Browse files

Showing the changes to kernel/debug (1 of 1 file). Show all

Unified · Split

kernel/debug/kdb/kdb_main.c+3−3
@@ -2512,10 +2512,10 @@ static int kdb_kill(int argc, const char **argv) · 2511 unmodified lines
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];