From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2998568AbdDZKpJ (ORCPT ); Wed, 26 Apr 2017 06:45:09 -0400 Received: from ozlabs.org ([103.22.144.67]:59373 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2998554AbdDZKpC (ORCPT ); Wed, 26 Apr 2017 06:45:02 -0400 From: Michael Ellerman To: "Naveen N. Rao" Cc: Masami Hiramatsu , Paul Clarke , David Laight , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] kallsyms: optimize kallsyms_lookup_name() for a few cases In-Reply-To: <20170425161822.18764-1-naveen.n.rao@linux.vnet.ibm.com> References: <20170425161822.18764-1-naveen.n.rao@linux.vnet.ibm.com> User-Agent: Notmuch/0.21 (https://notmuchmail.org) Date: Wed, 26 Apr 2017 20:44:59 +1000 Message-ID: <87lgqn1m8k.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Naveen N. Rao" writes: > diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c > index 6a3b249a2ae1..d134b060564f 100644 > --- a/kernel/kallsyms.c > +++ b/kernel/kallsyms.c > @@ -205,6 +205,12 @@ unsigned long kallsyms_lookup_name(const char *name) > unsigned long i; > unsigned int off; > > + if (!name || *name == '\0') > + return false; > + > + if (strnchr(name, MODULE_NAME_LEN, ':')) > + return module_kallsyms_lookup_name(name); > + > for (i = 0, off = 0; i < kallsyms_num_syms; i++) { > off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf)); ... } return module_kallsyms_lookup_name(name); Is the rest of the context. Which looks a bit odd, we already did module lookup previously? But it's correct, because you can lookup a symbol in a module without a module prefix, it just looks in every module. You could invert the logic, ie. check that there isn't a ":" in the name and only in that case do the for loop, always falling back to module lookup. Or just add a comment explaining why we call module lookup in two places. cheers