Skip to contentSkip to conversation

init: Use ktime_us_delta() to make initcall_debug log more precise

PATCH Applied Mark-PK Tsai 2 participants 2 messages Feb 9, 2022 Arm MediaTek

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init: Use ktime_us_delta() to make initcall_debug log more precise

Use ktime_us_delta() to make the initcall_debug log more precise than right shifting the result of ktime_to_ns() by 10 bits.

---
 init/main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
init/main.c +2 -6
index 65fa2e41a9c0..c8edcc3029b1 100644
@@ -1246,15 +1246,11 @@ trace_initcall_start_cb(void *data, initcall_t fn)
 static __init_or_module void
 trace_initcall_finish_cb(void *data, initcall_t fn, int ret)
 {
-	ktime_t *calltime = (ktime_t *)data;
-	ktime_t delta, rettime;
-	unsigned long long duration;
+	ktime_t rettime, *calltime = (ktime_t *)data;
 
 	rettime = ktime_get();
-	delta = ktime_sub(rettime, *calltime);
-	duration = (unsigned long long) ktime_to_ns(delta) >> 10;
 	printk(KERN_DEBUG "initcall %pS returned %d after %lld usecs\n",
-		 fn, ret, duration);
+		 fn, ret, (unsigned long long)ktime_us_delta(rettime, *calltime));
 }
 
 static ktime_t initcall_calltime;
Signature · 1 line
2.18.0
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 33 lines · Mark-PK Tsai

Use ktime_us_delta() to make the initcall_debug log more precise than right shifting the result of ktime_to_ns() by 10 bits.

---
 init/main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
init/main.c +2 -6
index 65fa2e41a9c0..c8edcc3029b1 100644
@@ -1246,15 +1246,11 @@ trace_initcall_start_cb(void *data, initcall_t fn)
 static __init_or_module void
 trace_initcall_finish_cb(void *data, initcall_t fn, int ret)
 {
-	ktime_t *calltime = (ktime_t *)data;
-	ktime_t delta, rettime;
-	unsigned long long duration;
+	ktime_t rettime, *calltime = (ktime_t *)data;
 
 	rettime = ktime_get();
-	delta = ktime_sub(rettime, *calltime);
-	duration = (unsigned long long) ktime_to_ns(delta) >> 10;
 	printk(KERN_DEBUG "initcall %pS returned %d after %lld usecs\n",
-		 fn, ret, duration);
+		 fn, ret, (unsigned long long)ktime_us_delta(rettime, *calltime));
 }
 
 static ktime_t initcall_calltime;
Signature · 1 line
2.18.0

I took this for a spin while playing around with other things today, cleans things up nicely imo.