From patchwork Thu Jun 15 13:05:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp650363vqr; Thu, 15 Jun 2023 06:52:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6P118IuuBQzPBchFEpkplB9A1QrYRCbNY3XM47S4Zeh9ITVlDsVLNdnbuXKvn+UYWv9152 X-Received: by 2002:a17:902:e844:b0:1b0:10a1:3da9 with SMTP id t4-20020a170902e84400b001b010a13da9mr5829088plg.32.1686837131887; Thu, 15 Jun 2023 06:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686837131; cv=none; d=google.com; s=arc-20160816; b=KfLx1aoYqbiJHkA4AmxtFGWv/dyuPRPxi3XLfqUXqtlPGb/VHi0+NEHf1Su9E1QkGT 8p8wUxqcMm6RaG4joreuUPBk4oIE4pU4RuVbMxSDU5RiHrWVsKAMGXc7WZMw9/mNJrAq ZtzISyUIiZmVsQwMJ7CYJwRbJXyB60E7yuR0iMjVFvot0RfrlEtZVEiXnBgJ3mNjICqR auR3V4eRlZAHTz/l7FN6h/0zglZj0A96bFRLkyOv9jYkuBEkEj3S0RmTZ6O5W1b8bbQR v6Cd8/SFbYk8kBdDOP+b8LH/GuTGKRbMeUPiDJUbcL7DMT+Hh3LzAY7B6mNCP/PCOwkp qAHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=5cblOrAy3/O3NR3mqFyXR+j4+UhJYnx7mWckk4AKx6o=; b=jtBF0+lujAR5yYkS5qGzY8Aabw5HOI+z4QDecDgMxkRnANnAscEIHxmz3s+Z3GCEO1 S9muXXl/RzSw+9P+mMfofJ7gWrMBFuQACrT0+tYrc46whWfCoaRE8EwfgbX5Ikisv0aW 1Q4Q4N0p820XUQQf9Kb7NmiVypmKz0ZsUa8MJjnkZ4HIgw7YH+eqyOt8vJgAhVwBuzMR W3jQjgepePBttRE17iwxkX9aXzHILudJnk9FkKM7Yir0YhE1R4X+X8rmLVEmnBs1xAsH nD89pgqVRiGN3rCNBCToIipG0CpjMtTfDRHq8iHgh9AzXL2Xmm+/GwzxcydFlkXK+C+1 XSrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a8-20020a170902b58800b001ae5eb838edsi12653048pls.152.2023.06.15.06.51.59; Thu, 15 Jun 2023 06:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344396AbjFONgX (ORCPT + 99 others); Thu, 15 Jun 2023 09:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344734AbjFONfY (ORCPT ); Thu, 15 Jun 2023 09:35:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B44A3AB8 for ; Thu, 15 Jun 2023 06:34:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B8DCF639D3 for ; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94D82C43391; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7A-000Tpl-2A; Thu, 15 Jun 2023 09:34:16 -0400 Message-ID: <20230615133416.491731786@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:40 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Christian Brauner , Beau Belgrave Subject: [for-linus][PATCH 09/15] tracing/user_events: Remove user_ns walk for groups References: <20230615130531.200384328@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768776932494964834?= X-GMAIL-MSGID: =?utf-8?q?1768776932494964834?= From: Beau Belgrave 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/20230601224928.301-1-beaub@linux.microsoft.com Suggested-by: Christian Brauner Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 42 ++++---------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 49914b6cb651..cf6d4c02c363 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -182,21 +182,11 @@ static void user_event_group_destroy(struct user_event_group *group) kfree(group); } -static char *user_event_group_system_name(struct user_namespace *user_ns) +static char *user_event_group_system_name(void) { char *system_name; int len = sizeof(USER_EVENTS_SYSTEM) + 1; - if (user_ns != &init_user_ns) { - /* - * Unexpected at this point: - * We only currently support init_user_ns. - * When we enable more, this will trigger a failure so log. - */ - pr_warn("user_events: Namespace other than init_user_ns!\n"); - return NULL; - } - system_name = kmalloc(len, GFP_KERNEL); if (!system_name) @@ -207,34 +197,12 @@ static char *user_event_group_system_name(struct user_namespace *user_ns) return system_name; } -static inline struct user_event_group -*user_event_group_from_user_ns(struct user_namespace *user_ns) -{ - if (user_ns == &init_user_ns) - return init_group; - - return NULL; -} - static struct user_event_group *current_user_event_group(void) { - struct user_namespace *user_ns = current_user_ns(); - struct user_event_group *group = NULL; - - while (user_ns) { - group = user_event_group_from_user_ns(user_ns); - - if (group) - break; - - user_ns = user_ns->parent; - } - - return group; + return init_group; } -static struct user_event_group -*user_event_group_create(struct user_namespace *user_ns) +static struct user_event_group *user_event_group_create(void) { struct user_event_group *group; @@ -243,7 +211,7 @@ static struct user_event_group if (!group) return NULL; - group->system_name = user_event_group_system_name(user_ns); + group->system_name = user_event_group_system_name(); if (!group->system_name) goto error; @@ -2603,7 +2571,7 @@ static int __init trace_events_user_init(void) if (!fault_cache) return -ENOMEM; - init_group = user_event_group_create(&init_user_ns); + init_group = user_event_group_create(); if (!init_group) { kmem_cache_destroy(fault_cache);