printk: Introduce CONFIG_PRINTK_TIME_FROM_ARM_ARCH_TIMER

Change-Id: I0ab5914349ad3e0028954c831c5e79d46fe2d420
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
This commit is contained in:
Tao Huang 2020-04-06 15:54:55 +08:00
commit b6373f87a9
2 changed files with 24 additions and 2 deletions

View file

@ -58,6 +58,24 @@
#include "braille.h"
#include "internal.h"
#ifdef CONFIG_PRINTK_TIME_FROM_ARM_ARCH_TIMER
#include <clocksource/arm_arch_timer.h>
static u64 get_local_clock(void)
{
u64 ns;
ns = arch_timer_read_counter() * 1000;
do_div(ns, 24);
return ns;
}
#else
static inline u64 get_local_clock(void)
{
return local_clock();
}
#endif
int console_printk[4] = {
CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
MESSAGE_LOGLEVEL_DEFAULT, /* default_message_loglevel */
@ -660,7 +678,7 @@ static int log_store(int facility, int level,
if (ts_nsec > 0)
msg->ts_nsec = ts_nsec;
else
msg->ts_nsec = local_clock();
msg->ts_nsec = get_local_clock();
memset(log_dict(msg) + dict_len, 0, pad_len);
msg->len = size;
@ -1835,7 +1853,7 @@ static bool cont_add(int facility, int level, enum log_flags flags, const char *
cont.facility = facility;
cont.level = level;
cont.owner = current;
cont.ts_nsec = local_clock();
cont.ts_nsec = get_local_clock();
cont.flags = flags;
}

View file

@ -17,6 +17,10 @@ config PRINTK_TIME
The behavior is also controlled by the kernel command line
parameter printk.time=1. See Documentation/admin-guide/kernel-parameters.rst
config PRINTK_TIME_FROM_ARM_ARCH_TIMER
bool "Timing from ARM architected timer"
depends on PRINTK_TIME && ARM_ARCH_TIMER
config PRINTK_PROCESS
bool "Show process information on printks"
depends on PRINTK