From: Thomas Meyer <thomas@m3y3r.de>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel/groups.c: use bsearch library function
Date: Wed, 09 Oct 2019 20:35:29 +0200 [thread overview]
Message-ID: <875zkxydfy.fsf@m3y3r.de> (raw)
In-Reply-To: <60e43953-a7f9-c52e-150c-74059d1b377b@rasmusvillemoes.dk> (Rasmus Villemoes's message of "Wed, 9 Oct 2019 09:46:21 +0200")
Rasmus Villemoes <linux@rasmusvillemoes.dk> writes:
> On 07/10/2019 21.26, Thomas Meyer wrote:
>> commit b7b2562f7252 ("kernel/groups.c: use sort library function")
>> introduced the sort library function.
>> also use the bsearch library function instead of open-coding the binary
>> search.
Hi,
> Yes, but please note the difference between sorting the group_info and
> searching it: The former is done quite rarely - the setgroups syscall is
> used roughly once per login-session.
>
> But the searching of that structure is done more or less every time a
> user accesses a file not owned by that user (e.g., any time a normal
> user accesses anything in /usr) - at least if I'm reading
> acl_permission_check() right.
>
> So using a callback-based interface, especially in a post-spectre world,
> may have a somewhat large performance impact.
okay, so the code is duplicated for performance reasons? nothing a
compiler can inline, I guess.
so what about a comment instead:
diff --git a/kernel/groups.c b/kernel/groups.c
index daae2f2dc6d4f..46b5d4cd53c2e 100644
--- a/kernel/groups.c
+++ b/kernel/groups.c
@@ -93,7 +93,7 @@ void groups_sort(struct group_info *group_info)
}
EXPORT_SYMBOL(groups_sort);
-/* a simple bsearch */
+/* duplicate code from lib/bsearch.c for performance reasons */
int groups_search(const struct group_info *group_info, kgid_t grp)
{
unsigned int left, right;
Mfg
thomas
prev parent reply other threads:[~2019-10-09 18:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-07 19:26 Thomas Meyer
2019-10-09 7:46 ` Rasmus Villemoes
2019-10-09 18:35 ` Thomas Meyer [this message]
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=875zkxydfy.fsf@m3y3r.de \
--to=thomas@m3y3r.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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
all inboxes | Powered by JetHome®