From patchwork Thu Jun 1 22:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beau Belgrave X-Patchwork-Id: 102231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp664704vqr; Thu, 1 Jun 2023 16:02:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ltOH9/aZJxKGS/SIo76cLh1w19xuTzLYwxuEn8BdVIiH59PEot2Wndy/K1wHCuZgsA0co X-Received: by 2002:a05:6a00:1992:b0:624:2e60:f21e with SMTP id d18-20020a056a00199200b006242e60f21emr9461201pfl.29.1685660567444; Thu, 01 Jun 2023 16:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685660567; cv=none; d=google.com; s=arc-20160816; b=hKU44+oEhVI9jEfweQmeF1mS/A7wj6rvuFB+tnjx7W1P9yCp5Xe5l5usGtcgWH8Gtl Sqm6VGPFlXySVUa76gOEGbyWeQG3K6fOvHMWyVEg+wfm5ovK+T6hoyCQ/Zs0x5BUKS1z wj2j3TcU7l+AWIkVxTqANGS5tukakGCshkB7N9IQLNG+A1rrUg59nQmB2QwlIaUXmlok C3j8mUEYz/nYJK8EU/ob3iJ4aak7qNQknSNPTp0HECoRVbBTxs0nzk55wvVeHHPdmAD2 Z+MMBhyAYEpblPXm77/EudgZoIv8UfdR1NdP/ob8fMMb3eh6f7x5SWU9bvRbINiOhrQw b3Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=Al6Gkocw7whHT52Bc4ElZbslNdqBvx6ntA83ZjEnGCw=; b=svlQpp+Wt6yrSe9OLS5mEjmcuQhzkTRr9pEMBE+F52ghtuXSK+p2sK+3kxuRyQ6tKK 5hPMQ+jtJG2kpXg2NMDFdQcE5J9EqRJoQtQq7RF5Pyi39DKWT6D/I/7PWYF9SZ+vAYgz EgpovP1OWnM8LxqJSrz2XQDYKwr7q0pngmV5caO5EJYAzB8dQGaGByaYxlTHQcs1fQF6 Ps6HgB1q2lSe7yx7n2MOR7IehFMppdFoLrrDm/DnpzrLLhkF+ubi9PT3yItIs7ewI+ja nLu5CMH7uszNs3M1rD1K0kpcGBc2ffiUZ/97I+jKY2d0DOoFPybMP3RB2hxAbirwzyZb cpKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=eBkE6tth; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m132-20020a633f8a000000b00541cfaad533si433045pga.88.2023.06.01.16.02.29; Thu, 01 Jun 2023 16:02:47 -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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=eBkE6tth; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231628AbjFAWtg (ORCPT + 99 others); Thu, 1 Jun 2023 18:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjFAWtf (ORCPT ); Thu, 1 Jun 2023 18:49:35 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 434BA137; Thu, 1 Jun 2023 15:49:34 -0700 (PDT) Received: from W11-BEAU-MD.localdomain (unknown [76.135.27.212]) by linux.microsoft.com (Postfix) with ESMTPSA id 7693120FCD27; Thu, 1 Jun 2023 15:49:32 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7693120FCD27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1685659772; bh=Al6Gkocw7whHT52Bc4ElZbslNdqBvx6ntA83ZjEnGCw=; h=From:To:Cc:Subject:Date:From; b=eBkE6tthDxKoqBO9Fwv67XKmq0g+Sy+bnMV3haP3kpSA4FOId5penjiuwuUqu0fqc 0yrQbjbQ+UgZSpC/6MYwDHiYcWqMJ1v36hHtX3iMOPoePgNeWl9WAKYtBiCVij64ij I90KenDa9WpQitzqgEfNzHCHKiIoNaLGCsvrWMak= From: Beau Belgrave To: rostedt@goodmis.org, mhiramat@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, brauner@kernel.org Subject: [PATCH] tracing/user_events: Remove user_ns walk for groups Date: Thu, 1 Jun 2023 15:49:28 -0700 Message-Id: <20230601224928.301-1-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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?1767543214799613438?= X-GMAIL-MSGID: =?utf-8?q?1767543214799613438?= 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/ Suggested-by: Christian Brauner Signed-off-by: Beau Belgrave --- kernel/trace/trace_events_user.c | 42 ++++---------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) base-commit: 3862f86c1529fa0016de6344eb974877b4cd3838 diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index b1ecd7677642..55e362484b66 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -180,21 +180,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) @@ -205,34 +195,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; @@ -241,7 +209,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; @@ -2543,7 +2511,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);