From: Chuck Lever <chuck.lever@oracle.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org,
Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jeff Layton <jlayton@kernel.org>
Subject: Re: [for-next][PATCH 2/5] tracing: Remove __assign_str_len()
Date: Mon, 26 Feb 2024 14:15:59 -0500 [thread overview]
Message-ID: <Zdzjb91cJKvgHUMm@manet.1015granger.net> (raw)
In-Reply-To: <20240226184950.974920801@goodmis.org>
On Mon, Feb 26, 2024 at 01:49:34PM -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> 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 <chuck.lever@oracle.com>
> Cc: Jeff Layton <jlayton@kernel.org>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Acked-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> 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:
> --
> 2.43.0
>
>
--
Chuck Lever
next prev parent reply other threads:[~2024-02-26 19:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 18:49 [for-next][PATCH 0/5] tracing: More updates for 6.9 Steven Rostedt
2024-02-26 18:49 ` [for-next][PATCH 1/5] ftrace: Fix most kernel-doc warnings Steven Rostedt
2024-02-26 18:49 ` [for-next][PATCH 2/5] tracing: Remove __assign_str_len() Steven Rostedt
2024-02-26 19:15 ` Chuck Lever [this message]
2024-02-26 18:49 ` [for-next][PATCH 3/5] tracing: Add __string_len() example Steven Rostedt
2024-02-26 18:49 ` [for-next][PATCH 4/5] tracing: Add warning if string in __assign_str() does not match __string() Steven Rostedt
2024-02-26 18:49 ` [for-next][PATCH 5/5] tracing: Remove second parameter to __assign_rel_str() Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zdzjb91cJKvgHUMm@manet.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®