[lkml]   [2019]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [PATCH] kernel/groups.c: use bsearch library function
Rasmus Villemoes <> 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.


> 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)

-/* 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;


 \ /
  Last update: 2019-10-09 20:36    [W:0.027 / U:1.544 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site