51 lines
1.5 KiB
Diff
51 lines
1.5 KiB
Diff
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Date: Mon, 20 Apr 2015 10:53:35 +0200
|
|
Subject: [PATCH] kdbus: optimize auxgroup collector
|
|
|
|
current->creds can only be changed by 'current'. That is, as long as we
|
|
only access our own credentials, we can be sure it does not change. Hence,
|
|
there is no need to ref cred->group_info if all we do is copy its content.
|
|
|
|
This avoids touching shared cachelines when collecting auxgroups.
|
|
|
|
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
|
|
Acked-by: Daniel Mack <daniel@zonque.org>
|
|
---
|
|
ipc/kdbus/metadata.c | 10 ++++------
|
|
1 file changed, 4 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/ipc/kdbus/metadata.c b/ipc/kdbus/metadata.c
|
|
index eeebfef11552..174436f0aa01 100644
|
|
--- a/ipc/kdbus/metadata.c
|
|
+++ b/ipc/kdbus/metadata.c
|
|
@@ -245,25 +245,23 @@ static void kdbus_meta_proc_collect_pids(struct kdbus_meta_proc *mp)
|
|
|
|
static int kdbus_meta_proc_collect_auxgroups(struct kdbus_meta_proc *mp)
|
|
{
|
|
- struct group_info *info;
|
|
+ const struct group_info *info;
|
|
size_t i;
|
|
|
|
- info = get_current_groups();
|
|
+ /* no need to lock/ref, current creds cannot change */
|
|
+ info = current_cred()->group_info;
|
|
|
|
if (info->ngroups > 0) {
|
|
mp->auxgrps = kmalloc_array(info->ngroups, sizeof(kgid_t),
|
|
GFP_KERNEL);
|
|
- if (!mp->auxgrps) {
|
|
- put_group_info(info);
|
|
+ if (!mp->auxgrps)
|
|
return -ENOMEM;
|
|
- }
|
|
|
|
for (i = 0; i < info->ngroups; i++)
|
|
mp->auxgrps[i] = GROUP_AT(info, i);
|
|
}
|
|
|
|
mp->n_auxgrps = info->ngroups;
|
|
- put_group_info(info);
|
|
mp->valid |= KDBUS_ATTACH_AUXGROUPS;
|
|
|
|
return 0;
|