Skip to content

Commit ed0e0ae

Browse files
beaubelgraverostedt
authored andcommitted
tracing/user_events: Remove user_ns walk for groups
During discussions it was suggested that user_ns is not a good place to try to attach a tracing namespace. The current code has stubs to enable that work that are very likely to change and incur a performance cost. Remove the user_ns walk when creating a group and determining the system name to use, since it's unlikely user_ns will be used in the future. Link: https://lore.kernel.org/all/20230601-urenkel-holzofen-cd9403b9cadd@brauner/ Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Suggested-by: Christian Brauner <[email protected]> Signed-off-by: Beau Belgrave <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 42187bd commit ed0e0ae

File tree

1 file changed

+5
-37
lines changed

1 file changed

+5
-37
lines changed

kernel/trace/trace_events_user.c

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,11 @@ static void user_event_group_destroy(struct user_event_group *group)
182182
kfree(group);
183183
}
184184

185-
static char *user_event_group_system_name(struct user_namespace *user_ns)
185+
static char *user_event_group_system_name(void)
186186
{
187187
char *system_name;
188188
int len = sizeof(USER_EVENTS_SYSTEM) + 1;
189189

190-
if (user_ns != &init_user_ns) {
191-
/*
192-
* Unexpected at this point:
193-
* We only currently support init_user_ns.
194-
* When we enable more, this will trigger a failure so log.
195-
*/
196-
pr_warn("user_events: Namespace other than init_user_ns!\n");
197-
return NULL;
198-
}
199-
200190
system_name = kmalloc(len, GFP_KERNEL);
201191

202192
if (!system_name)
@@ -207,34 +197,12 @@ static char *user_event_group_system_name(struct user_namespace *user_ns)
207197
return system_name;
208198
}
209199

210-
static inline struct user_event_group
211-
*user_event_group_from_user_ns(struct user_namespace *user_ns)
212-
{
213-
if (user_ns == &init_user_ns)
214-
return init_group;
215-
216-
return NULL;
217-
}
218-
219200
static struct user_event_group *current_user_event_group(void)
220201
{
221-
struct user_namespace *user_ns = current_user_ns();
222-
struct user_event_group *group = NULL;
223-
224-
while (user_ns) {
225-
group = user_event_group_from_user_ns(user_ns);
226-
227-
if (group)
228-
break;
229-
230-
user_ns = user_ns->parent;
231-
}
232-
233-
return group;
202+
return init_group;
234203
}
235204

236-
static struct user_event_group
237-
*user_event_group_create(struct user_namespace *user_ns)
205+
static struct user_event_group *user_event_group_create(void)
238206
{
239207
struct user_event_group *group;
240208

@@ -243,7 +211,7 @@ static struct user_event_group
243211
if (!group)
244212
return NULL;
245213

246-
group->system_name = user_event_group_system_name(user_ns);
214+
group->system_name = user_event_group_system_name();
247215

248216
if (!group->system_name)
249217
goto error;
@@ -2603,7 +2571,7 @@ static int __init trace_events_user_init(void)
26032571
if (!fault_cache)
26042572
return -ENOMEM;
26052573

2606-
init_group = user_event_group_create(&init_user_ns);
2574+
init_group = user_event_group_create();
26072575

26082576
if (!init_group) {
26092577
kmem_cache_destroy(fault_cache);

0 commit comments

Comments
 (0)