statistics infrastructure - prerequisite: timestamp
PATCH 4/6 statistics infrastructure - prerequisite: timestamp
[patch 4/6] statistics infrastructure - prerequisite: timestamp
This patch separates the timestamp code out from printk. Thus, other components, like the statistics infrastructure, can also make use of it and provide similar timestamps. It just makes sense to have one timestamp format throughout the kernel.
The original piece of code was a bit promiscuous, IMHO. Please accept the little cleanup that comes with my patch.
And I think that I have fixed a printed_len related miscalculation. printed_len needs to be increased if no valid log level has been found and a log level prefix has been added by printk(). Otherwise, printed_len must not be increased. The old code did it the other way around (in the timestamp case).
---
include/linux/jiffies.h | 7 ++++ kernel/printk.c | 74 +++++++++++++++++++----------------------------- 2 files changed, 37 insertions(+), 44 deletions(-)
include/linux/jiffies.h +7 -0
@@ -447,4 +447,11 @@ static inline u64 nsec_to_clock_t(u64 x) return x; } +static inline int nsec_to_timestamp (char *s,unsigned long long t) +{ +unsigned long nsec_rem =do_div (t,1000000000 ); +return sprintf (s,"[%5lu.%06lu]" , (unsigned long )t, nsec_rem/1000 ); +} +#define TIMESTAMP_SIZE 30 +#endif
kernel/printk.c +30 -44
96 lines not on this page · raw message