aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2016-05-20 20:04:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 20:58:30 -0400
commitc8cdd2be213f0f5372287a764225665f1ac64e56 (patch)
treed1dc98b6a330aeb27a824971f018c39965f3f447 /init
parent4108124f5c46efc951c4c6be947598a21d6b7fde (diff)
init/main.c: simplify initcall_blacklisted()
Using kasprintf to get the function name makes us look up the name twice, along with all the vsnprintf overhead of parsing the format string etc. It also means there is an allocation failure case to deal with. Since symbol_string in vsprintf.c would anyway allocate an array of size KSYM_SYMBOL_LEN on the stack, that might as well be done up here. Moreover, since this is a debug feature and the blacklisted_initcalls list is usually empty, we might as well test that and thus avoid looking up the symbol name even once in the common case. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Prarit Bhargava <prarit@redhat.com> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init')
-rw-r--r--init/main.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/init/main.c b/init/main.c
index fa9b2bdde183..bc0f9e0bcf22 100644
--- a/init/main.c
+++ b/init/main.c
@@ -706,21 +706,20 @@ static int __init initcall_blacklist(char *str)
706static bool __init_or_module initcall_blacklisted(initcall_t fn) 706static bool __init_or_module initcall_blacklisted(initcall_t fn)
707{ 707{
708 struct blacklist_entry *entry; 708 struct blacklist_entry *entry;
709 char *fn_name; 709 char fn_name[KSYM_SYMBOL_LEN];
710 710
711 fn_name = kasprintf(GFP_KERNEL, "%pf", fn); 711 if (list_empty(&blacklisted_initcalls))
712 if (!fn_name)
713 return false; 712 return false;
714 713
714 sprint_symbol_no_offset(fn_name, (unsigned long)fn);
715
715 list_for_each_entry(entry, &blacklisted_initcalls, next) { 716 list_for_each_entry(entry, &blacklisted_initcalls, next) {
716 if (!strcmp(fn_name, entry->buf)) { 717 if (!strcmp(fn_name, entry->buf)) {
717 pr_debug("initcall %s blacklisted\n", fn_name); 718 pr_debug("initcall %s blacklisted\n", fn_name);
718 kfree(fn_name);
719 return true; 719 return true;
720 } 720 }
721 } 721 }
722 722
723 kfree(fn_name);
724 return false; 723 return false;
725} 724}
726#else 725#else