From patchwork Mon Feb 26 18:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 206853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2268056dyb; Mon, 26 Feb 2024 10:48:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWIannEfOoBcsRxwC4HM6f5q5EMJTSjgPkTdK+wWWCIxP7HbfzATG0dGK7C1v/ReQ51N9r0ZtflKsFGDsZEoaVhj7zISg== X-Google-Smtp-Source: AGHT+IFbU1JFur9QK2W5q8ZWX+P5WhfMEtt4NxWP+761LA3p/VDKtMxDHPyYAbSD0i3ZnQdmxVsD X-Received: by 2002:a05:6512:1053:b0:512:bf09:624a with SMTP id c19-20020a056512105300b00512bf09624amr5363287lfb.66.1708973327710; Mon, 26 Feb 2024 10:48:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708973327; cv=pass; d=google.com; s=arc-20160816; b=SW/jb9v5G9znUxrKDLotm5+pWfMVgwPUQodOqcACQB/2Ak5L/gkJ2rguwy15s9FGGR Rut39XryBW6MnInaXGQzNHrdU3R9oqNUPIWgnpBqe0ko2x3f2nS8Yl3V7SxOY9s9SLao u/9xKkkZuJYJtH7sP8bMMAAt8HlwL02FR7hnUwHDizKYrj3s4pamS1ZywW6UEGviLRHr NmOqHGqm7lBMF+jt9vgj6moOJd6+FQy+w7AMAb8BU2yedL7mSQLLG8ikJIZnN6v/HENR SsD1ese2TmcRHa/grrxnGAKxKuY2gQ4R4/2LW0obp1VKapCarmlP4WieFlkb1u55QGsj TbHA== 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=Hzp0kBe6NOcOkwO2q9cYUCT941BNrt3/XdZsc3KZZxw=; fh=YJNbiTDh1bXPtSAuYY4pcZdHhYfKKcW8mPN0yeq1P+4=; b=PG73DDFQ1SGH2SiYN4/Wk7q/ADMGyleFOC1BrDUcgOotg7ZI1sy+/6pY9yQgtuQ2ai RaaC4lFN2Kf+VCzJA09cAwI08hvk32mmd+kL9+8fxDF434atSikALMQ2EefAOcd9QEQC 3A3zM8NuWotaLSNefxp4yjXUIA05K3c8LO+evfCHYlMalz7gRLpA1yVgmK/nfSSLZERy 7tRG9cnKNhY6hDOiF19nCS0K9S+pUWffE6+FRzTT0KkFONLNYlx0YhIGhP7pV5d59Fu2 7BJF5/9JbDEFeyPFA/SQnWzME1h4xLtBvkX93bvmDOYoJb595uP1Q44Rx9zcbiqrWhzA Z4Aw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-82155-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82155-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 l12-20020a170906230c00b00a3e40f8ea26si16032eja.18.2024.02.26.10.48.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 10:48:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82155-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-82155-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82155-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 5100E1F2A468 for ; Mon, 26 Feb 2024 18:48:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9E52130AF0; Mon, 26 Feb 2024 18:47:52 +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 09BD912B165 for ; Mon, 26 Feb 2024 18:47:50 +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=1708973271; cv=none; b=Zlz+hg74/zh1tLb0BEhTDIZS30uR7AUGNM0SfHtBfW6xqP657+G78wCO26gMFoPzF8H4oWljdZgWO2Uf3eNRHzcx9pOWjhATQbJytuaLw6BuLEilN2WghDPcJjUhBerrRbeu2sP95Kkx9FxgvLMQRPP50OwCDeBo2aa49+WkiRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708973271; c=relaxed/simple; bh=FIsqY0GYMu8i4l2YcwaXi7PM31Nn7I2D2TKH/biGcbg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=QCegnIdXF4tevpx3I1+X35kcGwrShp+hGnuIXrTp4o7dPHbbESkY2ch/D7w+LAOTPFT/IOtNbS6zscOO2as0VCY2Gk6q0T/WM97bLdr37uIHvOJBn75/aIrpX1sk4Fjghik9l/f7+BR9cCEMvLWp0GrEf9f1ezOGEinIEka/jSc= 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 B750FC43399; Mon, 26 Feb 2024 18:47:50 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1reg2x-000000090Zx-0UhY; Mon, 26 Feb 2024 13:49:51 -0500 Message-ID: <20240226184950.974920801@goodmis.org> User-Agent: quilt/0.67 Date: Mon, 26 Feb 2024 13:49:34 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Chuck Lever , Jeff Layton Subject: [for-next][PATCH 2/5] tracing: Remove __assign_str_len() References: <20240226184932.303400070@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: 1791988415883046013 X-GMAIL-MSGID: 1791988415883046013 From: "Steven Rostedt (Google)" Now that __assign_str() gets the length from the __string() (and __string_len()) macros, there's no reason to have a separate __assign_str_len() macro as __assign_str() can get the length of the string needed. Also remove __assign_rel_str() although it had no users anyway. Link: https://lore.kernel.org/linux-trace-kernel/20240223152206.0b650659@gandalf.local.home Cc: Chuck Lever Cc: Jeff Layton Signed-off-by: Steven Rostedt (Google) Acked-by: Chuck Lever --- fs/nfsd/trace.h | 8 +++--- include/trace/stages/stage6_event_callback.h | 28 ++++++++------------ samples/trace_events/trace-events-sample.h | 9 ++++--- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 2cd57033791f..98b14f30d772 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -102,7 +102,7 @@ TRACE_EVENT(nfsd_compound, TP_fast_assign( __entry->xid = be32_to_cpu(rqst->rq_xid); __entry->opcnt = opcnt; - __assign_str_len(tag, tag, taglen); + __assign_str(tag, tag); ), TP_printk("xid=0x%08x opcnt=%u tag=%s", __entry->xid, __entry->opcnt, __get_str(tag) @@ -483,7 +483,7 @@ TRACE_EVENT(nfsd_dirent, TP_fast_assign( __entry->fh_hash = fhp ? knfsd_fh_hash(&fhp->fh_handle) : 0; __entry->ino = ino; - __assign_str_len(name, name, namlen) + __assign_str(name, name); ), TP_printk("fh_hash=0x%08x ino=%llu name=%s", __entry->fh_hash, __entry->ino, __get_str(name) @@ -853,7 +853,7 @@ DECLARE_EVENT_CLASS(nfsd_clid_class, __entry->flavor = clp->cl_cred.cr_flavor; memcpy(__entry->verifier, (void *)&clp->cl_verifier, NFS4_VERIFIER_SIZE); - __assign_str_len(name, clp->cl_name.data, clp->cl_name.len); + __assign_str(name, clp->cl_name.data); ), TP_printk("addr=%pISpc name='%s' verifier=0x%s flavor=%s client=%08x:%08x", __entry->addr, __get_str(name), @@ -1800,7 +1800,7 @@ TRACE_EVENT(nfsd_ctl_time, TP_fast_assign( __entry->netns_ino = net->ns.inum; __entry->time = time; - __assign_str_len(name, name, namelen); + __assign_str(name, name); ), TP_printk("file=%s time=%d\n", __get_str(name), __entry->time diff --git a/include/trace/stages/stage6_event_callback.h b/include/trace/stages/stage6_event_callback.h index 2bfd49713b42..0c0f50bcdc56 100644 --- a/include/trace/stages/stage6_event_callback.h +++ b/include/trace/stages/stage6_event_callback.h @@ -32,16 +32,13 @@ #undef __assign_str #define __assign_str(dst, src) \ - memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? : EVENT_NULL_STR, \ - __get_dynamic_array_len(dst)) - -#undef __assign_str_len -#define __assign_str_len(dst, src, len) \ do { \ - memcpy(__get_str(dst), \ - __data_offsets.dst##_ptr_ ? : EVENT_NULL_STR, len); \ - __get_str(dst)[len] = '\0'; \ - } while(0) + char *__str__ = __get_str(dst); \ + int __len__ = __get_dynamic_array_len(dst) - 1; \ + memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ + EVENT_NULL_STR, __len__); \ + __str__[__len__] = '\0'; \ + } while (0) #undef __assign_vstr #define __assign_vstr(dst, fmt, va) \ @@ -94,15 +91,12 @@ #undef __assign_rel_str #define __assign_rel_str(dst, src) \ - memcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? : EVENT_NULL_STR, \ - __get_rel_dynamic_array_len(dst)) - -#undef __assign_rel_str_len -#define __assign_rel_str_len(dst, src, len) \ do { \ - memcpy(__get_rel_str(dst), \ - __data_offsets.dst##_ptr_ ? : EVENT_NULL_STR, len); \ - __get_rel_str(dst)[len] = '\0'; \ + char *__str__ = __get_rel_str(dst); \ + int __len__ = __get_rel_dynamic_array_len(dst) - 1; \ + memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ + EVENT_NULL_STR, __len__); \ + __str__[__len__] = '\0'; \ } while (0) #undef __rel_bitmask diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 23f923ccd529..f2d2d56ce8e2 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -163,8 +163,7 @@ * __string(). * * __string_len: This is a helper to a __dynamic_array, but it understands - * that the array has characters in it, and with the combined - * use of __assign_str_len(), it will allocate 'len' + 1 bytes + * that the array has characters in it, it will allocate 'len' + 1 bytes * in the ring buffer and add a '\0' to the string. This is * useful if the string being saved has no terminating '\0' byte. * It requires that the length of the string is known as it acts @@ -174,9 +173,11 @@ * * __string_len(foo, bar, len) * - * To assign this string, use the helper macro __assign_str_len(). + * To assign this string, use the helper macro __assign_str(). + * The length is saved via the __string_len() and is retrieved in + * __assign_str(). * - * __assign_str_len(foo, bar, len); + * __assign_str(foo, bar); * * Then len + 1 is allocated to the ring buffer, and a nul terminating * byte is added. This is similar to: