linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] init/main.c: Simplify initcall_blacklisted()
@ 2015-01-17  0:25 Rasmus Villemoes
  2015-01-19 19:19 ` Oleg Nesterov
  0 siblings, 1 reply; 10+ messages in thread
From: Rasmus Villemoes @ 2015-01-17  0:25 UTC (permalink / raw)
  To: Andrew Morton, Rusty Russell, H. Peter Anvin,
	Peter Zijlstra (Intel), Oleg Nesterov, Geert Uytterhoeven,
	Prarit Bhargava, Fabian Frederick, Johannes Weiner
  Cc: Rasmus Villemoes, linux-kernel

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.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---

Notes:
    I don't know how expensive it is to do the symbol lookup for each
    initcall. It might be worthwhile adding an
    
      if (list_empty(&blacklisted_initcalls))
        return false;
    
    at the very beginning of initcall_blacklisted(), since this is a debug
    feature and the blacklist is indeed usually empty.

 init/main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/init/main.c b/init/main.c
index 61b993767db5..286602b677de 100644
--- a/init/main.c
+++ b/init/main.c
@@ -733,22 +733,18 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn)
 {
 	struct list_head *tmp;
 	struct blacklist_entry *entry;
-	char *fn_name;
+	char fn_name[KSYM_SYMBOL_LEN];
 
-	fn_name = kasprintf(GFP_KERNEL, "%pf", fn);
-	if (!fn_name)
-		return false;
+	sprint_symbol_no_offset(fn_name, (unsigned long)fn);
 
 	list_for_each(tmp, &blacklisted_initcalls) {
 		entry = list_entry(tmp, struct blacklist_entry, next);
 		if (!strcmp(fn_name, entry->buf)) {
 			pr_debug("initcall %s blacklisted\n", fn_name);
-			kfree(fn_name);
 			return true;
 		}
 	}
 
-	kfree(fn_name);
 	return false;
 }
 #else
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-03-24 17:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-17  0:25 [RFC/PATCH] init/main.c: Simplify initcall_blacklisted() Rasmus Villemoes
2015-01-19 19:19 ` Oleg Nesterov
2015-01-20  1:05   ` Rusty Russell
2015-01-20 10:49     ` Prarit Bhargava
2015-01-20 18:05       ` Oleg Nesterov
2015-01-20 18:39         ` Prarit Bhargava
2016-03-21 23:14           ` [PATCH resend] " Rasmus Villemoes
2016-03-22  3:27             ` Rusty Russell
2016-03-23 23:54               ` Rasmus Villemoes
2016-03-24 17:16             ` Prarit Bhargava

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).