From patchwork Fri Feb 23 20:28:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp827294dyb; Fri, 23 Feb 2024 12:27:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXZzPE8XK07GmQ0kizgyYjhXogR1gN1pRNODVXDrAaim4v8rRF3zasSB/2xB2eVSp8z3IcDjfPhKUEK9ITcq1B4qa5N+Q== X-Google-Smtp-Source: AGHT+IGd0WEpBvEENLbwnFoc9fsY2h85O5LCQQfxRsXiEQIcMrareXrxV8pLb8imxLWu6VYt8F5m X-Received: by 2002:a17:906:4a19:b0:a3f:d743:1b with SMTP id w25-20020a1709064a1900b00a3fd743001bmr510105eju.70.1708720029612; Fri, 23 Feb 2024 12:27:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708720029; cv=pass; d=google.com; s=arc-20160816; b=vHxwuoarVRQsXrL6N9lGzWcbWLWbxFG7jVAQJwWT0JTarF0M4WKmB4uZez8JW2ms3i DHfAzljYEHQEbexpXtHXwPtyv5ouw9+wWqcqM8b/5NujGnl2iKMQm0A/FhwRM7lKWtNd HnPjSK8vLRbmfol19lwlSQMBrRMOIWlOrtDKczjoqqNaJtjTPvl9pC/Sl594aeVkDzrv yRqG9zv7CK1dcpgixps0UyC6ZxALdF+fgOeHRVK116SPzSBTSnSHL0hOt3hgaYeS/QJh +QHtER3g6Ioz5Hr7sciPhILpOtgVVRDfmGRMfZhtJLQnclk6ILshbMQXdjkco14eAZdL ZqkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date; bh=oM5I+VDIfTfIGOqDPg0lqvRoGMFxiceRGYnTrbfAmw8=; fh=a/W6vY+bgZ8N83j3/Fv0S1qn1lyMv2u/UPVp2x/5R8s=; b=DL4adSN6pitrnUrgVUAkfB262yYN16ahU+v8KyASjdYy/IxkwosPmYhxxr+yxe+dDW HLcKaYWKey4vM+IqCblbwRQGmv5WM2Rs9P+OlC276DblernQcQGGSAB0GjBYUhQEkXKd cNzWgoTcGZT7lLAVBCbHEQHXOqxqS2fSOzohmR6XVImJLeBgpRT4VLWZpTFTObhwAbYD 305IDE0ju//UiYpf+uKz8ryQ+3zCVDTNtGdXAwJR8WwUWPCL9TIN7Rycq1qfxiYFuorF 3zwE4aJgaopSWE3N4Rm/VLirCXpUYn7ofwIuoh8ON5ZgymhYC24pW6e3ascN66MfCS06 tPnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-79103-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79103-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 kz15-20020a17090777cf00b00a3e7eb19a24si5005241ejc.103.2024.02.23.12.27.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:27:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79103-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-79103-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79103-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 3CFE31F21831 for ; Fri, 23 Feb 2024 20:27:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45E3E149388; Fri, 23 Feb 2024 20:26:37 +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 C2E5B146E96; Fri, 23 Feb 2024 20:26:35 +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=1708719995; cv=none; b=j0aX18qISt5sZdjy0G/QPxkmycampUByT3Rn81k807jAQYeVARywstS4aRpzKujX0Qr8D53j9EdVRtiUJ6jp03lGhl2Smrl3jGfRpgJdgFqjr65JxKPKbgYH0HH5kxUgrkpLjHS0lQvptlSMwoU2OWG2zM+0hVlVOM96TRBtU30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708719995; c=relaxed/simple; bh=BKjk2drUibhKGcus9h79n6m+U1rXszg3UpQTrvBjVCA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=J3bE/IUfKkFC9fyGzFlAYRFs3lE/0Z1LPdI35lhZMt558vRFqnnENp0rEOnFEqmiCICkQRMK9hF8H6BTJnDdygrSsRIyCeQzkPfOOKUSkko/BLDc38IxwnIeKw4pQP2+ThvtTgmhEc7p5iE2CtSIj43jN+tnDlSqbRlRhma6URw= 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 ADCBFC43399; Fri, 23 Feb 2024 20:26:34 +0000 (UTC) Date: Fri, 23 Feb 2024 15:28:27 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mathieu Desnoyers Subject: [PATCH] tracing: Add __string_len() example Message-ID: <20240223152827.5f9f78e2@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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: 1791722813498306859 X-GMAIL-MSGID: 1791722813498306859 From: "Steven Rostedt (Google)" There's no example code that uses __string_len(), and since the sample code is used for testing the event logic, add a use case. Signed-off-by: Steven Rostedt (Google) --- samples/trace_events/trace-events-sample.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index f2d2d56ce8e2..2dfaf7fc7bfa 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -303,6 +303,7 @@ TRACE_EVENT(foo_bar, __bitmask( cpus, num_possible_cpus() ) __cpumask( cpum ) __vstring( vstr, fmt, va ) + __string_len( lstr, foo, bar / 2 < strlen(foo) ? bar / 2 : strlen(foo) ) ), TP_fast_assign( @@ -311,12 +312,13 @@ TRACE_EVENT(foo_bar, memcpy(__get_dynamic_array(list), lst, __length_of(lst) * sizeof(int)); __assign_str(str, string); + __assign_str(lstr, foo); __assign_vstr(vstr, fmt, va); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); __assign_cpumask(cpum, cpumask_bits(mask)); ), - TP_printk("foo %s %d %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar, /* * Notice here the use of some helper functions. This includes: @@ -360,7 +362,8 @@ TRACE_EVENT(foo_bar, __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list) / sizeof(int), sizeof(int)), - __get_str(str), __get_bitmask(cpus), __get_cpumask(cpum), + __get_str(str), __get_str(lstr), + __get_bitmask(cpus), __get_cpumask(cpum), __get_str(vstr)) );