From 105e8c2e47788a612bbc0fc135a3c75ef25f29e4 Mon Sep 17 00:00:00 2001 From: Mark-PK Tsai Date: Wed, 23 Mar 2022 16:06:08 -0700 Subject: 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. Link: https://lkml.kernel.org/r/20220209053350.15771-1-mark-pk.tsai@mediatek.com Signed-off-by: Mark-PK Tsai Reviewed-by: Andrew Halaney Tested-by: Andrew Halaney Cc: Steven Rostedt Cc: Matthias Brugger Cc: Masami Hiramatsu Cc: Vlastimil Babka Cc: Kefeng Wang Cc: Rasmus Villemoes Cc: Kees Cook Cc: Valentin Schneider Cc: Peter Zijlstra Cc: YJ Chiang Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- init/main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'init') diff --git a/init/main.c b/init/main.c index 65fa2e41a9c0..c8edcc3029b1 100644 --- a/init/main.c +++ b/init/main.c @@ -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; -- cgit v1.2.3 From f9a40b0890658330c83c95511f9d6b396610defc Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 23 Mar 2022 16:06:14 -0700 Subject: init/main.c: return 1 from handled __setup() functions initcall_blacklist() should return 1 to indicate that it handled its cmdline arguments. set_debug_rodata() should return 1 to indicate that it handled its cmdline arguments. Print a warning if the option string is invalid. This prevents these strings from being added to the 'init' program's environment as they are not init arguments/parameters. Link: https://lkml.kernel.org/r/20220221050901.23985-1-rdunlap@infradead.org Signed-off-by: Randy Dunlap Reported-by: Igor Zhbanov Cc: Ingo Molnar Cc: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- init/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'init') diff --git a/init/main.c b/init/main.c index c8edcc3029b1..4a12c9546f69 100644 --- a/init/main.c +++ b/init/main.c @@ -1190,7 +1190,7 @@ static int __init initcall_blacklist(char *str) } } while (str_entry); - return 0; + return 1; } static bool __init_or_module initcall_blacklisted(initcall_t fn) @@ -1448,7 +1448,9 @@ static noinline void __init kernel_init_freeable(void); bool rodata_enabled __ro_after_init = true; static int __init set_debug_rodata(char *str) { - return strtobool(str, &rodata_enabled); + if (strtobool(str, &rodata_enabled)) + pr_warn("Invalid option string for rodata: '%s'\n", str); + return 1; } __setup("rodata=", set_debug_rodata); #endif -- cgit v1.2.3