blob: ea6505525b2649588c6b34101223033478310d52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
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;
|