From patchwork Thu Jun 15 13:05:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp686577vqr; Thu, 15 Jun 2023 07:41:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6yp5L6Ndooru8za54w0vhvFgBT2B1ZhLYZsQPHy7iuGsPV2tS78wpYE4wsmZ7N3ZOJzypX X-Received: by 2002:a17:902:9b8c:b0:1b1:99d8:4361 with SMTP id y12-20020a1709029b8c00b001b199d84361mr12440607plp.6.1686840074362; Thu, 15 Jun 2023 07:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686840074; cv=none; d=google.com; s=arc-20160816; b=APQMyypxs0rcKcJNTKqOCcvwpFDqqDfVYAbO61yhGEOLawTo3W2l19ZTx1EDMOBmlJ +Z6xsnatQQf5raMK02sYqvobR+jiGC36PIHafdYoe/wfkin1lCIH+og4ZLXwD4LDQPkN sWMXUZCGnuvmqAPZOGpVShymoLzL3CZXDyIGECNaB+ZVLZWyfyP7ZJ27wI8Q0LdySjnn aMe22X4pLdEDtscyGX0WTFKR4FIjVDDl8vwWgGmCSUQdfAFoyNPufr+Afckx/uw3ArEZ X4QKgjMT6OG4A8klxgiSub4gV0rCLaNUAPOfzmW2CtDsIMmwNDq8klhLt3dEAxr31uHa UJrA== 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=5wyqxXvYApbC2NlYOKlR/BWK+UDat+2A+4f2DDhrkio=; b=rz0KDjA8RU3ILTnvOwEBr8cRV5zpRy/UCIp6igSJPvtPUGWgthw7gjTS4kjLC1QsTP BPJCkoqIzjQQ5Pd4Pk07zsJ998aC7ROo6d7pF+g+DBNOP9jLcqkpppIgnAw97pVdfwBZ pDV/EPTvJuTFwI5NFUtnwjLV9rtX29MAR869spr2KiWUOVgQlXgiHT5fi67l8qJ1jfDz 5Wzp9PM27kExrnZcFx/3HTaJ3VPFh+fKtk7JJQaq2UI8/shsCCgbpEkDOR+Rrt1lBYiH pMYyANEpZ6amQcrioyXuAYyhFxXSmtTR2BUoip1p711BVxtL7oyCZJCRYxXj7ECjTNfF j7rw== 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 lc6-20020a170902fa8600b001b3f35a694esi4622918plb.83.2023.06.15.07.40.57; Thu, 15 Jun 2023 07:41:14 -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 S1344173AbjFONfb (ORCPT + 99 others); Thu, 15 Jun 2023 09:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344471AbjFONfD (ORCPT ); Thu, 15 Jun 2023 09:35:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7217E30DB for ; Thu, 15 Jun 2023 06:34:18 -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) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B9BD660F85 for ; Thu, 15 Jun 2023 13:34:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FF3BC433C9; Thu, 15 Jun 2023 13:34:16 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n79-000TlJ-0A; Thu, 15 Jun 2023 09:34:15 -0400 Message-ID: <20230615133414.865893768@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:32 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Daniel Bristot de Oliveira , Daniel Bristot de Oliveira Subject: [for-linus][PATCH 01/15] tracing/rv/rtla: Update MAINTAINERS file to point to proper mailing list References: <20230615130531.200384328@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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?1768780018082046794?= X-GMAIL-MSGID: =?utf-8?q?1768780018082046794?= From: "Steven Rostedt (Google)" The mailing list that goes to linux-trace-devel is for the tracing libraries, and the patchwork associated to the tracing libraries keys off of that mailing list. For anything that lives in the Linux kernel proper (including the tools directory) must go through linux-trace-kernel, as the patchwork to that list keys off of the Linux kernel proper. Update the MAINTAINERS file to reflect the proper mailing lists. Link: https://lore.kernel.org/linux-trace-kernel/20230529044002.0481452b@rorschach.local.home Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Daniel Bristot de Oliveira Signed-off-by: Steven Rostedt (Google) Acked-by: Daniel Bristot de Oliveira --- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 27ef11624748..725d35b5d328 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17806,7 +17806,7 @@ F: tools/testing/selftests/rtc/ Real-time Linux Analysis (RTLA) tools M: Daniel Bristot de Oliveira M: Steven Rostedt -L: linux-trace-devel@vger.kernel.org +L: linux-trace-kernel@vger.kernel.org S: Maintained F: Documentation/tools/rtla/ F: tools/tracing/rtla/ @@ -18368,7 +18368,7 @@ F: drivers/infiniband/ulp/rtrs/ RUNTIME VERIFICATION (RV) M: Daniel Bristot de Oliveira M: Steven Rostedt -L: linux-trace-devel@vger.kernel.org +L: linux-trace-kernel@vger.kernel.org S: Maintained F: Documentation/trace/rv/ F: include/linux/rv.h From patchwork Thu Jun 15 13:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp646560vqr; Thu, 15 Jun 2023 06:45:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4bXbNWxLldgh0PrBEU27cgh3dwPXqC+IFDahv3gxKPdqIN8uiF14fXblHPpxNO6od8pLWQ X-Received: by 2002:a05:6a20:3cac:b0:110:2064:ecb with SMTP id b44-20020a056a203cac00b0011020640ecbmr6146261pzj.15.1686836737338; Thu, 15 Jun 2023 06:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686836737; cv=none; d=google.com; s=arc-20160816; b=on1hdmumhgOBlFhQJoI/V3ij/KKqy6TiSBy3U8FKRtZiI1fudcjKIZfBPOFibp5GPI 0DxPyEvWq1aUMyKovyP+B6Vvp+c4h0rj9wDS/j3373WkpPwNoHJ8CaOHLhUoz5YCU/5W LGCjlRRnj2mxco2kuv0T1b/SvIIrW5XA7C4SlYu5GPvNZB5CphUhwBgJ4P3r1+WM8Uq0 eam1nVY3WYB25r5nNyJFnuX2KdQBr8mlqA+ewBp/DN17lez6dorBHkwHjdgtRsBM4bUC 3vnW1oGs3TDHfLYoufmeBAgOUt36Jot4DHlPl9GVI4tTo8Gnj+q5zmZ60EoNmq2SysVD uusQ== 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=1N3RS/e2XBWuYH4HxCG3tF7TxXYcwfnvAFSE3UzT3n8=; b=tKx7IaSsnisAUv29pl8Rh7Eqf21ZLTroCLJoyVn9rM1YuCtLs/KH9HRumkrwZ5IKJg AzH7SKY5GqZJKBL0wgkgBrfFchfk8ymIK1Tk2Kq5hAbrK1lYc12z4k2RXXlTASk26k7h bfqzUXM1MGKxL9NGGBnQUcEDbbYo4HTqWkvqsF96KKbz5S+zlF2DHLKY1xOeaFDnxTY4 Tt+dcSaFNjri5n+eumq0EQmQkfQxEUXO84r9UUkHEWx/I26IfZiIV/x3KcYSSFfLHQbH NZNL2OPn1Pqr7SwtiKFZqHnnhN/EJGEPCK2dOg600FGPLeX3z0Vqnl9uXKGrtBb+HaGV P7Cw== 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 f16-20020a633810000000b0054288b91d66si12902606pga.635.2023.06.15.06.45.23; Thu, 15 Jun 2023 06:45:37 -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 S1344217AbjFONfi (ORCPT + 99 others); Thu, 15 Jun 2023 09:35:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344485AbjFONfD (ORCPT ); Thu, 15 Jun 2023 09:35:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D2430DE for ; Thu, 15 Jun 2023 06:34:18 -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 E038E63759 for ; Thu, 15 Jun 2023 13:34:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55D1BC433CB; Thu, 15 Jun 2023 13:34:16 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n79-000Tlr-0p; Thu, 15 Jun 2023 09:34:15 -0400 Message-ID: <20230615133415.070156632@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:33 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , sunliming , Beau Belgrave Subject: [for-linus][PATCH 02/15] tracing/user_events: Prevent same name but different args event References: <20230615130531.200384328@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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?1768776518465373481?= X-GMAIL-MSGID: =?utf-8?q?1768776518465373481?= From: sunliming User processes register name_args for events. If the same name but different args event are registered. The trace outputs of second event are printed as the first event. This is incorrect. Return EADDRINUSE back to the user process if the same name but different args event has being registered. Link: https://lore.kernel.org/linux-trace-kernel/20230529032100.286534-1-sunliming@kylinos.cn Signed-off-by: sunliming Reviewed-by: Masami Hiramatsu (Google) Acked-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 36 +++++++++++++++---- .../selftests/user_events/ftrace_test.c | 6 ++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index dbb14705d0d3..37a38496a6be 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1786,6 +1786,8 @@ static int user_event_parse(struct user_event_group *group, char *name, int ret; u32 key; struct user_event *user; + int argc = 0; + char **argv; /* Prevent dyn_event from racing */ mutex_lock(&event_mutex); @@ -1793,13 +1795,35 @@ static int user_event_parse(struct user_event_group *group, char *name, mutex_unlock(&event_mutex); if (user) { - *newuser = user; - /* - * Name is allocated by caller, free it since it already exists. - * Caller only worries about failure cases for freeing. - */ - kfree(name); + if (args) { + argv = argv_split(GFP_KERNEL, args, &argc); + if (!argv) { + ret = -ENOMEM; + goto error; + } + + ret = user_fields_match(user, argc, (const char **)argv); + argv_free(argv); + + } else + ret = list_empty(&user->fields); + + if (ret) { + *newuser = user; + /* + * Name is allocated by caller, free it since it already exists. + * Caller only worries about failure cases for freeing. + */ + kfree(name); + } else { + ret = -EADDRINUSE; + goto error; + } + return 0; +error: + refcount_dec(&user->refcnt); + return ret; } user = kzalloc(sizeof(*user), GFP_KERNEL_ACCOUNT); diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c index 7c99cef94a65..6e8c4b47281c 100644 --- a/tools/testing/selftests/user_events/ftrace_test.c +++ b/tools/testing/selftests/user_events/ftrace_test.c @@ -228,6 +228,12 @@ TEST_F(user, register_events) { ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); ASSERT_EQ(0, reg.write_index); + /* Multiple registers to same name but different args should fail */ + reg.enable_bit = 29; + reg.name_args = (__u64)"__test_event u32 field1;"; + ASSERT_EQ(-1, ioctl(self->data_fd, DIAG_IOCSREG, ®)); + ASSERT_EQ(EADDRINUSE, errno); + /* Ensure disabled */ self->enable_fd = open(enable_file, O_RDWR); ASSERT_NE(-1, self->enable_fd); From patchwork Thu Jun 15 13:05:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108529 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp648344vqr; Thu, 15 Jun 2023 06:48:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5sl/PZT0du/mFanqrdrMQdZQzVmPq+EsbjW40vXWwUz1Di9sf+nyRDoLXtfoBb5XZ+yH5C X-Received: by 2002:a17:902:ceca:b0:19c:dbce:dce8 with SMTP id d10-20020a170902ceca00b0019cdbcedce8mr18815573plg.15.1686836916218; Thu, 15 Jun 2023 06:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686836916; cv=none; d=google.com; s=arc-20160816; b=kXvQZLljzCM3eZqVZL4SwKUpV0/FqmCWGsfMqWDdnthD6LZ2jG+Hb+smXX31dWQ4CV NhFgBbTUiezqljrS5uzNlfLDlxyXPEpVDz0lwS8wmiHwcoAfqrohoNY9PehpsARAKta6 LGCH0Lsa/fkBKRmX7Q7nm22EzgwUOpMzz3OEML6vtFoQGWPBZm7qJBHyh0OmGCjyzjXy Cwk/MElHD9UxSZXtm6vUB3QNt8DnjQFAK5z1YeMIZ8j/VNsGZ8fwc0GGPrZIt5BPp7EF Sp7kK0MRqoYEqRxNhaWtZWQiCRvY3PH+h+vrFMRERn60gXFplK3KC6z0fCIGOu6/Z0wP K+lQ== 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=VnBtuuztT8YTEIzv1KqCpstxn1D0sObw353No87dbfg=; b=DvxAtVk+jdpknqO7w2iJUp1LxWPz1z3hEsQ5ZLWYkDZQl9vbY9tYO6EdkxxtB7BKGn pTW6W+gsG3Mxh6pkhTMeggk86o8MHQf7DhBYk9DK4TNnHfrhoFEwViAmNe4xgvq0qEzs wD6aUt9zREe7oAGfnoAvZWt6UkVVYsY90U9FOCIYq3iuhgRA5em6bGGUGL2doQs4bovn vjNULF7m3wPnryZv9SRh/6Mq41zl14L/1e3dKAYiJh8MdyXdMfykchC9ERV50AtJioE1 z0PGZXq/x9bGbXF7aIF/0UYInasF6ACEoCn4oqrHIe0szmkSgGp8oma6h7u18sVFZoBP ouNA== 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 p1-20020a170902e74100b001b1bf4c8688si9289197plf.231.2023.06.15.06.48.21; Thu, 15 Jun 2023 06:48:36 -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 S1344202AbjFONfe (ORCPT + 99 others); Thu, 15 Jun 2023 09:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344484AbjFONfD (ORCPT ); Thu, 15 Jun 2023 09:35:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5046430E0 for ; Thu, 15 Jun 2023 06:34:19 -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 15584637DA for ; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7872DC43391; Thu, 15 Jun 2023 13:34:16 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n79-000TmP-1U; Thu, 15 Jun 2023 09:34:15 -0400 Message-ID: <20230615133415.275901907@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:34 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , sunliming Subject: [for-linus][PATCH 03/15] tracing/user_events: Handle matching arguments that is null from dyn_events References: <20230615130531.200384328@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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?1768776705891080326?= X-GMAIL-MSGID: =?utf-8?q?1768776705891080326?= From: sunliming When A registering user event from dyn_events has no argments, it will pass the matching check, regardless of whether there is a user event with the same name and arguments. Add the matching check when the arguments of registering user event is null. Link: https://lore.kernel.org/linux-trace-kernel/20230529065110.303440-1-sunliming@kylinos.cn Signed-off-by: sunliming Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 37a38496a6be..afe61dc86543 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1745,6 +1745,8 @@ static bool user_event_match(const char *system, const char *event, if (match && argc > 0) match = user_fields_match(user, argc, argv); + else if (match && argc == 0) + match = list_empty(&user->fields); return match; } From patchwork Thu Jun 15 13:05:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp679379vqr; Thu, 15 Jun 2023 07:30:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wGAxaadCfTXUYacrYdmog6f572rQGD3p3JkoQP1YdnW3EhQdh92r3h6XTOFHlHPMwzPe1 X-Received: by 2002:a2e:9a88:0:b0:2b4:3faf:c3de with SMTP id p8-20020a2e9a88000000b002b43fafc3demr1672057lji.49.1686839454803; Thu, 15 Jun 2023 07:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686839454; cv=none; d=google.com; s=arc-20160816; b=N4fmLVUTfMARGhwhkDxSl6UVUhTZDR6f7P2NT9g6p84oKiiDwcftK1ghJ/EAERiwOH 6vAshjUTxOO0+pVOzPHf3Cp01+VDAX/3cueGCxFKwkvcQ/Fk7RGKzE1uKGwGB/Pv9DZU REKXbK+IjXiJPh1tI6fJFwHK+vP4uW0rCLY449fdu0dwuO4fdINA+63t74lAtn3DZkwz k1YbIzXvjj0ev9oPWprTbHn2/vT/RiAzXn9E9j/4H2tXBfEt0+aGTwdY+39ezdjZisu3 qJQq3FBcqnBYYFB2HldLtH7IFTj/vzzvcqeB8jSV3ToePliVGNhEmmXVPuMv+KtiE1xH D95g== 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=2iG0qcLEWG38z1uY69hvkDWP3oV8HxWRBJVG9HlEvhI=; b=CDGNLP6GF4wc/G5cwAUmPTA4QLIh5S6Bvx62FwDCwU/DSNn8gDhZbTr0Qfqspey+LP Xaw6m5zOYRyeeb5cOZ0WS+RQJP2TZ7v2YsWtVvx6N9jbPrlqjpb4ADorayIT25UDPjby 37y5JTvx61lVqwSHpXDOGvOrfJTSsNF80kIWCoSQ3PM9vOmpCdDAP+vuXaVY23iq+Qs/ ekoVC5EsOF4fPcuR5UTwlEh3Vsxn9WhNQ1X2v4udWW2QFw+kGd+QIlGAogSKTyBe/y/x kl5qL5tf+I1QcOLoU2ySmPdGTxfIopUEZJ2KTJP+4CEEQMEonhoMegW4EU1PRrPZ+XwH Vcuw== 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 s8-20020aa7d788000000b0051643861867si9679412edq.226.2023.06.15.07.30.24; Thu, 15 Jun 2023 07:30:54 -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 S1344291AbjFONft (ORCPT + 99 others); Thu, 15 Jun 2023 09:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344574AbjFONfL (ORCPT ); Thu, 15 Jun 2023 09:35:11 -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 5A38C2960 for ; Thu, 15 Jun 2023 06:34:30 -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 3F5E4637EE for ; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A30F5C43395; Thu, 15 Jun 2023 13:34:16 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n79-000Tmx-28; Thu, 15 Jun 2023 09:34:15 -0400 Message-ID: <20230615133415.478015212@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:35 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , sunliming Subject: [for-linus][PATCH 04/15] tracing: Modify print_fields() for fields output order 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?1768779368461597479?= X-GMAIL-MSGID: =?utf-8?q?1768779368461597479?= From: sunliming Now the print_fields() print trace event fields in reverse order. Modify it to the positive sequence. Example outputs for a user event: test0 u32 count1; u32 count2 Output before: example-2547 [000] ..... 325.666387: test0: count2=0x2 (2) count1=0x1 (1) Output after: example-2742 [002] ..... 429.769370: test0: count1=0x1 (1) count2=0x2 (2) Link: https://lore.kernel.org/linux-trace-kernel/20230525085232.5096-1-sunliming@kylinos.cn Fixes: 80a76994b2d88 ("tracing: Add "fields" option to show raw trace event fields") Signed-off-by: sunliming Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 15f05faaae44..1e33f367783e 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -847,7 +847,7 @@ static void print_fields(struct trace_iterator *iter, struct trace_event_call *c int ret; void *pos; - list_for_each_entry(field, head, link) { + list_for_each_entry_reverse(field, head, link) { trace_seq_printf(&iter->seq, " %s=", field->name); if (field->offset + field->size > iter->ent_size) { trace_seq_puts(&iter->seq, ""); From patchwork Thu Jun 15 13:05:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108561 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp683719vqr; Thu, 15 Jun 2023 07:36:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ687OE+vG78NlMD/cKhV3jjF/4vwHVeYrHtYk1ZR8vICMA0sWj0AIUNSa1BmWHLj0MdkVo2 X-Received: by 2002:aa7:cd16:0:b0:514:9929:1b01 with SMTP id b22-20020aa7cd16000000b0051499291b01mr12133647edw.8.1686839812600; Thu, 15 Jun 2023 07:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686839812; cv=none; d=google.com; s=arc-20160816; b=xrjs/rE/Xtl27VTWIwDhAH1bp+S/oixoId/mo6UO91OGDmlrw/JoEc9tGE5OyXaCyZ wu/5zMUq3fPs5f7rziSL0vg7sWko603yGIbQWmS6l9k+uDcy3PKR07fF77TtY95vbVMh gKTnqoEPIDMBHI52GCaF5amwV6bW8/566A1dI/j/bQNdXnG5JHzd+DrlsXCNlaPrjg5X j7euz15ofaqYoVcHIng3ZfxXp5y1AUyWuIcqhkc87UA1gNF0A1/rhC9NxcyYpjeH7zf3 q8FTz+Ij3pdyBJ60K3a1gSgSFC3yHOlj/BPJdvaP2KtlPnIX0PLs4p6fZPRKf8NTK2zH ooNQ== 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=4OWJSPdDkZrdOLP72RAYT13q+F04PiuHVFvP9v7huBo=; b=i6K/jgqzvltKqC0uvLuohV9Ppl/HoybJzDWmnwwUkvYtGqEsNL54a6zY26krBu+E7p 0yDQVvRAp5S/78AxUsFqcXxUeADvyTyzNs6ORx/ChBYuG4pPRKO0v9PRt1fo8SEm0mYy ApslVEmSRoC4xCnfmt7I4lL+tqHCG4d0pCyJv+kvL1S1eYAoGVPnBD9XMThpEyAedUf6 ohBfkR+8IQmzSX5IGLOT4/O77qTYh40SkNYwgt+WozCEdp78LbWLE68LRpQRUujma2Hz RESK1pFwrog5HwUEAe2YmO7795at8ZkOlr7i8YhAKn0DFkI9U0hvWspp0RgnH09Gn0uA SSvg== 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 e12-20020a50ec8c000000b00516b291217fsi10013179edr.0.2023.06.15.07.36.27; Thu, 15 Jun 2023 07:36:52 -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 S238729AbjFONgz (ORCPT + 99 others); Thu, 15 Jun 2023 09:36:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344351AbjFONgU (ORCPT ); Thu, 15 Jun 2023 09:36:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56FD63582 for ; Thu, 15 Jun 2023 06:35:10 -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 7EFC6633FE for ; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB406C433CA; Thu, 15 Jun 2023 13:34:16 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n79-000TnV-2o; Thu, 15 Jun 2023 09:34:15 -0400 Message-ID: <20230615133415.683635706@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:36 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave , sunliming Subject: [for-linus][PATCH 05/15] tracing/user_events: Fix the incorrect trace record for empty arguments events References: <20230615130531.200384328@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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?1768779742846963290?= X-GMAIL-MSGID: =?utf-8?q?1768779742846963290?= From: sunliming The user_events support events that has empty arguments. But the trace event is discarded and not really committed when the arguments is empty. Fix this by not attempting to copy in zero-length data. Link: https://lkml.kernel.org/r/20230606062027.1008398-2-sunliming@kylinos.cn Acked-by: Beau Belgrave Acked-by: Masami Hiramatsu (Google) Signed-off-by: sunliming Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index afe61dc86543..49914b6cb651 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1432,7 +1432,7 @@ static void user_event_ftrace(struct user_event *user, struct iov_iter *i, if (unlikely(!entry)) return; - if (unlikely(!copy_nofault(entry + 1, i->count, i))) + if (unlikely(i->count != 0 && !copy_nofault(entry + 1, i->count, i))) goto discard; if (!list_empty(&user->validators) && @@ -1473,7 +1473,7 @@ static void user_event_perf(struct user_event *user, struct iov_iter *i, perf_fetch_caller_regs(regs); - if (unlikely(!copy_nofault(perf_entry + 1, i->count, i))) + if (unlikely(i->count != 0 && !copy_nofault(perf_entry + 1, i->count, i))) goto discard; if (!list_empty(&user->validators) && From patchwork Thu Jun 15 13:05:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp652342vqr; Thu, 15 Jun 2023 06:55:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40xC3VMpq4jEO/NTMsH6lBBifNrqjr8HJr1PTK/xKppYK6f4KvMb2QWDgI0yluLWH01Xi/ X-Received: by 2002:a17:902:aa8f:b0:1b0:339d:db6a with SMTP id d15-20020a170902aa8f00b001b0339ddb6amr11253288plr.21.1686837355875; Thu, 15 Jun 2023 06:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686837355; cv=none; d=google.com; s=arc-20160816; b=f16U6BV6PiJUZvCMQYxiguF8X7WMxmjbuIFrUKYHhIDL75bbA5Xx91S3BEg1qKryIp kRBh9CsRmGuI420bYFWuusYnnffAAhdhaOBkWGGmfngvyzG24sZPvdg0hEhqYoy4fuSi l0CkGfpFGPu8M9qS+2Kus9OBZheat8AqTCwrB6nPmN8mv32F6UAcOGAVwBgufNUAgjzF z38hr5sljjFNXM5iHqp7n14kST8ijIOyvfA19FKjFoCPObe9op0ZWU+v1fSM6yJu4+jO SqJ68xACzmJrVNMx7oaInToW90Q6qdG10wTgMJlP1vBP8gdtYslWC5jIktJJDwtB8NaE PsCg== 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=1H99irYoc6cLb0K06NrlLERSJzm53pvbaeeqoxLQYZw=; b=LI3qcz6MyQJoPIHz4LLndncnk23RTw5HpewiKXwxU4KwneKVU/svAH2s3W9+XEBEFf AXWTTxLG2WqEszt2uBKK68GacfkiZ7H0p0ueKs8GDotJy71BxJ90zT0aSj6kZI85llkK VBo3vFt1u8t5zzhUzn0kgAO3k80kK3z5ivYli9V+jzi3N8YsTHYowhpVSKy7A/aKDOXM TBXPEUIIce92i/vmuo1GKMECt7YljBHlmCgGE+60u7tylYdeIXpzQBlk+811rEG7BZc+ ChLfslQPgaN39LkszUsMJptXph8LkUtk/sD6pV9fvicXHjHfYN4+dIofeje5aAe6w/BJ kdaA== 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 m11-20020a170902f64b00b001a95b85b070si9730186plg.604.2023.06.15.06.55.43; Thu, 15 Jun 2023 06:55:55 -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 S1344404AbjFONg6 (ORCPT + 99 others); Thu, 15 Jun 2023 09:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344361AbjFONgV (ORCPT ); Thu, 15 Jun 2023 09:36:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96DE7358B for ; Thu, 15 Jun 2023 06:35:10 -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 86325638B3 for ; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F19F1C433CC; Thu, 15 Jun 2023 13:34:16 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7A-000To3-0E; Thu, 15 Jun 2023 09:34:16 -0400 Message-ID: <20230615133415.888378523@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:37 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave , sunliming Subject: [for-linus][PATCH 06/15] selftests/user_events: Add ftrace self-test for empty arguments events References: <20230615130531.200384328@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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?1768777166916270389?= X-GMAIL-MSGID: =?utf-8?q?1768777166916270389?= From: sunliming Tests to ensure events that has empty arguments can input trace record correctly when using ftrace. Link: https://lkml.kernel.org/r/20230606062027.1008398-3-sunliming@kylinos.cn Acked-by: Beau Belgrave Acked-by: Masami Hiramatsu (Google) Signed-off-by: sunliming Signed-off-by: Steven Rostedt (Google) --- .../selftests/user_events/ftrace_test.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c index 6e8c4b47281c..abfb49558a26 100644 --- a/tools/testing/selftests/user_events/ftrace_test.c +++ b/tools/testing/selftests/user_events/ftrace_test.c @@ -316,6 +316,39 @@ TEST_F(user, write_events) { ASSERT_EQ(EINVAL, errno); } +TEST_F(user, write_empty_events) { + struct user_reg reg = {0}; + struct iovec io[1]; + int before = 0, after = 0; + + reg.size = sizeof(reg); + reg.name_args = (__u64)"__test_event"; + reg.enable_bit = 31; + reg.enable_addr = (__u64)&self->check; + reg.enable_size = sizeof(self->check); + + io[0].iov_base = ®.write_index; + io[0].iov_len = sizeof(reg.write_index); + + /* Register should work */ + ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); + ASSERT_EQ(0, reg.write_index); + ASSERT_EQ(0, self->check); + + /* Enable event */ + self->enable_fd = open(enable_file, O_RDWR); + ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1"))) + + /* Event should now be enabled */ + ASSERT_EQ(1 << reg.enable_bit, self->check); + + /* Write should make it out to ftrace buffers */ + before = trace_bytes(); + ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 1)); + after = trace_bytes(); + ASSERT_GT(after, before); +} + TEST_F(user, write_fault) { struct user_reg reg = {0}; struct iovec io[2]; From patchwork Thu Jun 15 13:05:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp673209vqr; Thu, 15 Jun 2023 07:21:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4T/N0akQ26v3FCdulmhTGWtHTFdHWCQzptkBfWUe63hitinWs9jqS/GeXUcBtGJq7opCh5 X-Received: by 2002:a05:6808:b0c:b0:39c:71fc:4cb4 with SMTP id s12-20020a0568080b0c00b0039c71fc4cb4mr11512392oij.58.1686838890044; Thu, 15 Jun 2023 07:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686838889; cv=none; d=google.com; s=arc-20160816; b=GkFV07E3iwXMyoVHgL1Nc7smUnF9uak5qNiL28GclK+dQghYbkl5eNuVo2+yxxsEEr S1kJIbDdZp3vi4MOXYaEv4v8YGB/v4l9g+4i7FS30qKq090Ucm8byh2+F5NNeUlaV7rf fpkaZ8nTIjK3LRu2yr0ojclglyE5ZoOujX0UeALMqBY1Wf0Anx7EJnkLpOoMIrEfRaM6 Mrvuf0dXilA2YPbS66QqKYqTF1ZGumr4FlDqFO9aSQXpmWiYarq5Uwbk5dX3rUtfxCod Rl1TiZmWAzftrMj3o1Snmlgxu+/IQipUaIpox+CS8UdBgOcEX2sKctD35oMtqlS27NU0 7pGw== 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=//RRdv1TqMsGMlCJ28rAc5ADUb/9JWY+wnjFREEE/Q0=; b=cvHUc/0LYf67q4k0Ty18gd1ZwD7jkImmV/nslH2N779u1nAzy7Ho5+gulj+KvwddzL BY9gt5ybx5aZlLVfY2rGp1t0GdzIPbxPJR1gq5NEvD8/V+UvW2qgFUfv4F+rDwdkwjV5 Ayv4X6ITjUcOt5jZu5ijbp5Q2sAcE2iG9QXslt8Ahlu2JdZj2b6QK76G1ZKSMshPrqWq /4RjPxLn1HBnWYP17fAey6cPAvr90AEAduZ/QiYrC/achtAO5vVBrMOM4gB1Mbv9SpLZ FWkhiFv2dJHLetSA4rf52Xp2WqSORn63Q/ysl7AD227JEOPWQ5bBRCf04a9JaRtn4HLS /+kw== 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 p9-20020a639509000000b0053f24deef0dsi12794683pgd.312.2023.06.15.07.21.13; Thu, 15 Jun 2023 07:21:29 -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 S1343593AbjFONg1 (ORCPT + 99 others); Thu, 15 Jun 2023 09:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344753AbjFONfY (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 E36CD30F8 for ; Thu, 15 Jun 2023 06:34:47 -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 B75636371C for ; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32EC1C433C9; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7A-000Tob-0r; Thu, 15 Jun 2023 09:34:16 -0400 Message-ID: <20230615133416.089967064@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:38 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave , sunliming Subject: [for-linus][PATCH 07/15] selftests/user_events: Clear the events after perf self-test 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?1768778776161755663?= X-GMAIL-MSGID: =?utf-8?q?1768778776161755663?= From: sunliming When the self test is completed, perf self-test left the user events not to be cleared. Clear the events by unregister and delete the event. Link: https://lkml.kernel.org/r/20230606062027.1008398-4-sunliming@kylinos.cn Acked-by: Beau Belgrave Acked-by: Masami Hiramatsu (Google) Signed-off-by: sunliming Signed-off-by: Steven Rostedt (Google) --- .../testing/selftests/user_events/perf_test.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/testing/selftests/user_events/perf_test.c b/tools/testing/selftests/user_events/perf_test.c index a070258d4449..e97f24ab6e2f 100644 --- a/tools/testing/selftests/user_events/perf_test.c +++ b/tools/testing/selftests/user_events/perf_test.c @@ -81,6 +81,32 @@ static int get_offset(void) return offset; } +static int clear(int *check) +{ + struct user_unreg unreg = {0}; + + unreg.size = sizeof(unreg); + unreg.disable_bit = 31; + unreg.disable_addr = (__u64)check; + + int fd = open(data_file, O_RDWR); + + if (fd == -1) + return -1; + + if (ioctl(fd, DIAG_IOCSUNREG, &unreg) == -1) + if (errno != ENOENT) + return -1; + + if (ioctl(fd, DIAG_IOCSDEL, "__test_event") == -1) + if (errno != ENOENT) + return -1; + + close(fd); + + return 0; +} + FIXTURE(user) { int data_fd; int check; @@ -93,6 +119,9 @@ FIXTURE_SETUP(user) { FIXTURE_TEARDOWN(user) { close(self->data_fd); + + if (clear(&self->check) != 0) + printf("WARNING: Clear didn't work!\n"); } TEST_F(user, perf_write) { From patchwork Thu Jun 15 13:05:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp678058vqr; Thu, 15 Jun 2023 07:29:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QovMl8bjhtWSTL08jbtivtDeXkQBOOL92nqLy5eMvuM3Q5B8aPLXbQ09BbxpTxZ8Xlm5v X-Received: by 2002:aa7:d44e:0:b0:519:9b17:6938 with SMTP id q14-20020aa7d44e000000b005199b176938mr3301116edr.4.1686839349986; Thu, 15 Jun 2023 07:29:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686839349; cv=none; d=google.com; s=arc-20160816; b=nKyfyCQPn0g7fT03Pofm0/KuVZ/IeWYPhqtyRq75ZBOaL7+z9d0ZLiKHCtISxfB85X WgPzzcpIWzjKdnrs5hpESYjlEPL+QZ2V5qhTBMAOq96tIN6+Zp0HAP3MbG6vymD2v/5y jbB54g886h0wElAStOafUsb/DY0HRPFZdcS2DeOwGqV9e8tVd+95vbf69X26fjqGhZ+U H5g2DzyBsOT6nh00QXh0OYG3xwYAMDyXgbcKtPLR85x9mGgBInbjxTrvSAZ2wHOB2hh5 oNkD6ev4gMiRAfH+LH7pgaSb9RX7U5FjCstE9xaN2CfxRbw67RVbUWfZjnqA0YMq3Buo 8Vlw== 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=STReUXLsvfStNDKEbOiovkKamKKgPKg9PVenROvLuUA=; b=C1S2CcTpLCIAraRclvJiMj0CBPT/Xm1eI06sjXIDpC0eHSwYSQpY+uNIkKjMaxsqFq Vgryx0w5N8W9qWREsqTzokIe5eodhgd4RFniGfMVF439hB+iWIhIeYFoJMnlsK+w6Z3q ItAdGB2ZikgA5jQXl1SlLfFGvCZT/7d6YbsZqbefuTJy9pZ9h6Z6QfKX9jBQt7eHrHIg xEphw9Av0cEbLYO22Fm0H3N84S0knq8yCGMFYl7dUo4sE4Weazt9Q7MQzDjQs4h+Sii7 uCodecXIup/obfqzjvQ8vk5qbDpS7IQWJ8S9TIKaTp1URmrRj+4xHsCHzcBJOTI/yi7O wioQ== 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 i18-20020a50fc12000000b005188259bbe0si648391edr.369.2023.06.15.07.28.43; Thu, 15 Jun 2023 07:29:09 -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 S1344472AbjFONhH (ORCPT + 99 others); Thu, 15 Jun 2023 09:37:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344388AbjFONgX (ORCPT ); Thu, 15 Jun 2023 09:36:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DE002D5F for ; Thu, 15 Jun 2023 06:35:12 -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 F026C63904 for ; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 646BBC433CB; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7A-000TpB-1W; Thu, 15 Jun 2023 09:34:16 -0400 Message-ID: <20230615133416.288344909@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:39 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave , sunliming Subject: [for-linus][PATCH 08/15] selftests/user_events: Add perf self-test for empty arguments events References: <20230615130531.200384328@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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?1768779258086015959?= X-GMAIL-MSGID: =?utf-8?q?1768779258086015959?= From: sunliming Tests to ensure events that has empty arguments can input trace record correctly when using perf. Link: https://lkml.kernel.org/r/20230606062027.1008398-5-sunliming@kylinos.cn Acked-by: Beau Belgrave Acked-by: Masami Hiramatsu (Google) Signed-off-by: sunliming Signed-off-by: Steven Rostedt (Google) --- .../testing/selftests/user_events/perf_test.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/testing/selftests/user_events/perf_test.c b/tools/testing/selftests/user_events/perf_test.c index e97f24ab6e2f..8b09be566fa2 100644 --- a/tools/testing/selftests/user_events/perf_test.c +++ b/tools/testing/selftests/user_events/perf_test.c @@ -189,6 +189,59 @@ TEST_F(user, perf_write) { ASSERT_EQ(0, self->check); } +TEST_F(user, perf_empty_events) { + struct perf_event_attr pe = {0}; + struct user_reg reg = {0}; + struct perf_event_mmap_page *perf_page; + int page_size = sysconf(_SC_PAGESIZE); + int id, fd; + __u32 *val; + + reg.size = sizeof(reg); + reg.name_args = (__u64)"__test_event"; + reg.enable_bit = 31; + reg.enable_addr = (__u64)&self->check; + reg.enable_size = sizeof(self->check); + + /* Register should work */ + ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); + ASSERT_EQ(0, reg.write_index); + ASSERT_EQ(0, self->check); + + /* Id should be there */ + id = get_id(); + ASSERT_NE(-1, id); + + pe.type = PERF_TYPE_TRACEPOINT; + pe.size = sizeof(pe); + pe.config = id; + pe.sample_type = PERF_SAMPLE_RAW; + pe.sample_period = 1; + pe.wakeup_events = 1; + + /* Tracepoint attach should work */ + fd = perf_event_open(&pe, 0, -1, -1, 0); + ASSERT_NE(-1, fd); + + perf_page = mmap(NULL, page_size * 2, PROT_READ, MAP_SHARED, fd, 0); + ASSERT_NE(MAP_FAILED, perf_page); + + /* Status should be updated */ + ASSERT_EQ(1 << reg.enable_bit, self->check); + + /* Ensure write shows up at correct offset */ + ASSERT_NE(-1, write(self->data_fd, ®.write_index, + sizeof(reg.write_index))); + val = (void *)(((char *)perf_page) + perf_page->data_offset); + ASSERT_EQ(PERF_RECORD_SAMPLE, *val); + + munmap(perf_page, page_size * 2); + close(fd); + + /* Status should be updated */ + ASSERT_EQ(0, self->check); +} + int main(int argc, char **argv) { return test_harness_run(argc, argv); 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); From patchwork Thu Jun 15 13:05:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108534 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp652283vqr; Thu, 15 Jun 2023 06:55:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6m6FC5CCVAZhfbXNmLq7NncdyMewtYauvK3CvOCwoI5TodnXQPH6ENUrBMvV9kaO6tKX74 X-Received: by 2002:a05:6808:1b11:b0:39a:664c:9761 with SMTP id bx17-20020a0568081b1100b0039a664c9761mr16244222oib.29.1686837350918; Thu, 15 Jun 2023 06:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686837350; cv=none; d=google.com; s=arc-20160816; b=hzLt+x3beDP1bUy9X0nsp+CYkviwdfVpIB9wWefqbvTsH/kjbBhqZH8LoPDhNCsI2w JtugG4GS3jQko00bvjZRMUl0ZcoS3oViSM8bSdr9DJZmf9YzQLDZpqzQvZkU4V40et1R KYavwztqieRe1RzI0kQX9pG7ex9BZzznwSyH+HMaT/PswqgNLGSUUNciuAt7JZs82Ngf /YSZlAKEg2M1qlFZrXC3vo3TKibar/ji3X5ZfG7cUInWkZJsZy2vNh8rp24H9OhmW7ry 7YK+KEdMKW2Ab2wYRG73CVEc+F7hb9z7isWdy4hS52Py4RlNcfHuubPAQ99kmD4n56Qe +Vew== 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=9Aw3Ma5JovjDjUXawsslhDw58tqERZSUYj+uRxW8r7w=; b=sBAv/QmNlxfD4sqnaxSyGiaaX5Ftx0nx0ThctAXswqZwGq43fMPqvG8FAuuZidlpfl HI5GAWipo4uEttKfhVzMt9CWMDNSPtcTM/asUBtwoDVMkcCfk7LBZhLOOKdmfdY5M/lq rRv6SB5l7A12QN3+HC05UdzNtzBKyuz62ihJmlf6O5Mb2hyOaLiC4OMFK3VAtCi721xH ylUK3Awyp8IyWNg4YgLf92e6jqR0F/FC3B+DHJLWz9bUUVyKXoZ++9PEa09aZG0GCYGG Ce9s0sX6seyXxstijOD91/8wwn6bplygbm/llc+eYjboioOci7JIIGO3U5GCZ08k6SBR mPBg== 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 k6-20020a634b46000000b0053fb3688fadsi9720552pgl.144.2023.06.15.06.55.35; Thu, 15 Jun 2023 06:55:50 -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 S1344364AbjFONhC (ORCPT + 99 others); Thu, 15 Jun 2023 09:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344374AbjFONgV (ORCPT ); Thu, 15 Jun 2023 09:36:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E534358E for ; Thu, 15 Jun 2023 06:35:11 -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 DE6B863B6C for ; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBD5DC433C8; Thu, 15 Jun 2023 13:34:17 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7A-000TqK-2p; Thu, 15 Jun 2023 09:34:16 -0400 Message-ID: <20230615133416.688476874@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:41 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave Subject: [for-linus][PATCH 10/15] tracing/user_events: Store register flags on events References: <20230615130531.200384328@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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?1768777161846641926?= X-GMAIL-MSGID: =?utf-8?q?1768777161846641926?= From: Beau Belgrave Currently we don't have any available flags for user processes to use to indicate options for user_events. We will soon have a flag to indicate the event should or should not auto-delete once it's not being used by anyone. Add a reg_flags field to user_events and parameters to existing functions to allow for this in future patches. Link: https://lkml.kernel.org/r/20230614163336.5797-2-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index cf6d4c02c363..629823e21447 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -87,6 +87,7 @@ struct user_event { struct list_head validators; refcount_t refcnt; int min_size; + int reg_flags; char status; }; @@ -165,7 +166,7 @@ typedef void (*user_event_func_t) (struct user_event *user, struct iov_iter *i, static int user_event_parse(struct user_event_group *group, char *name, char *args, char *flags, - struct user_event **newuser); + struct user_event **newuser, int reg_flags); static struct user_event_mm *user_event_mm_get(struct user_event_mm *mm); static struct user_event_mm *user_event_mm_get_all(struct user_event *user); @@ -810,7 +811,8 @@ static struct list_head *user_event_get_fields(struct trace_event_call *call) * Upon success user_event has its ref count increased by 1. */ static int user_event_parse_cmd(struct user_event_group *group, - char *raw_command, struct user_event **newuser) + char *raw_command, struct user_event **newuser, + int reg_flags) { char *name = raw_command; char *args = strpbrk(name, " "); @@ -824,7 +826,7 @@ static int user_event_parse_cmd(struct user_event_group *group, if (flags) *flags++ = '\0'; - return user_event_parse(group, name, args, flags, newuser); + return user_event_parse(group, name, args, flags, newuser, reg_flags); } static int user_field_array_size(const char *type) @@ -1588,7 +1590,7 @@ static int user_event_create(const char *raw_command) mutex_lock(&group->reg_mutex); - ret = user_event_parse_cmd(group, name, &user); + ret = user_event_parse_cmd(group, name, &user, 0); if (!ret) refcount_dec(&user->refcnt); @@ -1751,7 +1753,7 @@ static int user_event_trace_register(struct user_event *user) */ static int user_event_parse(struct user_event_group *group, char *name, char *args, char *flags, - struct user_event **newuser) + struct user_event **newuser, int reg_flags) { int ret; u32 key; @@ -1846,6 +1848,8 @@ static int user_event_parse(struct user_event_group *group, char *name, if (ret) goto put_user_lock; + user->reg_flags = reg_flags; + /* Ensure we track self ref and caller ref (2) */ refcount_set(&user->refcnt, 2); @@ -2144,7 +2148,7 @@ static long user_events_ioctl_reg(struct user_event_file_info *info, return ret; } - ret = user_event_parse_cmd(info->group, name, &user); + ret = user_event_parse_cmd(info->group, name, &user, reg.flags); if (ret) { kfree(name); From patchwork Thu Jun 15 13:05:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108533 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp651167vqr; Thu, 15 Jun 2023 06:53:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ639gxqJQ79vTiagDP7iehV/TzPZ2jJLOQF8SM60QGq3NpNSPsyOgtpBzgBekMuvSBIpbvx X-Received: by 2002:a17:902:e884:b0:1b5:16f2:a4e3 with SMTP id w4-20020a170902e88400b001b516f2a4e3mr1695857plg.30.1686837218601; Thu, 15 Jun 2023 06:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686837218; cv=none; d=google.com; s=arc-20160816; b=a3djs/Gc9NdV+/H7oyCyGUhKWyXF5nP/tTUp+K8q/KctLPqzVjLQLsXKrtjHzSru4J 9cIbTw/zIqBDt1t7NWT6ckeI9Vb5HNcsv2aT0aALmmY2v6sUtXkjo6j8rUsHMtNLMg+3 8V/5N8SrhcCrEZOrfzkEnlAhvgx7DeksFuTAB07fcaHA4FV8sanufTOk+B5RnVjIVUub ZeqVWOWeiepcYKax0rVe1ss64wW187ravd2i/PpgVQ+jBh/lUTVnkrMwmOvh49VVbcw8 3RYeH0qW2YrO9EkZy1VmJdQkRMp4k+HIVXI9HUWapnZZG5Aouyc9F5nIICCC1x48pqWk ONPg== 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=l/hD1eNqU5TArv8lQznE2IjdJqVtGhxDkU7huB6/QYg=; b=DlU52Jmchek5jo0iXuB0tivTFTcMCDez7NnCGvr6U7a5nqPOX7gEfr4T4kMr1GF68q cfRvgXyYdOO3Qg0LjEWIB0gUqcdYP3gMq2FstsC9SIE0RCSQtD/mSl0Ian3Vuouw/A+J ulhhKAgwSizCuSGAzpZd5ficyI+FqcUl3haHBSQZ7wNgK6wnIKW+mAB7Rqn6HmGzS09o EnObo8cD9605uemOLbd/n0WhlNh7Xrv4CrW1iF0pUJJgobpbiT1NSmIa2392tXLBmm3m Wq4h8VFvSGfr970ixXlXcNKHMDXlWh/PiuUBf+YaXVk7GroRxnT8TEBkoh6f3KlfhMkL MdyQ== 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.53.25; Thu, 15 Jun 2023 06:53:38 -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 S1344145AbjFONgc (ORCPT + 99 others); Thu, 15 Jun 2023 09:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344132AbjFONfa (ORCPT ); Thu, 15 Jun 2023 09:35:30 -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 A28432947 for ; Thu, 15 Jun 2023 06:34:59 -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 AB38E637EB for ; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24850C433C0; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7B-000Tqs-0F; Thu, 15 Jun 2023 09:34:17 -0400 Message-ID: <20230615133416.895403445@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:42 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave Subject: [for-linus][PATCH 11/15] tracing/user_events: Track refcount consistently via put/get 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?1768777023121904296?= X-GMAIL-MSGID: =?utf-8?q?1768777023121904296?= From: Beau Belgrave Various parts of the code today track user_event's refcnt field directly via a refcount_add/dec. This makes it hard to modify the behavior of the last reference decrement in all code paths consistently. For example, in the future we will auto-delete events upon the last reference going away. This last reference could happen in many places, but we want it to be consistently handled. Add user_event_get() and user_event_put() for the add/dec. Update all places where direct refcounts are being used to utilize these new functions. In each location pass if event_mutex is locked or not. This allows us to drop events automatically in future patches clearly. Ensure when caller states the lock is held, it really is (or is not) held. Link: https://lkml.kernel.org/r/20230614163336.5797-3-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 69 +++++++++++++++++++------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 629823e21447..c064458eea5c 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -177,6 +177,28 @@ static u32 user_event_key(char *name) return jhash(name, strlen(name), 0); } +static struct user_event *user_event_get(struct user_event *user) +{ + refcount_inc(&user->refcnt); + + return user; +} + +static void user_event_put(struct user_event *user, bool locked) +{ +#ifdef CONFIG_LOCKDEP + if (locked) + lockdep_assert_held(&event_mutex); + else + lockdep_assert_not_held(&event_mutex); +#endif + + if (unlikely(!user)) + return; + + refcount_dec(&user->refcnt); +} + static void user_event_group_destroy(struct user_event_group *group) { kfree(group->system_name); @@ -228,12 +250,13 @@ static struct user_event_group *user_event_group_create(void) return NULL; }; -static void user_event_enabler_destroy(struct user_event_enabler *enabler) +static void user_event_enabler_destroy(struct user_event_enabler *enabler, + bool locked) { list_del_rcu(&enabler->mm_enablers_link); /* No longer tracking the event via the enabler */ - refcount_dec(&enabler->event->refcnt); + user_event_put(enabler->event, locked); kfree(enabler); } @@ -295,7 +318,7 @@ static void user_event_enabler_fault_fixup(struct work_struct *work) /* User asked for enabler to be removed during fault */ if (test_bit(ENABLE_VAL_FREEING_BIT, ENABLE_BITOPS(enabler))) { - user_event_enabler_destroy(enabler); + user_event_enabler_destroy(enabler, true); goto out; } @@ -470,14 +493,12 @@ static bool user_event_enabler_dup(struct user_event_enabler *orig, if (!enabler) return false; - enabler->event = orig->event; + enabler->event = user_event_get(orig->event); enabler->addr = orig->addr; /* Only dup part of value (ignore future flags, etc) */ enabler->values = orig->values & ENABLE_VAL_DUP_MASK; - refcount_inc(&enabler->event->refcnt); - /* Enablers not exposed yet, RCU not required */ list_add(&enabler->mm_enablers_link, &mm->enablers); @@ -594,7 +615,7 @@ static void user_event_mm_destroy(struct user_event_mm *mm) struct user_event_enabler *enabler, *next; list_for_each_entry_safe(enabler, next, &mm->enablers, mm_enablers_link) - user_event_enabler_destroy(enabler); + user_event_enabler_destroy(enabler, false); mmdrop(mm->mm); kfree(mm); @@ -749,7 +770,7 @@ static struct user_event_enabler * exit or run exec(), which includes forks and clones. */ if (!*write_result) { - refcount_inc(&enabler->event->refcnt); + user_event_get(user); list_add_rcu(&enabler->mm_enablers_link, &user_mm->enablers); } @@ -1337,10 +1358,8 @@ static struct user_event *find_user_event(struct user_event_group *group, *outkey = key; hash_for_each_possible(group->register_table, user, node, key) - if (!strcmp(EVENT_NAME(user), name)) { - refcount_inc(&user->refcnt); - return user; - } + if (!strcmp(EVENT_NAME(user), name)) + return user_event_get(user); return NULL; } @@ -1554,12 +1573,12 @@ static int user_event_reg(struct trace_event_call *call, return ret; inc: - refcount_inc(&user->refcnt); + user_event_get(user); update_enable_bit_for(user); return 0; dec: update_enable_bit_for(user); - refcount_dec(&user->refcnt); + user_event_put(user, true); return 0; } @@ -1593,7 +1612,7 @@ static int user_event_create(const char *raw_command) ret = user_event_parse_cmd(group, name, &user, 0); if (!ret) - refcount_dec(&user->refcnt); + user_event_put(user, false); mutex_unlock(&group->reg_mutex); @@ -1794,7 +1813,7 @@ static int user_event_parse(struct user_event_group *group, char *name, return 0; error: - refcount_dec(&user->refcnt); + user_event_put(user, false); return ret; } @@ -1883,7 +1902,7 @@ static int delete_user_event(struct user_event_group *group, char *name) if (!user) return -ENOENT; - refcount_dec(&user->refcnt); + user_event_put(user, true); if (!user_event_last_ref(user)) return -EBUSY; @@ -2042,9 +2061,7 @@ static int user_events_ref_add(struct user_event_file_info *info, for (i = 0; i < count; ++i) new_refs->events[i] = refs->events[i]; - new_refs->events[i] = user; - - refcount_inc(&user->refcnt); + new_refs->events[i] = user_event_get(user); rcu_assign_pointer(info->refs, new_refs); @@ -2158,7 +2175,7 @@ static long user_events_ioctl_reg(struct user_event_file_info *info, ret = user_events_ref_add(info, user); /* No longer need parse ref, ref_add either worked or not */ - refcount_dec(&user->refcnt); + user_event_put(user, false); /* Positive number is index and valid */ if (ret < 0) @@ -2307,7 +2324,7 @@ static long user_events_ioctl_unreg(unsigned long uarg) set_bit(ENABLE_VAL_FREEING_BIT, ENABLE_BITOPS(enabler)); if (!test_bit(ENABLE_VAL_FAULTING_BIT, ENABLE_BITOPS(enabler))) - user_event_enabler_destroy(enabler); + user_event_enabler_destroy(enabler, true); /* Removed at least one */ ret = 0; @@ -2365,7 +2382,6 @@ static int user_events_release(struct inode *node, struct file *file) struct user_event_file_info *info = file->private_data; struct user_event_group *group; struct user_event_refs *refs; - struct user_event *user; int i; if (!info) @@ -2389,12 +2405,9 @@ static int user_events_release(struct inode *node, struct file *file) * The underlying user_events are ref counted, and cannot be freed. * After this decrement, the user_events may be freed elsewhere. */ - for (i = 0; i < refs->count; ++i) { - user = refs->events[i]; + for (i = 0; i < refs->count; ++i) + user_event_put(refs->events[i], false); - if (user) - refcount_dec(&user->refcnt); - } out: file->private_data = NULL; From patchwork Thu Jun 15 13:05:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108566 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp686108vqr; Thu, 15 Jun 2023 07:40:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6kU9lD3v91JnN/6tIgxYudQ1QKMvzDM0z8d8z3Emco4Jf0tKD84DPD5cveCYCG/u/uCX+O X-Received: by 2002:a54:4e1a:0:b0:398:55ec:6986 with SMTP id a26-20020a544e1a000000b0039855ec6986mr14380913oiy.13.1686840029230; Thu, 15 Jun 2023 07:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686840029; cv=none; d=google.com; s=arc-20160816; b=Qyoc6k1pMCKLMu5WbNO2sKpahFg8BUCD8/+GAw6q9dbjUHROSO+laz2cNNjXkX6o2+ Ks6/F/48p30Za06nC4Qer82MuCh9d6hArXBbE+6dcnj1rFWzvdUyZbnjZq7+ucIhhspM uL1kDFM5MnHSuiS2LWjQ26H2oB3asb/gab/ssXd9rYc8f3tUeNPDEQoreQK9I+bBkQ+V eAPMl9fG1zC7sl3uknzCDz9FtuayBIDKwjKar1tcOI8OY9cS/n9khHhzWCdjGoWlSNzE OlwDCwH0JyvudsgTyAVvFFpBuHNuAgC2YG24G45CroYPbbooO2iRDuJActdIWXIJkR1l 3NvQ== 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=zZzBeqCXAuA9rM3SCx4dkqI9AkrrmA4ZPrqwg3tfOcg=; b=dW2zFQ6VGcPK1tDZ5vT9T5VRdAOaAWGVK/ttcWAjWnNeu8Fb2hpGPb1RE+B8c1d9gI sN2iHVturHYDCY0CFtVzJK0RzpoBG/9fcT6+QOACNVWbHcdcYea8WmfG+xOy6EbQoKQe Pb4M7IIaaJxHXU9NPxn7Lp3PiTH88KNQTXWuO9WY46Po16imnD9NZdi2J183Gh6Cupcf 2J6b1Aaf/DB7m4rb3MQS3BIAFl91tRvJSHOKKI1s4E9HRW6cszpJuViJpzoFKx3P2oIR I8HiChL7dj0CJAVf1yaEofPKQprxeTU/TGnOX3Wzd2yQgU5SW1Z+K6QFNBcL6pUAclmx zQDg== 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 u123-20020a637981000000b00524eef20da6si13262719pgc.642.2023.06.15.07.40.16; Thu, 15 Jun 2023 07:40:29 -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 S1344301AbjFONgp (ORCPT + 99 others); Thu, 15 Jun 2023 09:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344199AbjFONfe (ORCPT ); Thu, 15 Jun 2023 09:35:34 -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 13F943586 for ; Thu, 15 Jun 2023 06:35:01 -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 DE6F463A1F for ; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49212C433C8; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7B-000TrS-0v; Thu, 15 Jun 2023 09:34:17 -0400 Message-ID: <20230615133417.099572277@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:43 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave Subject: [for-linus][PATCH 12/15] tracing/user_events: Add auto cleanup and future persist flag 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?1768779970747060402?= X-GMAIL-MSGID: =?utf-8?q?1768779970747060402?= From: Beau Belgrave Currently user events need to be manually deleted via the delete IOCTL call or via the dynamic_events file. Most operators and processes wish to have these events auto cleanup when they are no longer used by anything to prevent them piling without manual maintenance. However, some operators may not want this, such as pre-registering events via the dynamic_events tracefs file. Update user_event_put() to attempt an auto delete of the event if it's the last reference. The auto delete must run in a work queue to ensure proper behavior of class->reg() invocations that don't expect the call to go away from underneath them during the unregister. Add work_struct to user_event struct to ensure we can do this reliably. Add a persist flag, that is not yet exposed, to ensure we can toggle between auto-cleanup and leaving the events existing in the future. When a non-zero flag is seen during register, return -EINVAL to ensure ABI is clear for the user processes while we work out the best approach for persistent events. Link: https://lkml.kernel.org/r/20230614163336.5797-4-beaub@linux.microsoft.com Link: https://lore.kernel.org/linux-trace-kernel/20230518093600.3f119d68@rorschach.local.home/ Suggested-by: Steven Rostedt Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 139 ++++++++++++++++++++++++++++--- 1 file changed, 126 insertions(+), 13 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index c064458eea5c..8df0550415e7 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -49,6 +49,18 @@ #define EVENT_STATUS_PERF BIT(1) #define EVENT_STATUS_OTHER BIT(7) +/* + * User register flags are not allowed yet, keep them here until we are + * ready to expose them out to the user ABI. + */ +enum user_reg_flag { + /* Event will not delete upon last reference closing */ + USER_EVENT_REG_PERSIST = 1U << 0, + + /* This value or above is currently non-ABI */ + USER_EVENT_REG_MAX = 1U << 1, +}; + /* * Stores the system name, tables, and locks for a group of events. This * allows isolation for events by various means. @@ -85,6 +97,7 @@ struct user_event { struct hlist_node node; struct list_head fields; struct list_head validators; + struct work_struct put_work; refcount_t refcnt; int min_size; int reg_flags; @@ -171,6 +184,7 @@ static int user_event_parse(struct user_event_group *group, char *name, static struct user_event_mm *user_event_mm_get(struct user_event_mm *mm); static struct user_event_mm *user_event_mm_get_all(struct user_event *user); static void user_event_mm_put(struct user_event_mm *mm); +static int destroy_user_event(struct user_event *user); static u32 user_event_key(char *name) { @@ -184,19 +198,103 @@ static struct user_event *user_event_get(struct user_event *user) return user; } +static void delayed_destroy_user_event(struct work_struct *work) +{ + struct user_event *user = container_of( + work, struct user_event, put_work); + + mutex_lock(&event_mutex); + + if (!refcount_dec_and_test(&user->refcnt)) + goto out; + + if (destroy_user_event(user)) { + /* + * The only reason this would fail here is if we cannot + * update the visibility of the event. In this case the + * event stays in the hashtable, waiting for someone to + * attempt to delete it later. + */ + pr_warn("user_events: Unable to delete event\n"); + refcount_set(&user->refcnt, 1); + } +out: + mutex_unlock(&event_mutex); +} + static void user_event_put(struct user_event *user, bool locked) { -#ifdef CONFIG_LOCKDEP - if (locked) - lockdep_assert_held(&event_mutex); - else - lockdep_assert_not_held(&event_mutex); -#endif + bool delete; if (unlikely(!user)) return; - refcount_dec(&user->refcnt); + /* + * When the event is not enabled for auto-delete there will always + * be at least 1 reference to the event. During the event creation + * we initially set the refcnt to 2 to achieve this. In those cases + * the caller must acquire event_mutex and after decrement check if + * the refcnt is 1, meaning this is the last reference. When auto + * delete is enabled, there will only be 1 ref, IE: refcnt will be + * only set to 1 during creation to allow the below checks to go + * through upon the last put. The last put must always be done with + * the event mutex held. + */ + if (!locked) { + lockdep_assert_not_held(&event_mutex); + delete = refcount_dec_and_mutex_lock(&user->refcnt, &event_mutex); + } else { + lockdep_assert_held(&event_mutex); + delete = refcount_dec_and_test(&user->refcnt); + } + + if (!delete) + return; + + /* + * We now have the event_mutex in all cases, which ensures that + * no new references will be taken until event_mutex is released. + * New references come through find_user_event(), which requires + * the event_mutex to be held. + */ + + if (user->reg_flags & USER_EVENT_REG_PERSIST) { + /* We should not get here when persist flag is set */ + pr_alert("BUG: Auto-delete engaged on persistent event\n"); + goto out; + } + + /* + * Unfortunately we have to attempt the actual destroy in a work + * queue. This is because not all cases handle a trace_event_call + * being removed within the class->reg() operation for unregister. + */ + INIT_WORK(&user->put_work, delayed_destroy_user_event); + + /* + * Since the event is still in the hashtable, we have to re-inc + * the ref count to 1. This count will be decremented and checked + * in the work queue to ensure it's still the last ref. This is + * needed because a user-process could register the same event in + * between the time of event_mutex release and the work queue + * running the delayed destroy. If we removed the item now from + * the hashtable, this would result in a timing window where a + * user process would fail a register because the trace_event_call + * register would fail in the tracing layers. + */ + refcount_set(&user->refcnt, 1); + + if (WARN_ON_ONCE(!schedule_work(&user->put_work))) { + /* + * If we fail we must wait for an admin to attempt delete or + * another register/close of the event, whichever is first. + */ + pr_warn("user_events: Unable to queue delayed destroy\n"); + } +out: + /* Ensure if we didn't have event_mutex before we unlock it */ + if (!locked) + mutex_unlock(&event_mutex); } static void user_event_group_destroy(struct user_event_group *group) @@ -793,7 +891,12 @@ static struct user_event_enabler static __always_inline __must_check bool user_event_last_ref(struct user_event *user) { - return refcount_read(&user->refcnt) == 1; + int last = 0; + + if (user->reg_flags & USER_EVENT_REG_PERSIST) + last = 1; + + return refcount_read(&user->refcnt) == last; } static __always_inline __must_check @@ -1609,7 +1712,8 @@ static int user_event_create(const char *raw_command) mutex_lock(&group->reg_mutex); - ret = user_event_parse_cmd(group, name, &user, 0); + /* Dyn events persist, otherwise they would cleanup immediately */ + ret = user_event_parse_cmd(group, name, &user, USER_EVENT_REG_PERSIST); if (!ret) user_event_put(user, false); @@ -1780,6 +1884,10 @@ static int user_event_parse(struct user_event_group *group, char *name, int argc = 0; char **argv; + /* User register flags are not ready yet */ + if (reg_flags != 0 || flags != NULL) + return -EINVAL; + /* Prevent dyn_event from racing */ mutex_lock(&event_mutex); user = find_user_event(group, name, &key); @@ -1869,8 +1977,13 @@ static int user_event_parse(struct user_event_group *group, char *name, user->reg_flags = reg_flags; - /* Ensure we track self ref and caller ref (2) */ - refcount_set(&user->refcnt, 2); + if (user->reg_flags & USER_EVENT_REG_PERSIST) { + /* Ensure we track self ref and caller ref (2) */ + refcount_set(&user->refcnt, 2); + } else { + /* Ensure we track only caller ref (1) */ + refcount_set(&user->refcnt, 1); + } dyn_event_init(&user->devent, &user_event_dops); dyn_event_add(&user->devent, &user->call); @@ -2092,8 +2205,8 @@ static long user_reg_get(struct user_reg __user *ureg, struct user_reg *kreg) if (ret) return ret; - /* Ensure no flags, since we don't support any yet */ - if (kreg->flags != 0) + /* Ensure only valid flags */ + if (kreg->flags & ~(USER_EVENT_REG_MAX-1)) return -EINVAL; /* Ensure supported size */ From patchwork Thu Jun 15 13:05:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108559 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp680216vqr; Thu, 15 Jun 2023 07:31:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4HvlQ08TR5XsMZmry/x/GwvT9WHk63iT+uQIoYsZgniPnFYFX3UeuKt9JGIFVFWJ8KHmXg X-Received: by 2002:a17:907:26c5:b0:974:4f34:b043 with SMTP id bp5-20020a17090726c500b009744f34b043mr19205582ejc.1.1686839516544; Thu, 15 Jun 2023 07:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686839516; cv=none; d=google.com; s=arc-20160816; b=PlgL0iINroblrgPI5ukVmdAVG7xCCvqF1NOF3hLDUBuBjUvGU7uSsweci3W8Qfk0V0 TitRNSHlyfsBE7RI7BwQY2QO5j1RhICo+S3ikS0MccVX9FctVoZJwfmFMZEkjrXFBuge DB7vzy9vnPKg9Uh6FmZccdYbP+8IG6n3TCOBoE5SIHFnk6FKG350HR3PrHRoAceN3x9a 7UqEuPowR/0a0RVtBVEqwbbRVxeZsCxpi5DPJYBVimDnrMHD5KEohErmQmWkgdnP9333 1JluA2BLllqdC4IntW+Ev52dJAPIp1gyJc8Ic5KApx4KgHXUIXZVrBiyMMW7untwId0C 791w== 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=BImNSYzQj95/+i9ixsAK51PCsdUA8RmaK0981igdGcg=; b=uhJIvYpuqHveZfNPQxA3T2sz52pcI8iqC82jHUeVbKazH7o7uuSlDQ43Ww2ZajOt9g /gI9RjpNwH5FTODXbNyZ4pluaqS3+qyzHXC306s0VTA48TuyUeLQg9D6xk9bykJj5YI4 4tSvgugiHtKdl2+wzMZCGCI8hTbICFjpP1ncAJmayOQOgwy2gu9QCTFujsxF3HlwBeud BEyI7mUT8rehPS4v8HJBJoHV1i0EeaXO2uXpbjDNKj95zaI3gq3YbuTiDuFyax4NQD2v nfFOvXKuEDV4R/Gg7Oq46u5/7U6yDcB6V2EKpQHawy9YN4aVs/kUUOYiKrv4sBFtqZx3 KN4Q== 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 f14-20020a170906048e00b00982817b0858si1884609eja.364.2023.06.15.07.31.30; Thu, 15 Jun 2023 07:31:56 -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 S1344437AbjFONgk (ORCPT + 99 others); Thu, 15 Jun 2023 09:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344171AbjFONfb (ORCPT ); Thu, 15 Jun 2023 09:35:31 -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 37B492729 for ; Thu, 15 Jun 2023 06:35:01 -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 EB8E86399E for ; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 684D8C433CA; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7B-000Ts1-1Z; Thu, 15 Jun 2023 09:34:17 -0400 Message-ID: <20230615133417.304604444@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:44 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave Subject: [for-linus][PATCH 13/15] selftests/user_events: Ensure auto cleanup works as expected 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?1768779432751024635?= X-GMAIL-MSGID: =?utf-8?q?1768779432751024635?= From: Beau Belgrave User events now auto cleanup upon the last reference put. Update ftrace_test to ensure this works as expected. Ensure EBUSY delays while event is being deleted do not cause transient failures by waiting and re-attempting. Link: https://lkml.kernel.org/r/20230614163336.5797-5-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- .../selftests/user_events/ftrace_test.c | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c index abfb49558a26..eb6904d89f14 100644 --- a/tools/testing/selftests/user_events/ftrace_test.c +++ b/tools/testing/selftests/user_events/ftrace_test.c @@ -102,30 +102,56 @@ static int get_print_fmt(char *buffer, int len) return -1; } +static bool wait_for_delete(void) +{ + int i; + + for (i = 0; i < 1000; ++i) { + int fd = open(enable_file, O_RDONLY); + + if (fd == -1) + return true; + + close(fd); + usleep(1000); + } + + return false; +} + static int clear(int *check) { struct user_unreg unreg = {0}; + int fd; unreg.size = sizeof(unreg); unreg.disable_bit = 31; unreg.disable_addr = (__u64)check; - int fd = open(data_file, O_RDWR); + fd = open(data_file, O_RDWR); if (fd == -1) return -1; if (ioctl(fd, DIAG_IOCSUNREG, &unreg) == -1) if (errno != ENOENT) - return -1; - - if (ioctl(fd, DIAG_IOCSDEL, "__test_event") == -1) - if (errno != ENOENT) - return -1; + goto fail; + + if (ioctl(fd, DIAG_IOCSDEL, "__test_event") == -1) { + if (errno == EBUSY) { + if (!wait_for_delete()) + goto fail; + } else if (errno != ENOENT) + goto fail; + } close(fd); return 0; +fail: + close(fd); + + return -1; } static int check_print_fmt(const char *event, const char *expected, int *check) @@ -155,9 +181,8 @@ static int check_print_fmt(const char *event, const char *expected, int *check) /* Register should work */ ret = ioctl(fd, DIAG_IOCSREG, ®); - close(fd); - if (ret != 0) { + close(fd); printf("Reg failed in fmt\n"); return ret; } @@ -165,6 +190,8 @@ static int check_print_fmt(const char *event, const char *expected, int *check) /* Ensure correct print_fmt */ ret = get_print_fmt(print_fmt, sizeof(print_fmt)); + close(fd); + if (ret != 0) return ret; @@ -256,10 +283,10 @@ TEST_F(user, register_events) { unreg.disable_bit = 30; ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSUNREG, &unreg)); - /* Delete should work only after close and unregister */ + /* Delete should have been auto-done after close and unregister */ close(self->data_fd); - self->data_fd = open(data_file, O_RDWR); - ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSDEL, "__test_event")); + + ASSERT_EQ(true, wait_for_delete()); } TEST_F(user, write_events) { From patchwork Thu Jun 15 13:05:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108558 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp679569vqr; Thu, 15 Jun 2023 07:31:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XpQQcrXNTWtmQRAr39q+s/pSztyyOcgthXIXvpqwiENEQHB1C8m90p28jCnVS4DkLIpTn X-Received: by 2002:a17:907:3f83:b0:94b:ffe9:37fd with SMTP id hr3-20020a1709073f8300b0094bffe937fdmr15759782ejc.5.1686839467963; Thu, 15 Jun 2023 07:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686839467; cv=none; d=google.com; s=arc-20160816; b=B9Mv07qktALesMWwQqjDQQpdBL4MUuTbrxH+UNRrzJCTFxbHhtfuD9aHHPmMgKaLj5 DrjGJAN7de+YRb/r+V0fVWcAOtjHZJZDVFBNZkms8MhhW46ePbGTyTn4rNJ6RTb0KCGa L3uArQ5G3GIaeHcbaie7PPF82K/OxTYwaMwOgHqydICwKGRo+ki6w0Pu9J1TvVJXXk6r t2rtIGiENWJEHvrmMLSX2qlSlHPeHMnBObMtAfE7ADJBIeRJQK2jlLxQ+MiF3Hil7hgr oYDeq0Za7sNTJ0jOUaeMJLvQw82IzghlDPayWfjWbMakOB11hZ6F+yd9SbilM33Fj27D wBJg== 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=CsOXPNeOMNEa5hqE3IDybGSt6jAnbQeLckRva8RY20s=; b=ThkplasUODYWZGct71rPz1dZIxRsFcKYb5aieq2/IAAVNiXYQxP7k61OaPUw4kbrjR XTEmvTENjoFjFbF5jL9z2JmzdgwdIojVkoM1mYT4jCvtvKjxXnyUw8C7ey9x16+nxrDX RLMs41i9ujGZ4GqMYUrwaHULkjXNu00U5kGBXSZ8rb3u6urbw9f8efGzP7dqaGsmvJYy 53V1ywor6d0mR7x/6X7gcDBsq214P5oiUkXGWdWMreukc18w3bEfFNyYaoP3g1od0AGS jxp63eqJD4TqeG/gZQ+HlqQ3GrcT8jEeNCmiVsZUhWGZZ9FFkBrSbacrXMKoPHLkmTdx UXCQ== 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 t10-20020a1709064f0a00b0096f7c8c215bsi9281818eju.874.2023.06.15.07.30.38; Thu, 15 Jun 2023 07:31:07 -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 S1344005AbjFONhK (ORCPT + 99 others); Thu, 15 Jun 2023 09:37:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344389AbjFONgX (ORCPT ); Thu, 15 Jun 2023 09:36:23 -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 7E0092D76 for ; Thu, 15 Jun 2023 06:35:13 -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 1BF6D63C87 for ; Thu, 15 Jun 2023 13:34:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8888AC43391; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7B-000Tsb-2D; Thu, 15 Jun 2023 09:34:17 -0400 Message-ID: <20230615133417.503900831@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:45 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave Subject: [for-linus][PATCH 14/15] selftests/user_events: Adapt dyn_test to non-persist events 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?1768779381879659180?= X-GMAIL-MSGID: =?utf-8?q?1768779381879659180?= From: Beau Belgrave Now that user_events does not honor persist events the dynamic_events file cannot be easily used to test parsing and matching cases. Update dyn_test to use the direct ABI file instead of dynamic_events so that we still have testing coverage until persist events and dynamic_events file integration has been decided. Link: https://lkml.kernel.org/r/20230614163336.5797-6-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- .../testing/selftests/user_events/dyn_test.c | 177 ++++++++++++++---- 1 file changed, 136 insertions(+), 41 deletions(-) diff --git a/tools/testing/selftests/user_events/dyn_test.c b/tools/testing/selftests/user_events/dyn_test.c index 8879a7b04c6a..d6979a48478f 100644 --- a/tools/testing/selftests/user_events/dyn_test.c +++ b/tools/testing/selftests/user_events/dyn_test.c @@ -16,42 +16,140 @@ #include "../kselftest_harness.h" -const char *dyn_file = "/sys/kernel/tracing/dynamic_events"; -const char *clear = "!u:__test_event"; +const char *abi_file = "/sys/kernel/tracing/user_events_data"; +const char *enable_file = "/sys/kernel/tracing/events/user_events/__test_event/enable"; -static int Append(const char *value) +static bool wait_for_delete(void) { - int fd = open(dyn_file, O_RDWR | O_APPEND); - int ret = write(fd, value, strlen(value)); + int i; + + for (i = 0; i < 1000; ++i) { + int fd = open(enable_file, O_RDONLY); + + if (fd == -1) + return true; + + close(fd); + usleep(1000); + } + + return false; +} + +static int reg_event(int fd, int *check, int bit, const char *value) +{ + struct user_reg reg = {0}; + + reg.size = sizeof(reg); + reg.name_args = (__u64)value; + reg.enable_bit = bit; + reg.enable_addr = (__u64)check; + reg.enable_size = sizeof(*check); + + if (ioctl(fd, DIAG_IOCSREG, ®) == -1) + return -1; + + return 0; +} + +static int unreg_event(int fd, int *check, int bit) +{ + struct user_unreg unreg = {0}; + + unreg.size = sizeof(unreg); + unreg.disable_bit = bit; + unreg.disable_addr = (__u64)check; + + return ioctl(fd, DIAG_IOCSUNREG, &unreg); +} + +static int parse(int *check, const char *value) +{ + int fd = open(abi_file, O_RDWR); + int ret; + + if (fd == -1) + return -1; + + /* Until we have persist flags via dynamic events, use the base name */ + if (value[0] != 'u' || value[1] != ':') { + close(fd); + return -1; + } + + ret = reg_event(fd, check, 31, value + 2); + + if (ret != -1) { + if (unreg_event(fd, check, 31) == -1) + printf("WARN: Couldn't unreg event\n"); + } close(fd); + return ret; } -#define CLEAR() \ +static int check_match(int *check, const char *first, const char *second, bool *match) +{ + int fd = open(abi_file, O_RDWR); + int ret = -1; + + if (fd == -1) + return -1; + + if (reg_event(fd, check, 31, first) == -1) + goto cleanup; + + if (reg_event(fd, check, 30, second) == -1) { + if (errno == EADDRINUSE) { + /* Name is in use, with different fields */ + *match = false; + ret = 0; + } + + goto cleanup; + } + + *match = true; + ret = 0; +cleanup: + unreg_event(fd, check, 31); + unreg_event(fd, check, 30); + + close(fd); + + wait_for_delete(); + + return ret; +} + +#define TEST_MATCH(x, y) \ do { \ - int ret = Append(clear); \ - if (ret == -1) \ - ASSERT_EQ(ENOENT, errno); \ + bool match; \ + ASSERT_NE(-1, check_match(&self->check, x, y, &match)); \ + ASSERT_EQ(true, match); \ } while (0) -#define TEST_PARSE(x) \ +#define TEST_NMATCH(x, y) \ do { \ - ASSERT_NE(-1, Append(x)); \ - CLEAR(); \ + bool match; \ + ASSERT_NE(-1, check_match(&self->check, x, y, &match)); \ + ASSERT_EQ(false, match); \ } while (0) -#define TEST_NPARSE(x) ASSERT_EQ(-1, Append(x)) +#define TEST_PARSE(x) ASSERT_NE(-1, parse(&self->check, x)) + +#define TEST_NPARSE(x) ASSERT_EQ(-1, parse(&self->check, x)) FIXTURE(user) { + int check; }; FIXTURE_SETUP(user) { - CLEAR(); } FIXTURE_TEARDOWN(user) { - CLEAR(); + wait_for_delete(); } TEST_F(user, basic_types) { @@ -95,33 +193,30 @@ TEST_F(user, size_types) { TEST_NPARSE("u:__test_event char a 20"); } -TEST_F(user, flags) { - /* Should work */ - TEST_PARSE("u:__test_event:BPF_ITER u32 a"); - /* Forward compat */ - TEST_PARSE("u:__test_event:BPF_ITER,FLAG_FUTURE u32 a"); -} - TEST_F(user, matching) { - /* Register */ - ASSERT_NE(-1, Append("u:__test_event struct custom a 20")); - /* Should not match */ - TEST_NPARSE("!u:__test_event struct custom b"); - /* Should match */ - TEST_PARSE("!u:__test_event struct custom a"); - /* Multi field reg */ - ASSERT_NE(-1, Append("u:__test_event u32 a; u32 b")); - /* Non matching cases */ - TEST_NPARSE("!u:__test_event u32 a"); - TEST_NPARSE("!u:__test_event u32 b"); - TEST_NPARSE("!u:__test_event u32 a; u32 "); - TEST_NPARSE("!u:__test_event u32 a; u32 a"); - /* Matching case */ - TEST_PARSE("!u:__test_event u32 a; u32 b"); - /* Register */ - ASSERT_NE(-1, Append("u:__test_event u32 a; u32 b")); - /* Ensure trailing semi-colon case */ - TEST_PARSE("!u:__test_event u32 a; u32 b;"); + /* Single name matches */ + TEST_MATCH("__test_event u32 a", + "__test_event u32 a"); + + /* Multiple names match */ + TEST_MATCH("__test_event u32 a; u32 b", + "__test_event u32 a; u32 b"); + + /* Multiple names match with dangling ; */ + TEST_MATCH("__test_event u32 a; u32 b", + "__test_event u32 a; u32 b;"); + + /* Single name doesn't match */ + TEST_NMATCH("__test_event u32 a", + "__test_event u32 b"); + + /* Multiple names don't match */ + TEST_NMATCH("__test_event u32 a; u32 b", + "__test_event u32 b; u32 a"); + + /* Types don't match */ + TEST_NMATCH("__test_event u64 a; u64 b", + "__test_event u32 a; u32 b"); } int main(int argc, char **argv) From patchwork Thu Jun 15 13:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 108537 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp652382vqr; Thu, 15 Jun 2023 06:56:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BT5NfcduOiRTBWgaAJHkZYvq0IteZunxVwuVNI5fk96ikJmPwTmo9ANhn8LBp9yuU3sQW X-Received: by 2002:a05:6a00:16d1:b0:638:edbc:74ca with SMTP id l17-20020a056a0016d100b00638edbc74camr5692988pfc.0.1686837361413; Thu, 15 Jun 2023 06:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686837361; cv=none; d=google.com; s=arc-20160816; b=Itc2qaucBpKzAAl+Ks1EEhVxhmpI2ePzfhQuNJgLllG7q6QpelqObGiz0ABNyK6XzR CGnVve2pRl0KOwACQHrbGgLjIgE3ZFybdaA4XcoHdSmwpjolfQ6qkFOitjIpXYEfwV7f 960hEhLQVKXiqTNBMSDm923O3aljOM9+jG9GSN1R4h2FW//+tMZMp4RUT6tvokxU3kef uNj5UUJk5OGlYXIlWfePhJjMjrC0OD7VFe5SfP54VDfzMMIJvDq2lyQwVdKI6J6VYTXl /jqYBQyhi6DftQVjO30X52pQPJbKHwDbGCgBEvoa4t1wOg9P5qOudMFMY46+rumJOf0X lLYg== 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=fokOP9X+AKiilzyHiw4wv0ZL37U73aNwqMJC59Yzzpc=; b=nIf5VL7bv4p0fpdd7VR1fIEFXI59ZNGB3ZDc72D8aIhUGu+VQqnIsLlrZ9hAB1Ru8T GBq6tsoUw8h4SL9a2P2HLwBH/aHNWEFBf418aYDQ3t6+prqSxpl3gtggZCBcV/i8kq1j 1Bv1bnssgzJNsNnl9sCAUOoAwphoYWsclsXyxJe9Ki0jIfD7401y65AMHHqbcGU2cjU7 Kbl+Z5ljLOa9zucNI9J58NuakhKjCgyWk3rf2bnPDWKmpfwQ/sq9dw/ftPYwZsaEhKhx iAfWb3UJ/AAmF/0i14k5t59K6Ierq7EZ8mpo5g/2n1S7HQVLNkiqmk4DpZwK62cSOtLs oFXQ== 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 k26-20020aa79d1a000000b006650ccb39e9si9142252pfp.294.2023.06.15.06.55.49; Thu, 15 Jun 2023 06:56:01 -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 S1344428AbjFONge (ORCPT + 99 others); Thu, 15 Jun 2023 09:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344169AbjFONfb (ORCPT ); Thu, 15 Jun 2023 09:35:31 -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 9F9C22D4C for ; Thu, 15 Jun 2023 06:35:00 -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 E751263BBE for ; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C481CC433CD; Thu, 15 Jun 2023 13:34:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1q9n7B-000TtA-2s; Thu, 15 Jun 2023 09:34:17 -0400 Message-ID: <20230615133417.709819338@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 15 Jun 2023 09:05:46 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Beau Belgrave Subject: [for-linus][PATCH 15/15] tracing/user_events: Document auto-cleanup and remove dyn_event refs 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?1768777173177185276?= X-GMAIL-MSGID: =?utf-8?q?1768777173177185276?= From: Beau Belgrave Now user_events auto-cleanup upon the last reference by default. This makes it not possible to use the dynamics event file via tracefs. Document that auto-cleanup is enabled by default and remove the refernce to /sys/kernel/tracing/dynamic_events file to make this clear. Link: https://lkml.kernel.org/r/20230614163336.5797-7-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- Documentation/trace/user_events.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Documentation/trace/user_events.rst b/Documentation/trace/user_events.rst index f79987e16cf4..e7b07313550a 100644 --- a/Documentation/trace/user_events.rst +++ b/Documentation/trace/user_events.rst @@ -14,10 +14,6 @@ Programs can view status of the events via /sys/kernel/tracing/user_events_status and can both register and write data out via /sys/kernel/tracing/user_events_data. -Programs can also use /sys/kernel/tracing/dynamic_events to register and -delete user based events via the u: prefix. The format of the command to -dynamic_events is the same as the ioctl with the u: prefix applied. - Typically programs will register a set of events that they wish to expose to tools that can read trace_events (such as ftrace and perf). The registration process tells the kernel which address and bit to reflect if any tool has @@ -144,6 +140,9 @@ its name. Delete will only succeed if there are no references left to the event (in both user and kernel space). User programs should use a separate file to request deletes than the one used for registration due to this. +**NOTE:** By default events will auto-delete when there are no references left +to the event. Flags in the future may change this logic. + Unregistering ------------- If after registering an event it is no longer wanted to be updated then it can