From patchwork Fri Feb 23 14:18:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp613045dyb; Fri, 23 Feb 2024 06:18:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWfx7/5Cpxubc1ON+rxv8C+CU+Uc5d7f2r2hwE9PMA4Qx7VsI5yMBTegtmWzZAXfD+AH0zvQ1A+9MMH2yH/lXLCrcliYg== X-Google-Smtp-Source: AGHT+IHIni6qlkAo3Ljgdr/P0WSkIQQMcx58kDnUHEmvILdpDPp2itRRf0kpN3LfdjHRQg9GrezX X-Received: by 2002:a05:6402:b33:b0:565:46e6:56db with SMTP id bo19-20020a0564020b3300b0056546e656dbmr1512717edb.19.1708697882693; Fri, 23 Feb 2024 06:18:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697882; cv=pass; d=google.com; s=arc-20160816; b=03VW+7Ib+tiZqRdfoK4Xd2uC4ItqDoD/49BFcLJZunJtUJpFZhii/s6fnHOA6CbYDd CSgTvqh+KlVZYh1+RKqtUFdYZuzTyd7+rTo3SWBu/kuSsmPeMzgDJBJbHQa8rvzcaJKI lGogQEhs+4bRdWBfMzHcyfr8z61Y6F1sBRkIPxU19WMnLLZhQh8szrQn9l1TWS7EtCpv lerxZldkpEzDuQkP2RfdkDc0a8h/AILqpCvl3dAA5cgBgfChas/+QgvRchmu+J+ccSpN IANVthFvyWMLLJsSCRI7KatKwLBpmQ9O3RYPhbE1zq+BQvC60w7wkhEJGfO80xAEJOg9 bciw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=7FlQJsbhpPO749gipMjljoSYpk2ZzWguJn2wr2Dy0zU=; fh=sbDUv6PuKPAkpuv6zbp1fPCjJZUEufc8KwKtgDDsdwc=; b=cKjbaQvVKx8t71zWsB0U5T/WTEKyf9QL6kCeiuo80OKDpOMQsMl5q7ATnD26vSv4+f VAd57PfQoNstj0l1KQW8mRAGDXwvMjXuUnBttg++PXt+4chH/SOTTLZ3pXPLdti7micM C07hjA+xQpxtbduC+nilzUu8R18yUzxRITcZd7npXq6cNG4OIjXBycIY6dvaZZwyEoXH Hej19ESxVtHzMR8Wi2iGjDZvzfPD5+6ktBSIcVeQoKLK21De7EOU/6vcpJR22Zfu+fo+ t2nLrRYAF7Lum4ZWTgVICXoIZ2hk9fs2h9jP6bznxdOy4LE0EQkutRRslIQSRu+cBAaN J5uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78455-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78455-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x29-20020a50d61d000000b0056382b02728si6292083edi.328.2024.02.23.06.18.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:18:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78455-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78455-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78455-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2B75E1F234B1 for ; Fri, 23 Feb 2024 14:18:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48E2E82C63; Fri, 23 Feb 2024 14:17:11 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E82F7F7D0 for ; Fri, 23 Feb 2024 14:17:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; cv=none; b=m/MxUbH6kQk22Lfjad/FBjIn4iVX3PDuEJb9p/j4Imq7y8cKe6JRNcMD5PGjgreMjkiKhpoYrr0KuQ4VDiRuEZ4HUaRu4nV7qy/sjl+Tran3mU4idsQtDmxRHjeqDmKM+YVCEsdU98XlG1RrpF0dsTzw5GhAkpaveEUi+ajU4J0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; c=relaxed/simple; bh=7sp6LKfmVAODTBRGZ6mT00DB66BAm8reYLZmF3tLaL0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=XkkANpFP2Rj/ER4qKke60Ek8eIDtWOYNgCcM//ibUG9T33O8FQZevZwoV9t4vf7Zc1IdhFy56VgmatrNyYGp6BdMLk6O19JcwuDxq1GR7BpcEkELw6m+Ki1s5TRvH38gbn1GCJsGgFzRIYQ8pENcpKR0yLniWaTOlwfeMsLuxm8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D77C7C43390; Fri, 23 Feb 2024 14:17:08 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOD-000000077LG-34wV; Fri, 23 Feb 2024 09:19:01 -0500 Message-ID: <20240223141901.595795628@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:39 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Beau Belgrave Subject: [for-next][PATCH 01/13] tracing/user_events: Prepare find/delete for same name events References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699591274209301 X-GMAIL-MSGID: 1791699591274209301 From: Beau Belgrave The current code for finding and deleting events assumes that there will never be cases when user_events are registered with the same name, but different formats. Scenarios exist where programs want to use the same name but have different formats. An example is multiple versions of a program running side-by-side using the same event name, but with updated formats in each version. This change does not yet allow for multi-format events. If user_events are registered with the same name but different arguments the programs see the same return values as before. This change simply makes it possible to easily accommodate for this. Update find_user_event() to take in argument parameters and register flags to accommodate future multi-format event scenarios. Have find validate argument matching and return error pointers to cover when an existing event has the same name but different format. Update callers to handle error pointer logic. Move delete_user_event() to use hash walking directly now that find_user_event() has changed. Delete all events found that match the register name, stop if an error occurs and report back to the user. Update user_fields_match() to cover list_empty() scenarios now that find_user_event() uses it directly. This makes the logic consistent across several callsites. Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-2-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 107 +++++++++++++++++-------------- 1 file changed, 59 insertions(+), 48 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index e76f5e1efdf2..fce5ed5fec50 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -202,6 +202,8 @@ 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 bool user_fields_match(struct user_event *user, int argc, + const char **argv); static u32 user_event_key(char *name) { @@ -1493,17 +1495,24 @@ static int destroy_user_event(struct user_event *user) } static struct user_event *find_user_event(struct user_event_group *group, - char *name, u32 *outkey) + char *name, int argc, const char **argv, + u32 flags, u32 *outkey) { struct user_event *user; u32 key = user_event_key(name); *outkey = key; - hash_for_each_possible(group->register_table, user, node, key) - if (!strcmp(EVENT_NAME(user), name)) + hash_for_each_possible(group->register_table, user, node, key) { + if (strcmp(EVENT_NAME(user), name)) + continue; + + if (user_fields_match(user, argc, argv)) return user_event_get(user); + return ERR_PTR(-EADDRINUSE); + } + return NULL; } @@ -1860,6 +1869,9 @@ static bool user_fields_match(struct user_event *user, int argc, struct list_head *head = &user->fields; int i = 0; + if (argc == 0) + return list_empty(head); + list_for_each_entry_reverse(field, head, link) { if (!user_field_match(field, argc, argv, &i)) return false; @@ -1880,10 +1892,8 @@ static bool user_event_match(const char *system, const char *event, match = strcmp(EVENT_NAME(user), event) == 0 && (!system || strcmp(system, USER_EVENTS_SYSTEM) == 0); - if (match && argc > 0) + if (match) match = user_fields_match(user, argc, argv); - else if (match && argc == 0) - match = list_empty(&user->fields); return match; } @@ -1922,11 +1932,11 @@ static int user_event_parse(struct user_event_group *group, char *name, char *args, char *flags, struct user_event **newuser, int reg_flags) { - int ret; - u32 key; struct user_event *user; + char **argv = NULL; int argc = 0; - char **argv; + int ret; + u32 key; /* Currently don't support any text based flags */ if (flags != NULL) @@ -1935,41 +1945,34 @@ static int user_event_parse(struct user_event_group *group, char *name, if (!user_event_capable(reg_flags)) return -EPERM; + if (args) { + argv = argv_split(GFP_KERNEL, args, &argc); + + if (!argv) + return -ENOMEM; + } + /* Prevent dyn_event from racing */ mutex_lock(&event_mutex); - user = find_user_event(group, name, &key); + user = find_user_event(group, name, argc, (const char **)argv, + reg_flags, &key); mutex_unlock(&event_mutex); - if (user) { - if (args) { - argv = argv_split(GFP_KERNEL, args, &argc); - if (!argv) { - ret = -ENOMEM; - goto error; - } + if (argv) + argv_free(argv); - 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; - } + if (IS_ERR(user)) + return PTR_ERR(user); + + 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); return 0; -error: - user_event_put(user, false); - return ret; } user = kzalloc(sizeof(*user), GFP_KERNEL_ACCOUNT); @@ -2052,25 +2055,33 @@ static int user_event_parse(struct user_event_group *group, char *name, } /* - * Deletes a previously created event if it is no longer being used. + * Deletes previously created events if they are no longer being used. */ static int delete_user_event(struct user_event_group *group, char *name) { - u32 key; - struct user_event *user = find_user_event(group, name, &key); + struct user_event *user; + struct hlist_node *tmp; + u32 key = user_event_key(name); + int ret = -ENOENT; - if (!user) - return -ENOENT; + /* Attempt to delete all event(s) with the name passed in */ + hash_for_each_possible_safe(group->register_table, user, tmp, node, key) { + if (strcmp(EVENT_NAME(user), name)) + continue; - user_event_put(user, true); + if (!user_event_last_ref(user)) + return -EBUSY; - if (!user_event_last_ref(user)) - return -EBUSY; + if (!user_event_capable(user->reg_flags)) + return -EPERM; - if (!user_event_capable(user->reg_flags)) - return -EPERM; + ret = destroy_user_event(user); - return destroy_user_event(user); + if (ret) + goto out; + } +out: + return ret; } /* From patchwork Fri Feb 23 14:18:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp613637dyb; Fri, 23 Feb 2024 06:19:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVD8jQ8ZIhOQVzjzGiO50RauvCNTt4+mFk5C+g54oJWcCZMbWxZKxRpG41f9IDDNmTG3gr6TJ+QCAsWzPiLLFL5MioFHQ== X-Google-Smtp-Source: AGHT+IGauq7t7RvXKLBVx2Yj++AJgl+wRk45nTBOfXQ8/YZdECJ2wI5tymoxsCFiTfA3bZ5bu8vU X-Received: by 2002:a05:6a00:1951:b0:6e4:d81e:1399 with SMTP id s17-20020a056a00195100b006e4d81e1399mr2086364pfk.22.1708697939935; Fri, 23 Feb 2024 06:18:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697939; cv=pass; d=google.com; s=arc-20160816; b=i0PF6MSwiwdSeNpb/OqYEGSZPhhaMDK7f6klB/GIF/Ofol01qvpDvoys1FO2EHqEoZ 7QU52TLG0rNgv2PHZFgd4Rz3Zq81+b/G8K1SzCYQA4/z0osUH3SF+aYrFxGuBOPNYqrf JpqgV1j0RQTaVl8gng52wE/TVilXRoNhYzyUn9zILta7IbeNvry/vlBbM4PFeVPTvHYX h4yw7tstXa+yvHh6wdH3rB+h8MQZG8yGB0i+faotygZLvffdJSrmvogXe3AaI/FdyXou Mfk7ru/TGA9wUi3aBF7fH5xbNWCF3v3sSDUzjFmDR+LtDKcUAHcNMfq1/L6rg7+uX+ZL +ypw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=44eupipNW/VVJqHtj0+VXRXjWTG0bHCehqmawCHbw5E=; fh=sbDUv6PuKPAkpuv6zbp1fPCjJZUEufc8KwKtgDDsdwc=; b=G0/T4dhHR5RDdxjidlxM2Dm7AMDVXAlvwsDKfI+A3ssT99Srkjn9oKxHY9Wjjv8U2s OyPtw9QreASDk7m6zm7zwW4lvzuHjsCtCAn943EaA1r13IH1/puRBPhsAyejrjaoXQsz zMpLqagHaFyenh3NB6laxSgcRoCszXfHIOFdLGwi23ae1RtdaMwpsj4pk2LURYSycpCN wGqa3lAz9xMcNft2kY/sHww/PM3Qny9+Wyo/IrfeiGaMcfwOJz/Pq9D/q8AMhC3seQkN Ke36LYY43KCLhHibBQXPTFB1IT0dJ/20MjKvBiklqjxPTnVpnyjp0+fWEnNbyMKaPwQe TlhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78456-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u29-20020a63b55d000000b005d576171e69si8545361pgo.88.2024.02.23.06.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:18:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78456-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BBE3A285377 for ; Fri, 23 Feb 2024 14:18:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD9F284A5D; Fri, 23 Feb 2024 14:17:12 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7803980629 for ; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; cv=none; b=Khibupd50Wfx5tnQclMsE7r1+/H8h4icIFaxFHm12h/36eotlZcdDmJ+QVaOhEMAchEr4huXcMBP+Cc+rGVe0HNBBryQ0ksHvLVE/LC6fg+Gv1PsZXTo303/tCgnaHN0/9LqKtkZ6pcVFiA5mKpoe/kiHJqcXcWgXy5A6zfpH8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; c=relaxed/simple; bh=Up9eFZpr8dIJaujb9WoqM/K2VjYXnomqdkuQX/lsnUg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=lrq7HYeTTLNx0yLUvqE6/SDFNpLcAIXz4K+6IGjOhvDgLk/H9ceKxFGx+plhPfcgoKtOkVW6MJd6rmRqvpiDloHYtRsOCGtJLS5pLxnWOs+dtaDaa7UUQpXDXUZ4svMJk1S74QCfYr+n4PZfsJWmO9LK4LkTcf0GkQzJ0l1JUCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA51FC433C7; Fri, 23 Feb 2024 14:17:08 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOD-000000077Lk-3kWI; Fri, 23 Feb 2024 09:19:01 -0500 Message-ID: <20240223141901.755071412@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:40 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Beau Belgrave Subject: [for-next][PATCH 02/13] tracing/user_events: Introduce multi-format events References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699650957155703 X-GMAIL-MSGID: 1791699650957155703 From: Beau Belgrave Currently user_events supports 1 event with the same name and must have the exact same format when referenced by multiple programs. This opens an opportunity for malicious or poorly thought through programs to create events that others use with different formats. Another scenario is user programs wishing to use the same event name but add more fields later when the software updates. Various versions of a program may be running side-by-side, which is prevented by the current single format requirement. Add a new register flag (USER_EVENT_REG_MULTI_FORMAT) which indicates the user program wishes to use the same user_event name, but may have several different formats of the event. When this flag is used, create the underlying tracepoint backing the user_event with a unique name per-version of the format. It's important that existing ABI users do not get this logic automatically, even if one of the multi format events matches the format. This ensures existing programs that create events and assume the tracepoint name will match exactly continue to work as expected. Add logic to only check multi-format events with other multi-format events and single-format events to only check single-format events during find. Change system name of the multi-format event tracepoint to ensure that multi-format events are isolated completely from single-format events. This prevents single-format names from conflicting with multi-format events if they end with the same suffix as the multi-format events. Add a register_name (reg_name) to the user_event struct which allows for split naming of events. We now have the name that was used to register within user_events as well as the unique name for the tracepoint. Upon registering events ensure matches based on first the reg_name, followed by the fields and format of the event. This allows for multiple events with the same registered name to have different formats. The underlying tracepoint will have a unique name in the format of {reg_name}.{unique_id}. For example, if both "test u32 value" and "test u64 value" are used with the USER_EVENT_REG_MULTI_FORMAT the system would have 2 unique tracepoints. The dynamic_events file would then show the following: u:test u64 count u:test u32 count The actual tracepoint names look like this: test.0 test.1 Both would be under the new user_events_multi system name to prevent the older ABI from being used to squat on multi-formatted events and block their use. Deleting events via "!u:test u64 count" would only delete the first tracepoint that matched that format. When the delete ABI is used all events with the same name will be attempted to be deleted. If per-version deletion is required, user programs should either not use persistent events or delete them via dynamic_events. Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-3-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- include/uapi/linux/user_events.h | 6 +- kernel/trace/trace_events_user.c | 102 +++++++++++++++++++++++++++---- 2 files changed, 95 insertions(+), 13 deletions(-) diff --git a/include/uapi/linux/user_events.h b/include/uapi/linux/user_events.h index f74f3aedd49c..a03de03dccbc 100644 --- a/include/uapi/linux/user_events.h +++ b/include/uapi/linux/user_events.h @@ -12,6 +12,7 @@ #include #define USER_EVENTS_SYSTEM "user_events" +#define USER_EVENTS_MULTI_SYSTEM "user_events_multi" #define USER_EVENTS_PREFIX "u:" /* Create dynamic location entry within a 32-bit value */ @@ -22,8 +23,11 @@ enum user_reg_flag { /* Event will not delete upon last reference closing */ USER_EVENT_REG_PERSIST = 1U << 0, + /* Event will be allowed to have multiple formats */ + USER_EVENT_REG_MULTI_FORMAT = 1U << 1, + /* This value or above is currently non-ABI */ - USER_EVENT_REG_MAX = 1U << 1, + USER_EVENT_REG_MAX = 1U << 2, }; /* diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index fce5ed5fec50..70d428c394b6 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -34,7 +34,8 @@ /* Limit how long of an event name plus args within the subsystem. */ #define MAX_EVENT_DESC 512 -#define EVENT_NAME(user_event) ((user_event)->tracepoint.name) +#define EVENT_NAME(user_event) ((user_event)->reg_name) +#define EVENT_TP_NAME(user_event) ((user_event)->tracepoint.name) #define MAX_FIELD_ARRAY_SIZE 1024 /* @@ -54,10 +55,13 @@ * allows isolation for events by various means. */ struct user_event_group { - char *system_name; - struct hlist_node node; - struct mutex reg_mutex; + char *system_name; + char *system_multi_name; + struct hlist_node node; + struct mutex reg_mutex; DECLARE_HASHTABLE(register_table, 8); + /* ID that moves forward within the group for multi-event names */ + u64 multi_id; }; /* Group for init_user_ns mapping, top-most group */ @@ -78,6 +82,7 @@ static unsigned int current_user_events; */ struct user_event { struct user_event_group *group; + char *reg_name; struct tracepoint tracepoint; struct trace_event_call call; struct trace_event_class class; @@ -127,6 +132,8 @@ struct user_event_enabler { #define ENABLE_BIT(e) ((int)((e)->values & ENABLE_VAL_BIT_MASK)) +#define EVENT_MULTI_FORMAT(f) ((f) & USER_EVENT_REG_MULTI_FORMAT) + /* Used for asynchronous faulting in of pages */ struct user_event_enabler_fault { struct work_struct work; @@ -330,6 +337,7 @@ static void user_event_put(struct user_event *user, bool locked) static void user_event_group_destroy(struct user_event_group *group) { kfree(group->system_name); + kfree(group->system_multi_name); kfree(group); } @@ -348,6 +356,11 @@ static char *user_event_group_system_name(void) return system_name; } +static char *user_event_group_system_multi_name(void) +{ + return kstrdup(USER_EVENTS_MULTI_SYSTEM, GFP_KERNEL); +} + static struct user_event_group *current_user_event_group(void) { return init_group; @@ -367,6 +380,11 @@ static struct user_event_group *user_event_group_create(void) if (!group->system_name) goto error; + group->system_multi_name = user_event_group_system_multi_name(); + + if (!group->system_multi_name) + goto error; + mutex_init(&group->reg_mutex); hash_init(group->register_table); @@ -1482,6 +1500,11 @@ static int destroy_user_event(struct user_event *user) hash_del(&user->node); user_event_destroy_validators(user); + + /* If we have different names, both must be freed */ + if (EVENT_NAME(user) != EVENT_TP_NAME(user)) + kfree(EVENT_TP_NAME(user)); + kfree(user->call.print_fmt); kfree(EVENT_NAME(user)); kfree(user); @@ -1504,12 +1527,24 @@ static struct user_event *find_user_event(struct user_event_group *group, *outkey = key; hash_for_each_possible(group->register_table, user, node, key) { + /* + * Single-format events shouldn't return multi-format + * events. Callers expect the underlying tracepoint to match + * the name exactly in these cases. Only check like-formats. + */ + if (EVENT_MULTI_FORMAT(flags) != EVENT_MULTI_FORMAT(user->reg_flags)) + continue; + if (strcmp(EVENT_NAME(user), name)) continue; if (user_fields_match(user, argc, argv)) return user_event_get(user); + /* Scan others if this is a multi-format event */ + if (EVENT_MULTI_FORMAT(flags)) + continue; + return ERR_PTR(-EADDRINUSE); } @@ -1889,8 +1924,12 @@ static bool user_event_match(const char *system, const char *event, struct user_event *user = container_of(ev, struct user_event, devent); bool match; - match = strcmp(EVENT_NAME(user), event) == 0 && - (!system || strcmp(system, USER_EVENTS_SYSTEM) == 0); + match = strcmp(EVENT_NAME(user), event) == 0; + + if (match && system) { + match = strcmp(system, user->group->system_name) == 0 || + strcmp(system, user->group->system_multi_name) == 0; + } if (match) match = user_fields_match(user, argc, argv); @@ -1923,6 +1962,33 @@ static int user_event_trace_register(struct user_event *user) return ret; } +static int user_event_set_tp_name(struct user_event *user) +{ + lockdep_assert_held(&user->group->reg_mutex); + + if (EVENT_MULTI_FORMAT(user->reg_flags)) { + char *multi_name; + + multi_name = kasprintf(GFP_KERNEL_ACCOUNT, "%s.%llx", + user->reg_name, user->group->multi_id); + + if (!multi_name) + return -ENOMEM; + + user->call.name = multi_name; + user->tracepoint.name = multi_name; + + /* Inc to ensure unique multi-event name next time */ + user->group->multi_id++; + } else { + /* Non Multi-format uses register name */ + user->call.name = user->reg_name; + user->tracepoint.name = user->reg_name; + } + + return 0; +} + /* * Parses the event name, arguments and flags then registers if successful. * The name buffer lifetime is owned by this method for success cases only. @@ -1985,7 +2051,13 @@ static int user_event_parse(struct user_event_group *group, char *name, INIT_LIST_HEAD(&user->validators); user->group = group; - user->tracepoint.name = name; + user->reg_name = name; + user->reg_flags = reg_flags; + + ret = user_event_set_tp_name(user); + + if (ret) + goto put_user; ret = user_event_parse_fields(user, args); @@ -1999,11 +2071,14 @@ static int user_event_parse(struct user_event_group *group, char *name, user->call.data = user; user->call.class = &user->class; - user->call.name = name; user->call.flags = TRACE_EVENT_FL_TRACEPOINT; user->call.tp = &user->tracepoint; user->call.event.funcs = &user_event_funcs; - user->class.system = group->system_name; + + if (EVENT_MULTI_FORMAT(user->reg_flags)) + user->class.system = group->system_multi_name; + else + user->class.system = group->system_name; user->class.fields_array = user_event_fields_array; user->class.get_fields = user_event_get_fields; @@ -2025,8 +2100,6 @@ static int user_event_parse(struct user_event_group *group, char *name, if (ret) goto put_user_lock; - user->reg_flags = reg_flags; - if (user->reg_flags & USER_EVENT_REG_PERSIST) { /* Ensure we track self ref and caller ref (2) */ refcount_set(&user->refcnt, 2); @@ -2050,6 +2123,11 @@ static int user_event_parse(struct user_event_group *group, char *name, user_event_destroy_fields(user); user_event_destroy_validators(user); kfree(user->call.print_fmt); + + /* Caller frees reg_name on error, but not multi-name */ + if (EVENT_NAME(user) != EVENT_TP_NAME(user)) + kfree(EVENT_TP_NAME(user)); + kfree(user); return ret; } @@ -2639,7 +2717,7 @@ static int user_seq_show(struct seq_file *m, void *p) hash_for_each(group->register_table, i, user, node) { status = user->status; - seq_printf(m, "%s", EVENT_NAME(user)); + seq_printf(m, "%s", EVENT_TP_NAME(user)); if (status != 0) seq_puts(m, " #"); From patchwork Fri Feb 23 14:18:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp613075dyb; Fri, 23 Feb 2024 06:18:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUN95U3ZO/ZV9+bRdJ8PiMKbf0JzrV2auD3y9IA6rpJUqXY0HYc6hdarL/ng8FjdinC0/GcrGMIQzj0S7P6F4SbPflNxQ== X-Google-Smtp-Source: AGHT+IGzfRLOTSMwADXaG7flyfcmpOZpu96X8RB6S89WfExWED1X8q2vVd+EJBByrWFTK6rXAshl X-Received: by 2002:a05:6512:3e23:b0:512:b266:16a1 with SMTP id i35-20020a0565123e2300b00512b26616a1mr1911845lfv.7.1708697885172; Fri, 23 Feb 2024 06:18:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697885; cv=pass; d=google.com; s=arc-20160816; b=G0z372o9VuWImN8TKqidixCtFzuRUqjeZGWzY6uQN+X/yr6IGS6byym9ApvRJ+XMiR 342qXIdyRs7FGtHJIOr7ATG87ljw2lIVvBTRnqkPKN4iuK7Asoe4bJMNevvinsOpY6un fdLUX/9PLT3hphkUfBn+It8yosUge+PWjZXn/kMwfnC8Nhj+G10kTyzGOwTHiWRJ1eEV svHy0DOCyIG14LcBtRwC4NNM2F25bEtH9zlt17MCnEYD/IN/m4AbFqtA5PTNZVJzKOaO mjY9mHchQ/1uoNArkjuz70gP0w6/qdnXyYjstbEtNFL2XNPDXoeZ+4w2UJlqf69Qnox0 +nnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=vnkt7Q1SYPPOt9HYZmOCCtMylLeKGqARY28DR6dGEz8=; fh=sbDUv6PuKPAkpuv6zbp1fPCjJZUEufc8KwKtgDDsdwc=; b=b3/LYmMJdJt//a2QzXQhSPv4TXwxNSPfcT7zBoX53+cUFUijOIuGx3k7p0+9uANt4F lqFd2Bcd8EevAUYhuVe08IikrocCGvTZCNBhRAulcqNyUDBj0OCTOOVV2enIrPOLbNo5 HoTVFuL58itcrwzBJp5xkgz7KgI+xC0H6HYS4Cs40JGLvYJAp8XzKoYBw97dHIjQ7QtM c0JKi4DOXO8Z2Twi/ywIaQq6t6wT8a4No72DtTZGneFzDuAEK23Pm2L0XJgVxbbxbZkI UOKfmkUKtIVyFd1tjHPC0GJii/jzcj5JjFGR9KXGsX+EUVXbkgA1MWBuQz0e/earu3XI IgRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78458-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78458-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g11-20020a056402320b00b00564f0f024e7si2707127eda.76.2024.02.23.06.18.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:18:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78458-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78458-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78458-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C41121F2303C for ; Fri, 23 Feb 2024 14:18:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60ED482C7E; Fri, 23 Feb 2024 14:17:11 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C08780BE4 for ; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; cv=none; b=bgVXDzuq/bn5Vlqv4nhwfe8Z+DhczZDs6jye5TXTfn5spokfLJXAlkTnrvnri4LgLV+xRH0UwTs+ASotOXPec70KT6IR3bm4ZlucCyLOKoCEpxIr3B81CdKpfW8JNn62Qds4/QFBX7PQoWn+Iw9lU8yasKKRYNxuhmH0vf7PIe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; c=relaxed/simple; bh=UDxACU48a6ODn38IN/prkOxVlk0VavU6n+0bJ/Ta2QQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=kI4BenmqArMo4B95MXCsVLymdFQM+J3kNvHwr/2ot8MOh1EG84VnGp/Odo5dzyWCpx1l4+P+6g6J8QnMW7ZTvArhu8JOZfri3n44zhHBqs0FWo5Gxua9mWpVFrtG/b4nEdPFv5Zf1tz78xsWqV56xq7GRnc7lnC1TaS2FMcgEGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CFFDC433B1; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOE-000000077ME-0DHa; Fri, 23 Feb 2024 09:19:02 -0500 Message-ID: <20240223141901.913156672@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:41 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Beau Belgrave Subject: [for-next][PATCH 03/13] selftests/user_events: Test multi-format events References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699593404371563 X-GMAIL-MSGID: 1791699593404371563 From: Beau Belgrave User_events now has multi-format events which allow for the same register name, but with different formats. When this occurs, different tracepoints are created with unique names. Add a new test that ensures the same name can be used for two different formats. Ensure they are isolated from each other and that name and arg matching still works if yet another register comes in with the same format as one of the two. Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-4-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- .../testing/selftests/user_events/abi_test.c | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c index cef1ff1af223..7288a05136ba 100644 --- a/tools/testing/selftests/user_events/abi_test.c +++ b/tools/testing/selftests/user_events/abi_test.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include "../kselftest_harness.h" @@ -23,6 +25,62 @@ const char *data_file = "/sys/kernel/tracing/user_events_data"; const char *enable_file = "/sys/kernel/tracing/events/user_events/__abi_event/enable"; +const char *multi_dir_glob = "/sys/kernel/tracing/events/user_events_multi/__abi_event.*"; + +static int wait_for_delete(char *dir) +{ + struct stat buf; + int i; + + for (i = 0; i < 10000; ++i) { + if (stat(dir, &buf) == -1 && errno == ENOENT) + return 0; + + usleep(1000); + } + + return -1; +} + +static int find_multi_event_dir(char *unique_field, char *out_dir, int dir_len) +{ + char path[256]; + glob_t buf; + int i, ret; + + ret = glob(multi_dir_glob, GLOB_ONLYDIR, NULL, &buf); + + if (ret) + return -1; + + ret = -1; + + for (i = 0; i < buf.gl_pathc; ++i) { + FILE *fp; + + snprintf(path, sizeof(path), "%s/format", buf.gl_pathv[i]); + fp = fopen(path, "r"); + + if (!fp) + continue; + + while (fgets(path, sizeof(path), fp) != NULL) { + if (strstr(path, unique_field)) { + fclose(fp); + /* strscpy is not available, use snprintf */ + snprintf(out_dir, dir_len, "%s", buf.gl_pathv[i]); + ret = 0; + goto out; + } + } + + fclose(fp); + } +out: + globfree(&buf); + + return ret; +} static bool event_exists(void) { @@ -74,6 +132,39 @@ static int event_delete(void) return ret; } +static int reg_enable_multi(void *enable, int size, int bit, int flags, + char *args) +{ + struct user_reg reg = {0}; + char full_args[512] = {0}; + int fd = open(data_file, O_RDWR); + int len; + int ret; + + if (fd < 0) + return -1; + + len = snprintf(full_args, sizeof(full_args), "__abi_event %s", args); + + if (len > sizeof(full_args)) { + ret = -E2BIG; + goto out; + } + + reg.size = sizeof(reg); + reg.name_args = (__u64)full_args; + reg.flags = USER_EVENT_REG_MULTI_FORMAT | flags; + reg.enable_bit = bit; + reg.enable_addr = (__u64)enable; + reg.enable_size = size; + + ret = ioctl(fd, DIAG_IOCSREG, ®); +out: + close(fd); + + return ret; +} + static int reg_enable_flags(void *enable, int size, int bit, int flags) { struct user_reg reg = {0}; @@ -207,6 +298,49 @@ TEST_F(user, bit_sizes) { ASSERT_NE(0, reg_enable(&self->check, 128, 0)); } +TEST_F(user, multi_format) { + char first_dir[256]; + char second_dir[256]; + struct stat buf; + + /* Multiple formats for the same name should work */ + ASSERT_EQ(0, reg_enable_multi(&self->check, sizeof(int), 0, + 0, "u32 multi_first")); + + ASSERT_EQ(0, reg_enable_multi(&self->check, sizeof(int), 1, + 0, "u64 multi_second")); + + /* Same name with same format should also work */ + ASSERT_EQ(0, reg_enable_multi(&self->check, sizeof(int), 2, + 0, "u64 multi_second")); + + ASSERT_EQ(0, find_multi_event_dir("multi_first", + first_dir, sizeof(first_dir))); + + ASSERT_EQ(0, find_multi_event_dir("multi_second", + second_dir, sizeof(second_dir))); + + /* Should not be found in the same dir */ + ASSERT_NE(0, strcmp(first_dir, second_dir)); + + /* First dir should still exist */ + ASSERT_EQ(0, stat(first_dir, &buf)); + + /* Disabling first register should remove first dir */ + ASSERT_EQ(0, reg_disable(&self->check, 0)); + ASSERT_EQ(0, wait_for_delete(first_dir)); + + /* Second dir should still exist */ + ASSERT_EQ(0, stat(second_dir, &buf)); + + /* Disabling second register should remove second dir */ + ASSERT_EQ(0, reg_disable(&self->check, 1)); + /* Ensure bit 1 and 2 are tied together, should not delete yet */ + ASSERT_EQ(0, stat(second_dir, &buf)); + ASSERT_EQ(0, reg_disable(&self->check, 2)); + ASSERT_EQ(0, wait_for_delete(second_dir)); +} + TEST_F(user, forks) { int i; From patchwork Fri Feb 23 14:18:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp612992dyb; Fri, 23 Feb 2024 06:17:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXAw1O6OnbYcELgdrzC4QvaFyOWVd3datKdUkDG3i7py44OcnWKVjqBxTfTC9kzGFtxJtUHFkWl2vUjOuoy1BKS7OpITw== X-Google-Smtp-Source: AGHT+IE8e+N7iWHJwJ3x4yGfkBgEYd+7PTjmdsoVjymSUe6UD3qqObKMg0twpnXBfd1K6mB1q4R+ X-Received: by 2002:a0c:df89:0:b0:68f:5c66:a92f with SMTP id w9-20020a0cdf89000000b0068f5c66a92fmr2157417qvl.45.1708697877188; Fri, 23 Feb 2024 06:17:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697877; cv=pass; d=google.com; s=arc-20160816; b=OSVbdNopmBN/JQ5vHII0b8XJBYRgeqqrV8D/oVPcKaGaDqvZdn5y68uY+gBLYrVduX 2kxSgG80rInLGB/f7fqB+Z6MUcPKtq0OR56scpm8J4OO1WRUVxp/6HVPGqtRJJ2Gqykx ITQuLSwLDqJqG4OZPdlZmP7FZrAahsL2+SJUunqosp/pqKu82KiF3UO4uO8gmqxjiZa1 6V6TnumanXQU1UovQVv4PgE7xH/gBIDbI80qS10p1G5z6mDMcg93cwXScicPOJCbdQ/m dQ8kKItrN7swH3oWmQTvWas+WO+OrD6ytBKsBJdqC+fm3e92Efm6RfU2vf4Sp9438xp4 sm4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=ABIuR4IagH7h0fv6dHHRkvqfSuHoPCi1fKvGZBitVZM=; fh=sbDUv6PuKPAkpuv6zbp1fPCjJZUEufc8KwKtgDDsdwc=; b=Jj029nuLgKWxbIPOSWwmlfV1y9iQu4/M9PEhVklyS13XtVRA9PFdPzwbBFJDlWm2YS sUWiz1MMMKrPKfqzOLRSIA9epUvwZwHzmCD9JtuvUQmFlHn0IGPPY+svnc6L8aIlExpC tfY6njNnIRVbn0WH9dqQyboxpAg59QRWbS82Dz8lZnA53kMB+X8kvQLhDfHOTzF7nChe 2mxDHqmKN20KNttY98iR7dUvd4qjOlUkqspHTNb8VRR4GVpkxXppBwWCBfK319MHNjM0 l84j93Qyajw/JulKc1b5xWfH4Pj09Bats8GS6QYXkEKdvrw2cA7uIwjRttLmWHeWlHap +FFA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78457-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q4-20020ad45ca4000000b0068f72fd2a17si11215457qvh.352.2024.02.23.06.17.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:17:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78457-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F3CD11C2194A for ; Fri, 23 Feb 2024 14:17:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C2388288F; Fri, 23 Feb 2024 14:17:11 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BE2180BE3 for ; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; cv=none; b=OCrSnxER5Aai7PvPmlnHKPeOGoDPkRUs/2dTszJ+WSnz42hjj6FmPn7IY3bs0PI/t4lnwTb8a6NU0WEN4f3t54rbOdngnVWzWZv0F6qNKbwCXVQkf/98Js4x2Ycne3Ihjrc/j15pcbSMOpfRwCHlJFY3QMoATXDtpoAY8q6T8xI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; c=relaxed/simple; bh=nKcWAWVRnB8xYWN/oRCb/6ODPrdVBFq4pB5n9Mp0FBY=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=cZDCSNvcI0DrMUbxldcgcyKfzhULlPsmnTHOxmc0+ccTWnkoiHjw7D0env7jmKAeJjl7lMmr1Op6Z4W6OFoVFqsWFk7g33xJJPXc6VNba1crGedmYA/2FXXBPUEkCFg1PYlxQO20BXPfQQCZ5BzT16vTzT8+MCwRxgGFzf4hys0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B0AEC43390; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOE-000000077Mi-0sLR; Fri, 23 Feb 2024 09:19:02 -0500 Message-ID: <20240223141902.070244243@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:42 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Beau Belgrave Subject: [for-next][PATCH 04/13] tracing/user_events: Document multi-format flag References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699585336697966 X-GMAIL-MSGID: 1791699585336697966 From: Beau Belgrave User programs can now ask user_events to handle the synchronization of multiple different formats for an event with the same name via the new USER_EVENT_REG_MULTI_FORMAT flag. Add a section for USER_EVENT_REG_MULTI_FORMAT that explains the intended purpose and caveats of using it. Explain how deletion works in these cases and how to use /sys/kernel/tracing/dynamic_events for per-version deletion. Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-5-beaub@linux.microsoft.com Signed-off-by: Beau Belgrave Signed-off-by: Steven Rostedt (Google) --- Documentation/trace/user_events.rst | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/trace/user_events.rst b/Documentation/trace/user_events.rst index d8f12442aaa6..1d5a7626e6a6 100644 --- a/Documentation/trace/user_events.rst +++ b/Documentation/trace/user_events.rst @@ -92,6 +92,24 @@ The following flags are currently supported. process closes or unregisters the event. Requires CAP_PERFMON otherwise -EPERM is returned. ++ USER_EVENT_REG_MULTI_FORMAT: The event can contain multiple formats. This + allows programs to prevent themselves from being blocked when their event + format changes and they wish to use the same name. When this flag is used the + tracepoint name will be in the new format of "name.unique_id" vs the older + format of "name". A tracepoint will be created for each unique pair of name + and format. This means if several processes use the same name and format, + they will use the same tracepoint. If yet another process uses the same name, + but a different format than the other processes, it will use a different + tracepoint with a new unique id. Recording programs need to scan tracefs for + the various different formats of the event name they are interested in + recording. The system name of the tracepoint will also use "user_events_multi" + instead of "user_events". This prevents single-format event names conflicting + with any multi-format event names within tracefs. The unique_id is output as + a hex string. Recording programs should ensure the tracepoint name starts with + the event name they registered and has a suffix that starts with . and only + has hex characters. For example to find all versions of the event "test" you + can use the regex "^test\.[0-9a-fA-F]+$". + Upon successful registration the following is set. + write_index: The index to use for this file descriptor that represents this @@ -106,6 +124,9 @@ or perf record -e user_events:[name] when attaching/recording. **NOTE:** The event subsystem name by default is "user_events". Callers should not assume it will always be "user_events". Operators reserve the right in the future to change the subsystem name per-process to accommodate event isolation. +In addition if the USER_EVENT_REG_MULTI_FORMAT flag is used the tracepoint name +will have a unique id appended to it and the system name will be +"user_events_multi" as described above. Command Format ^^^^^^^^^^^^^^ @@ -156,7 +177,11 @@ to request deletes than the one used for registration due to this. to the event. If programs do not want auto-delete, they must use the USER_EVENT_REG_PERSIST flag when registering the event. Once that flag is used the event exists until DIAG_IOCSDEL is invoked. Both register and delete of an -event that persists requires CAP_PERFMON, otherwise -EPERM is returned. +event that persists requires CAP_PERFMON, otherwise -EPERM is returned. When +there are multiple formats of the same event name, all events with the same +name will be attempted to be deleted. If only a specific version is wanted to +be deleted then the /sys/kernel/tracing/dynamic_events file should be used for +that specific format of the event. Unregistering ------------- From patchwork Fri Feb 23 14:18:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp613635dyb; Fri, 23 Feb 2024 06:18:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXX+ywWnvSON0Zq5k/Hmmlt76K9QjMTgfFCfmFHu7Vo28xxen+KZ23xyS704LdQykrBZjp4FbXX46pD1nwdnDk8/EFZ4A== X-Google-Smtp-Source: AGHT+IF2g+5s4CZiDm+qAnfMvKFeGz7nNG3BtOWcmIpFtnfxX2krJK2NXytQJEaDbEBzq2OG8xcE X-Received: by 2002:a05:6808:3193:b0:3c0:3359:484f with SMTP id cd19-20020a056808319300b003c03359484fmr1789414oib.58.1708697939752; Fri, 23 Feb 2024 06:18:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697939; cv=pass; d=google.com; s=arc-20160816; b=NLOwrEc/o7CeQxqdYPey9Kghh7ivO0ZknlH1IMaFbl33+pLwK1CGhUInPs2ZpHPYqA wCjAXcs4Zecb7+kVG13GZJRlpgiksBSDY2XBNHNKV7yV00zf5K8uQYpprdfyc8NABMIg c36fIgjx0d1cOWoR0ozhE/A7E+osu2nk5S9tWspJqsV2gEFLcsOSTn3TLxOfcEy8YB2k 6O4knO4XOg69Prpk4cqwRv6D3dOtU8yhlDDVX/lYNmMRkptJu+CmEuUCGpf0zXwknB4L ALWcQHOG8QarMMtZeiIjHYimsSDy4TWuib3COTlx3UhWfJprsTnUud+RtS0eIfrPZqp1 52mQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=whOwffhxQ/MJF/supPx9sV6VT9akW1+cp7Faa6Cpf5c=; fh=VfvcBXjKW8zST+VJ0hcJl/Sk7tpkGolRrSIsvmnLAzY=; b=WecmudMyFH3EczCzZO4Oy8SZT5lA4Mqb8iLhU+j5Obx1oESyqcjGnLe9FupMpR+XF/ 1qpOKAoGAvIsmdtbcgStPzMsl3KogZ1bfruJOzAF+RlhDf/w4KfNwll5xPqN4Tqfgq8R o4Pt2yOzHygWGpZYG+ff4HDZnMRLnRuybPO8Upq1OR3fSPcSSVvQR5PxBqdtHWzDKvhz mULNQFG5JIC20riwIZeKJQVl587iwNW4jKXmPtgovPqIirO7jEWqtHyXGkcRILtpJXKt 3uk1PL7DkVD5htgzoUC0OvHyX8uh7uW2aRq5mYjypDZK0FzQz4POo7tjUHEm4T8i+JDU HURg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78460-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78460-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gg4-20020a056214252400b0068f71c1fbb6si10696064qvb.473.2024.02.23.06.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:18:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78460-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78460-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78460-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 816EB1C2253B for ; Fri, 23 Feb 2024 14:18:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF8C184FA5; Fri, 23 Feb 2024 14:17:12 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE60C81AAD for ; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; cv=none; b=SXCWr/5YIhaJDgPxC3J8fcVPjgLdgdGR1tNmL+/CrC2ygPXtSbF7yc+h/sXQ/U2vGHVKFb/oRi+VX0QTqqAkGmd/XSKsg37oT5XpLJqaQjvwEsy+Rj/sbPm9uJj4NPByoP2xY6RvaaxjJLDuIvkCEGN90CZWCeGdC+NTxYFuyek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; c=relaxed/simple; bh=9g5M/uPrmYOSZQw75hsZotn5/TImjS5Rj6S+jNoXasQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=oE/LOKi3rX/Z54CZ1Jm201r+ifv1w55+1rEWsYDM2zxv78o+217jXdg5Dsj9+xxf5loHVu4CKDLZq+459F6nGmb2n8mSBeDyXupUbYWYaMtd+kCW8cjsY9zGHbGmCZnTXVR4YaLlZzvOoqQnYQGyFzHJZo4+kP7Oc+uRVp6mzq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7096BC43330; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOE-000000077NC-1ZH5; Fri, 23 Feb 2024 09:19:02 -0500 Message-ID: <20240223141902.230675644@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:43 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , John Garry Subject: [for-next][PATCH 05/13] tracing: Use init_utsname()->release References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699650631022794 X-GMAIL-MSGID: 1791699650631022794 From: John Garry Instead of using UTS_RELEASE, use init_utsname()->release, which means that we don't need to rebuild the code just for the git head commit changing. Link: https://lore.kernel.org/linux-trace-kernel/20240222124639.65629-1-john.g.garry@oracle.com Signed-off-by: John Garry Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8fdd68dbcf6d..f56b3275c676 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -13,7 +13,7 @@ * Copyright (C) 2004 Nadia Yvette Chambers */ #include -#include +#include #include #include #include @@ -4133,7 +4133,7 @@ print_trace_header(struct seq_file *m, struct trace_iterator *iter) get_total_entries(buf, &total, &entries); seq_printf(m, "# %s latency trace v1.1.5 on %s\n", - name, UTS_RELEASE); + name, init_utsname()->release); seq_puts(m, "# -----------------------------------" "---------------------------------\n"); seq_printf(m, "# latency: %lu us, #%lu/%lu, CPU#%d |" From patchwork Fri Feb 23 14:18:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp613901dyb; Fri, 23 Feb 2024 06:19:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUHjjfVSkKDWxrhkU7zIQGjs3MOGeCdUI6PqYkRVYUZpDC2GaYJdHhx5yoaTLCEHeI9qGBnJsGRA5NJYjz7QbOKNiTHyA== X-Google-Smtp-Source: AGHT+IHE4a301xr7QV4nAsC0UgFv3sjMC4POZQv92QUZ5gpOqzAcjUKvl/QVMdm4atXgYzQSPe+c X-Received: by 2002:a05:620a:56d0:b0:787:b801:5d49 with SMTP id wh16-20020a05620a56d000b00787b8015d49mr773971qkn.7.1708697962910; Fri, 23 Feb 2024 06:19:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697962; cv=pass; d=google.com; s=arc-20160816; b=rInOuAYorDeYcJ7jBKTxKeiIRfFElDW6K37EMer1CVTao6r/iKn2k0iGL2Net+XtZl YFi9fGthywiuDgmHUVTf/75bTBCIhaxD9RRsYzGc1qAT7GkNTTAOzbQ+/+VelV/D/cqu eLeViqd/JyY0UhOC7TcXTUpGGzNpSH6ITcXpfaVWkhrKOo1hS9d/O36IP3pYqwwDFXav GLblqiOKMYQu8Cas1ZsIOroXN50ooWpH9xSY7VQMWWJ12rnRMXFB2XE6K4NeWEKINnq8 8X0e9VnC/ub7XbZAeFqEaNbcp0uKNKMWjZ3Fw+QfK8AR6cYxRwbcoiWggv6bkZQRJboh ulcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=z9mrOt9g/Dcnpp8HehJLjeFh63XCsANEIzfIGulHJ7Y=; fh=4aHMAWoenazwtUUz77QSrbSp+uv0ZViBuOAY9m9gWWw=; b=ISB+inVpsMZ246XEpXRnGkLb1s0CEyTMJcruRVTTjt2ZzprScSK/Maj5ihzFZw+b1D 9PDGJUFOf4t4n93Isckp6BOMbK/3LycgOvbEhiYbQ5M7FLbQ87VQBi8cOqoeJb+4zL0w rXssjCXfwPUEXx5Cyt2ozgFqtrLHDWZcVm8zt4lDape0okHmD9LbKpm9XPcWJHfl4Skz jh3mXaZPBCiFXWv04lgkIT8V0jjI3I8w5dU+AhaIrPrTiE+6xj95MBjpe6Hu5qG7AjK8 o28+Yknklm6qqPqIyJlCVEjUA40V065BswkPZ7+CGkKALGVZcdcX1u+9KASVyF2zqVPL NW4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78461-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p26-20020a05620a22ba00b00787843997e3si5698347qkh.209.2024.02.23.06.19.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:19:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78461-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AFB5F1C226E5 for ; Fri, 23 Feb 2024 14:19:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 455B48562C; Fri, 23 Feb 2024 14:17:13 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9A6781ACA for ; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; cv=none; b=LTThyjxGmJlH3zv3ETEALeeVDGhd36XPtVk9PDHSSq79GckRQkN+mpZPsF3GCmvlmXqW2UogN16o7qyHHOqyEqsdFSv+54uyRyA4GJdGRueF+aqMJSF3G2lMOfiTP8woYW15TXEre8cPebOMTZrV6WRTg0HwZsT5Wza1Aw8qaig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; c=relaxed/simple; bh=3xrOW9URhoOAn6cXs/5dE696kcxcVdjb+ohYIPRoMYs=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=VDNtnAgtwBEs3xlawjKTx7cQ3miDTG8I3cQ5eC8EHpKydnfyBsbLNb++QRz8TL6yaZXVTZxF9O8BHzqaksW4fkbQLW6P60yo0Yw2Mx9+y1A1k3yJ8MNo1S6jpj9Ni1Orron/4FOTRrZ6Tc+oc6ibbYE9kZZSUzLdoqsJhasxB7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D546C4166B; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOE-000000077Ng-2Ezo; Fri, 23 Feb 2024 09:19:02 -0500 Message-ID: <20240223141902.394601874@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:44 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Jeff Layton , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Chuck Lever Subject: [for-next][PATCH 06/13] NFSD: Fix nfsd_clid_class use of __string_len() macro References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699675119430555 X-GMAIL-MSGID: 1791699675119430555 From: "Steven Rostedt (Google)" I'm working on restructuring the __string* macros so that it doesn't need to recalculate the string twice. That is, it will save it off when processing __string() and the __assign_str() will not need to do the work again as it currently does. Currently __string_len(item, src, len) doesn't actually use "src", but my changes will require src to be correct as that is where the __assign_str() will get its value from. The event class nfsd_clid_class has: __string_len(name, name, clp->cl_name.len) But the second "name" does not exist and causes my changes to fail to build. That second parameter should be: clp->cl_name.data. Link: https://lore.kernel.org/linux-trace-kernel/20240222122828.3d8d213c@gandalf.local.home Cc: Jeff Layton Cc: Neil Brown Cc: Olga Kornievskaia Cc: Dai Ngo Cc: Tom Talpey Fixes: d27b74a8675ca ("NFSD: Use new __string_len C macros for nfsd_clid_class") Acked-by: Chuck Lever Signed-off-by: Steven Rostedt (Google) Acked-by: Jeff Layton --- fs/nfsd/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index d1e8cf079b0f..2cd57033791f 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -843,7 +843,7 @@ DECLARE_EVENT_CLASS(nfsd_clid_class, __array(unsigned char, addr, sizeof(struct sockaddr_in6)) __field(unsigned long, flavor) __array(unsigned char, verifier, NFS4_VERIFIER_SIZE) - __string_len(name, name, clp->cl_name.len) + __string_len(name, clp->cl_name.data, clp->cl_name.len) ), TP_fast_assign( __entry->cl_boot = clp->cl_clientid.cl_boot; From patchwork Fri Feb 23 14:18:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp613654dyb; Fri, 23 Feb 2024 06:19:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU+DO5Z49GkNh5YTeB6h4uYJxi6BkeQBEdpaGZs7HpRZNLa52Cj6wXFtSGRYQfzT80c1avIN5Es4reqwHq2GuoKJ3xfow== X-Google-Smtp-Source: AGHT+IG/ZgZVfU0y734/Y6hezFfS9uTqNjcAntfAPKF6J8JtGVEUnSbfa1kj5F8pT28YsHkQqUGP X-Received: by 2002:a81:b044:0:b0:607:87cd:9395 with SMTP id x4-20020a81b044000000b0060787cd9395mr2081410ywk.17.1708697941591; Fri, 23 Feb 2024 06:19:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697941; cv=pass; d=google.com; s=arc-20160816; b=ifKoMuRnuTc2m3FJTVVLCG285GNAyezG6xHTvhaFNaYdeG9m5Nisn+8BxI1srKRtc7 ZveFhWlkP+MAm3vqlJX3mvY0BTeP0/XaqsUZGZt0mGt+zeKIKQ28DyeaqOA6LpAX4ZeD LwDK1CGAyuJxCRcpMro5lM55Z3qks2WYk5PfXE6PAmV2EEcWi+TSoOWOZND25du8vfAw N57LVkpI8vq1hxl4pQ0FCacRtgrsBKOREzk6OaiXQKwqFaT112elPF7shGlVwIzajQJD 6Otbgdx1V+L/UY7YOwtbhOLCxpStjoFC5YziFjzkV651jNksPVj7AJP0VJqLXrDhlTGo NRBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=0/5c2cZfKVTnzv0GaqwutBjLS0drmGlD+Ynu1ljkoJQ=; fh=sP+g5SVT877kocLwsgEFtkKYgCNZjYecMHK7EDTYRLg=; b=0T0HuIbt0ToIl+cZriNv/pCOwza3b07T+UzqshH9fNSpFrQ61h9BmXdT1AzmIzD4fw Ls0kYnbQKkI0gKfCm+20Ai1Iq6s9Z0JKKDNcPCL8a0xP/+F5Dxb9kR3KDt3JKyJ5xLml P/8GD3PZM1f7T+cGtbl4DeskoDwdSkuWF99qCH56ptvWfE7wK++h25py9MnKGusPNnmX VsZ0r8w9CCfHf4PYdAJkYluz1GlXD3krX7a3UPTnRMZ+S05RjcxwACrRw0+93tNfnNDo ewyk85WDTrXG1B5DJfRJ4n8o2h8/5dGnTXGt2xrP+dAtaMYBjEvmiYhFzAvKqIlisYAM sipg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78459-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y17-20020a05622a005100b0042e5ad3ee27si2676831qtw.52.2024.02.23.06.19.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:19:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78459-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 611EA1C2212E for ; Fri, 23 Feb 2024 14:19:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C331884FA7; Fri, 23 Feb 2024 14:17:12 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1972811F9 for ; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; cv=none; b=O6ODy7Ix6tYAXKSRbkxoO+8c/4lbYY1sfsXOo6ZyM2+5QeUxUbSzIkuFORLzsA2GNwh0NGNfV6G/hFG7xTF04wIuhIUiao5L8Gah/SYiE8wlb9VYor2S6JWxuJgU54WIOyI2YMYFIriJ1rwCQCSaALluYNWgxB/Tl1s0wyqvtGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697829; c=relaxed/simple; bh=uBv+s4SGLMdbgolqp2QWNEru5imW1UxdLM5GyLNVTUw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Ki2iKe/GKlgOakXDzEzOAqrpicCG8lSMCKffSSThB4ypeJhTz17X+dVXyJHPhhYhNm0f1IuZKLTMFKiOF37MrZcedfClQ8xUVNqiFIjdm4Om/pk9JuJ3fGCAb6sNGZV8X4kE91JQrw2K4w3YNLilXGvhClT5WhIu8wirOr7s57g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D369C43142; Fri, 23 Feb 2024 14:17:09 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOE-000000077OA-2tYX; Fri, 23 Feb 2024 09:19:02 -0500 Message-ID: <20240223141902.554087446@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:45 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Daniel Vetter , David Airlie , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Rodrigo Vivi Subject: [for-next][PATCH 07/13] drm/i915: Add missing ; to __assign_str() macros in tracepoint code References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699652953923824 X-GMAIL-MSGID: 1791699652953923824 From: "Steven Rostedt (Google)" I'm working on improving the __assign_str() and __string() macros to be more efficient, and removed some unneeded semicolons. This triggered a bug in the build as some of the __assign_str() macros in intel_display_trace was missing a terminating semicolon. Link: https://lore.kernel.org/linux-trace-kernel/20240222133057.2af72a19@gandalf.local.home Cc: Daniel Vetter Cc: David Airlie Fixes: 2ceea5d88048b ("drm/i915: Print plane name in fbc tracepoints") Reviewed-by: Ville Syrjälä Acked-by: Rodrigo Vivi Signed-off-by: Steven Rostedt (Google) --- drivers/gpu/drm/i915/display/intel_display_trace.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_trace.h b/drivers/gpu/drm/i915/display/intel_display_trace.h index 99bdb833591c..7862e7cefe02 100644 --- a/drivers/gpu/drm/i915/display/intel_display_trace.h +++ b/drivers/gpu/drm/i915/display/intel_display_trace.h @@ -411,7 +411,7 @@ TRACE_EVENT(intel_fbc_activate, struct intel_crtc *crtc = intel_crtc_for_pipe(to_i915(plane->base.dev), plane->pipe); __assign_str(dev, __dev_name_kms(plane)); - __assign_str(name, plane->base.name) + __assign_str(name, plane->base.name); __entry->pipe = crtc->pipe; __entry->frame = intel_crtc_get_vblank_counter(crtc); __entry->scanline = intel_get_crtc_scanline(crtc); @@ -438,7 +438,7 @@ TRACE_EVENT(intel_fbc_deactivate, struct intel_crtc *crtc = intel_crtc_for_pipe(to_i915(plane->base.dev), plane->pipe); __assign_str(dev, __dev_name_kms(plane)); - __assign_str(name, plane->base.name) + __assign_str(name, plane->base.name); __entry->pipe = crtc->pipe; __entry->frame = intel_crtc_get_vblank_counter(crtc); __entry->scanline = intel_get_crtc_scanline(crtc); @@ -465,7 +465,7 @@ TRACE_EVENT(intel_fbc_nuke, struct intel_crtc *crtc = intel_crtc_for_pipe(to_i915(plane->base.dev), plane->pipe); __assign_str(dev, __dev_name_kms(plane)); - __assign_str(name, plane->base.name) + __assign_str(name, plane->base.name); __entry->pipe = crtc->pipe; __entry->frame = intel_crtc_get_vblank_counter(crtc); __entry->scanline = intel_get_crtc_scanline(crtc); From patchwork Fri Feb 23 14:18:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp614039dyb; Fri, 23 Feb 2024 06:19:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVoMsT0HrIe2J2Snb6C+7zUyXQ8Wx6qjK31+ImUn8IDuAM+ta5Qir5U2MpXufTSOj/RHlgVdToM70z2J8nQCHhkEvoYWQ== X-Google-Smtp-Source: AGHT+IGS3yl70yFTqbQkZFlk3jszVuOxD1JAZo0+GnNqWtLxuZKotjNsPznax5cJbQpppmZpNUI0 X-Received: by 2002:a05:622a:1a05:b0:42e:5da9:37c3 with SMTP id f5-20020a05622a1a0500b0042e5da937c3mr2181051qtb.65.1708697978297; Fri, 23 Feb 2024 06:19:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697978; cv=pass; d=google.com; s=arc-20160816; b=0eQ8KR+09nQba9uJrh3h8yDpiPuzVypu4FYa8CJHXDIUuWWdRLB7GPPsveHpPrI9N2 Cu/9dNhWqkauZ0FM69PSSg/2kOU5xmTWZ4XXtS6aSAFLX64ziIKv8pbqXAz+2X1NqdMN 8vcpiDHutCwBo4R08rRaKiYtNF9sXAqXaWJnHE/Ks+i415dcTXinCB0VPTqWFGmRqPUM V2JEW+uGFSeop8rP3eC41IVh5eEEsq1pSR7OjfekGfLOn1mhLwtiSK7nyry6Km3N87hc Lvnk5YtD940BM+koH72VgT24ye1jIolMeEHgTJsg2oLR3x7DyL8NkPCET/F4ALqxZTS6 ImFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=KF62jqPKUMfmQARCISte8UuKFaty1MYvqqtU0E/nVGY=; fh=b7EyyZDi2buDZAF2B8ag3tZdxj3t/1S4ygn7fEeyjgQ=; b=tV12isLuo29H688Fn9Nu2EQvV/N5g5K1FoRvjlMYsbxzWz75c+4XIkNIgyYuONKwM0 cnmPr5G6j4pSCydMcPxNC84OdmbnFCl09PpQw2s35wkxrGKqjoS2L8f4yu6IeXje8st2 jQbAq0OcvaJ+7bjtcaxzOBip2pk1NgQcbGZ0rLaKqDQiCoJHFYgHLxNciFeFycOn46cP wiWWFTSbTl/nTxYqT6yztS7d7t+nf9g8BspjEtBCo0wBagQTC5MWwKdCd4dx7t9S/eRb KwoQhjmnviGo8T1LTg4OxYugbSc3IWhJUQQ64ptAiPy51bEHzF8nhvMu1cLIqcC7evW/ Fk7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78463-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78463-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ka6-20020a05622a440600b0042c4e4c4f62si14127731qtb.797.2024.02.23.06.19.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:19:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78463-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78463-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78463-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1BD5B1C227FD for ; Fri, 23 Feb 2024 14:19:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A05ED8662E; Fri, 23 Feb 2024 14:17:13 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C2CD823CD for ; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; cv=none; b=fKt284zUtIsGd4ZzCPB4cCv3tZwGy5tkdCVuCCW4pVdisREr55yPCxKVRXO8YnGbuQzSndBPFZHE1bGauIkeaO+X+PJghuSD6nC5VagW2Lk/VjrRWqNoKtGqGHkemjHiHP89HuRZ1C6t1V2a8B0wfENiR4gelGxGTzL+IW1HqQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; c=relaxed/simple; bh=TRTlBeIWlLJicEJm6c+SDXQxnX8BueJpz4S9NWvpEnU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Xp6O3B8SNT3o2JWIkVf3+tFGHIxNCfUELQ9SMsng5iXmBEd9bFFtL+xeAbBFSSpPKZh91FKJkGMiFDrQ8dRSpUf3yJzArkdTvgRnaFs6jiCTGmm3zZTytJOgVYWDp7nzvlyjTuovZ2aJ2gAvxx6qMBWVVr6O4clrLA9/RGl3Fes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 079ADC433C7; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOF-000000077PA-03aA; Fri, 23 Feb 2024 09:19:03 -0500 Message-ID: <20240223141902.873290088@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:47 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Rodrigo Vivi , Chuck Lever Subject: [for-next][PATCH 09/13] tracing: Do not calculate strlen() twice for __string() fields References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699691104932971 X-GMAIL-MSGID: 1791699691104932971 From: "Steven Rostedt (Google)" The TRACE_EVENT() macro handles dynamic strings by having: TP_PROTO(struct some_struct *s), TP_ARGS(s), TP_STRUCT__entry( __string(my_string, s->string) ), TP_fast_assign( __assign_str(my_string, s->string); ) TP_printk("%s", __get_str(my_string)) There's even some code that may call a function helper to find the s->string value. The problem with the above is that the work to get the s->string is done twice. Once at the __string() and again in the __assign_str(). The length of the string is calculated via a strlen(), not once, but twice. Once during the __string() macro and again in __assign_str(). But the length is actually already recorded in the data location and here's no reason to call strlen() again. Just use the saved length that was saved in the __string() code for the __assign_str() code. Link: https://lore.kernel.org/linux-trace-kernel/20240222211442.793074999@goodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Cc: Rodrigo Vivi Cc: Chuck Lever Signed-off-by: Steven Rostedt (Google) --- include/trace/stages/stage6_event_callback.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index b3e2f321e787..c0e5d097324e 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -32,8 +32,9 @@ #undef __assign_str #define __assign_str(dst, src) \ - strcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? \ - __data_offsets.dst##_ptr_ : "(null)") + memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? \ + __data_offsets.dst##_ptr_ : "(null)", \ + __get_dynamic_array_len(dst)) #undef __assign_str_len #define __assign_str_len(dst, src, len) \ @@ -94,8 +95,9 @@ #undef __assign_rel_str #define __assign_rel_str(dst, src) \ - strcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? \ - __data_offsets.dst##_ptr_ : "(null)") + memcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? \ + __data_offsets.dst##_ptr_ : "(null)", \ + __get_rel_dynamic_array_len(dst)) #undef __assign_rel_str_len #define __assign_rel_str_len(dst, src, len) \ From patchwork Fri Feb 23 14:18:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp614024dyb; Fri, 23 Feb 2024 06:19:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUdmCsZrj0p9P+7hvseGa8DnXI90h9iHOfY+SClq10E92GzV2vwmHaet/Vn4sYf8uf8rS9VrcZaK202R0LThxxg403qPQ== X-Google-Smtp-Source: AGHT+IH8WhM3ovRGQsLHo+F/Y3xt2SbcgDjwzf8D0OBv97SoBHHwT7mlpZVKLqRnYVe+nKcZOnwL X-Received: by 2002:a05:6a00:4f89:b0:6e4:8d20:66ed with SMTP id ld9-20020a056a004f8900b006e48d2066edmr8781837pfb.3.1708697977494; Fri, 23 Feb 2024 06:19:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697977; cv=pass; d=google.com; s=arc-20160816; b=djdJcuJrapG8qNhHVHcxv14dU+ryTjhHWKIUyXfD1GvSTUDCajbGo9padLDZSYqha1 eaEGELNoiSxEF9RZrCt2wQgAX+WnRd8tX+mplA17TWqHICWyDoCprZ+DS7+nINTyCVCd +lQI/30FMXyiQso6cFqWc1EItN15nkhKxP+rdlqCEcPts97SS330W+Uev6PbswWzF9LZ lSJCurGO0yXbG7QXp3HyZIP07ytN2Qu1jC2nGTKR54BanvMMaiBHZnGDFtRwDwufwZr4 cEUOUS4sLX98h9Vx5y/6kb8wOZTcY0PCY5adtfW7xH/gR0NyKqcuoz2ohzq6t63Nh2yg YZQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=C5+AGh4zdaJfQhNkAJbgU49ZxT/YAONw70FOvbi6KW4=; fh=5BBsyHlB8a39iZRylNlRwq68Y8N1HTURv9NhE+MQefE=; b=nt7m6jPuRWppeHuQVbuHZExr0PtTYrLmCQqPlXkS3XugYeO9Hh1RjR0Qd7qcCdqrD5 CFlhUu0+g9CTNjE0SUK5Rj9CTLFy5h7MhCkSxtYQHzL+4SpPw6gy3fcX6VwXn10RFDKB kElsiTY65k6Du0YX2Ca7Aur1khfOnr+1BbliqetgbsvAW1iJrMgRXmauzMGUOw50mbD3 SyoA3NAUoDdccpismIgShguB076M+b/mL9r4G27V3BXZOZK+lbFXmE07EQEaSNLoKbAj 6HOvLniV+P8WS45qoa+91wbIkAo0ZkhlYiEk+3shKC4aIMyB1Ur3NlB0jjnxnwo/bN9e r/tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78465-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78465-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a27-20020a630b5b000000b005dc87f9cc80si11801327pgl.553.2024.02.23.06.19.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:19:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78465-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78465-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78465-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4FD18285246 for ; Fri, 23 Feb 2024 14:19:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F6768662D; Fri, 23 Feb 2024 14:17:13 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FC3B823D9 for ; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; cv=none; b=PkyqrRVIRGLfQqMOmEhw8l/8bVL7/PrhzfZ2c7hkUiQuXZbSgMpgy6MAWeuBuw7MwwjtDE7mCtmNWU2VDpoqsXeM6OROOuNQy2thyjdL4p2GAeX40DOSfFqzcQQyBcQzob73/tJfoApaI5/jnMjMyrUCTlzGN37PPwxX20bRuhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; c=relaxed/simple; bh=SSAkBsKZDXS3J7H5zDJ3fM4StROONFq7WOqxGyruuNk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=JlqaSG1tA/xd47yOlaOmX2UFbXGjNm92lgBga0dgbp8WFFNVrSLccWhZfZhaKL38tVJ9efe0YsPgn68Q1HImqUiY7j0X3H7Sz1fYc4VdYtEx+VzZVHqMm1/goLW+yhYUCfgR/4CQGwthXahSBt0AARjPdXXPODzp1jA9xT0c4OI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E06C43142; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOF-000000077Qf-23xN; Fri, 23 Feb 2024 09:19:03 -0500 Message-ID: <20240223141903.347912102@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:50 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort Subject: [for-next][PATCH 12/13] tracing: Fix snapshot counter going between two tracers that use it References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699690757077431 X-GMAIL-MSGID: 1791699690757077431 From: "Steven Rostedt (Google)" Running the ftrace selftests caused the ring buffer mapping test to fail. Investigating, I found that the snapshot counter would be incremented every time a tracer that uses the snapshot is enabled even if the snapshot was used by the previous tracer. That is: # cd /sys/kernel/tracing # echo wakeup_rt > current_tracer # echo wakeup_dl > current_tracer # echo nop > current_tracer would leave the snapshot counter at 1 and not zero. That's because the enabling of wakeup_dl would increment the counter again but the setting the tracer to nop would only decrement it once. Do not arm the snapshot for a tracer if the previous tracer already had it armed. Link: https://lore.kernel.org/linux-trace-kernel/20240223013344.570525723@goodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Vincent Donnefort Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index f56b3275c676..1bcfbc21fb3e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -6148,7 +6148,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf) tracing_disarm_snapshot(tr); } - if (t->use_max_tr) { + if (!had_max_tr && t->use_max_tr) { ret = tracing_arm_snapshot_locked(tr); if (ret) goto out; From patchwork Fri Feb 23 14:18:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp614021dyb; Fri, 23 Feb 2024 06:19:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTD//p3S2AhWhDkkGr3EnEm0lLyAaOMXuF408qwfcqyL6qiD0qCayrkhWa2Ks4rGZ4ge90hUJnthO3OHzNL0Ba6xL2+g== X-Google-Smtp-Source: AGHT+IFPkH/t5fFMmwXA1ciVskRd6zVGVqIy5aUaiVN2+ezZEDSYSm0syNNtjNLLCQjtuqup5mR7 X-Received: by 2002:a17:907:11c5:b0:a3f:899e:d3ac with SMTP id va5-20020a17090711c500b00a3f899ed3acmr1718128ejb.35.1708697976992; Fri, 23 Feb 2024 06:19:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697976; cv=pass; d=google.com; s=arc-20160816; b=NftdQ1fSYmBGi5hxOoAhqIcpETQpIwqLe1QhFzxELEePrVwPlM7QMTznW92k2GZg4k V0iHvd4qUfRgL5ox0K0ckNLUSk/e7xA6SnxcCZ3shF2TbNmJJtfQjWBI0GcHnMS/gxiI gFTIZsDjI4QkX+4gsbPWcln2yM6RLwITpG3T4kD0iBOJLaBUcimW0BNeYjOB+PVpx2VI BK3emgnt+0g1Ng3iw+Z3CmpVsJaslMLJNKlXUM+UgxQSsmFefOTc8aDvWUlX2tKL4PnQ kMWFBGEgp6EyyWIWBGVJZK8bclltuuau5XLte/qWMo4q64IuSIWZzKpLFCRk1xW9VyI+ iJyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=Avh3Zc7WmUFnbevKbWbs7HS2av1/iPL8wft2PicSXI8=; fh=5BBsyHlB8a39iZRylNlRwq68Y8N1HTURv9NhE+MQefE=; b=m+cH9ho9YiuZGZty8rUTGkfjEnT8MV8HX6E4k0+U1rcBm8M8poZ399VgVNtzaxnuhp s5EkymDGnYAprcqthCuCi7vFuHECXGlLP2xKX+4KbeGO8GPLMhBgwBrlNBFCDveawsBc JPhwYUmDZ0oTNZd82XjVNTQWPCJhV0OUjY8CXIcXBW+pAzJogprUMceGQhLaSF6SlG/Y Ier/mfyofJf5BKFJJBWaNlIZBk9ESzB6BMbZbPQlo6JUm9RlL8M8Fyo+eAgdPez+80MO c4V4T/9A02KX6f6r/JSMAv95skZPyI39U7opMpI/VldjSWgJVpbitpJHtiZj91ffTkXS k4vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r8-20020a170906548800b00a3ee04c0addsi3719248ejo.945.2024.02.23.06.19.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:19:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9ADC01F241EA for ; Fri, 23 Feb 2024 14:19:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98FF08662B; Fri, 23 Feb 2024 14:17:13 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB59482868 for ; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; cv=none; b=DJR9dZsa2lDZT1wLEcfyYY4yTjELp0mgF4FUxiZTfCPUWtFRV+ndr9/Uzw+opFa1US3OU5zwGtVsImOcw2imt4vwY+JfsQSa1+V7Ufeq31eNZ/W9g1ZPkiukEAIbHsVN85CJliDANw7I5sVwwIxVgiw2bVWb/P175gZilM80Btg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; c=relaxed/simple; bh=ZgqLTdRoUVgbCvGQljZzqd+I5mUdqZPv5Wp0Z7wOMSk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=j8JK/MMNZsoItuD/rdXWUCWL5FSyKo0hqV9mEgaOXXpfDxRm1cEeDPfhUcesPjXPVeKwKdhyUHwGk/7rj0z5w06p6DWvGEg4ulgwtqldZUKad2MIjWddL07khjvVPPgXHyJi9bW7LcjRl9JQ6DehQ1htYtT+CAQc0cCX6RNAyrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A65B5C43390; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOF-000000077RA-2jRW; Fri, 23 Feb 2024 09:19:03 -0500 Message-ID: <20240223141903.512514224@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:51 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort Subject: [for-next][PATCH 13/13] tracing: Decrement the snapshot if the snapshot trigger fails to register References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699690226442675 X-GMAIL-MSGID: 1791699690226442675 From: "Steven Rostedt (Google)" Running the ftrace selftests caused the ring buffer mapping test to fail. Investigating, I found that the snapshot counter would be incremented every time a snapshot trigger was added, even if that snapshot trigger failed. # cd /sys/kernel/tracing # echo "snapshot" > events/sched/sched_process_fork/trigger # echo "snapshot" > events/sched/sched_process_fork/trigger -bash: echo: write error: File exists That second one that fails increments the snapshot counter but doesn't decrement it. It needs to be decremented when the snapshot fails. Link: https://lore.kernel.org/linux-trace-kernel/20240223013344.729055907@goodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Vincent Donnefort Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_trigger.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index 62e4f58b8671..4bec043c8690 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -1491,7 +1491,10 @@ register_snapshot_trigger(char *glob, if (ret < 0) return ret; - return register_trigger(glob, data, file); + ret = register_trigger(glob, data, file); + if (ret < 0) + tracing_disarm_snapshot(file->tr); + return ret; } static void unregister_snapshot_trigger(char *glob,