From: Mark Rutland <mark.rutland@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: jeyu@redhat.com, rusty@rustcorp.com.au, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] module: Optimize search_module_extables()
Date: Wed, 8 Feb 2017 15:44:34 +0000 [thread overview]
Message-ID: <20170208154433.GH15459@leverpostej> (raw)
In-Reply-To: <20170208144801.GZ6515@twins.programming.kicks-ass.net>
On Wed, Feb 08, 2017 at 03:48:01PM +0100, Peter Zijlstra wrote:
>
> While looking through the __ex_table stuff I found that we do a linear
> lookup of the module. Also fix up a comment.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
I'm not all that familiar with the module code, but from a quick scan of
__module_address() this looks sane to me. FWIW:
Acked-by: Mark Rutland <mark.rutland@arm.com>
Mark.
> ---
> kernel/module.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 3d8f126208e3..7bcdc35dbf95 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -4165,22 +4165,23 @@ const struct exception_table_entry *search_module_extables(unsigned long addr)
> struct module *mod;
>
> preempt_disable();
> - list_for_each_entry_rcu(mod, &modules, list) {
> - if (mod->state == MODULE_STATE_UNFORMED)
> - continue;
> - if (mod->num_exentries == 0)
> - continue;
> + mod = __module_address(addr);
> + if (!mod)
> + goto out;
>
> - e = search_extable(mod->extable,
> - mod->extable + mod->num_exentries - 1,
> - addr);
> - if (e)
> - break;
> - }
> + if (!mod->num_exentries)
> + goto out;
> +
> + e = search_extable(mod->extable,
> + mod->extable + mod->num_exentries - 1,
> + addr);
> +out:
> preempt_enable();
>
> - /* Now, if we found one, we are running inside it now, hence
> - we cannot unload the module, hence no refcnt needed. */
> + /*
> + * Now, if we found one, we are running inside it now, hence
> + * we cannot unload the module, hence no refcnt needed.
> + */
> return e;
> }
>
next prev parent reply other threads:[~2017-02-08 16:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-08 14:48 Peter Zijlstra
2017-02-08 15:44 ` Mark Rutland [this message]
2017-02-11 4:41 ` Jessica Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170208154433.GH15459@leverpostej \
--to=mark.rutland@arm.com \
--cc=jeyu@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome