linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever III <chuck.lever@oracle.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	David Wysochanski <dwysocha@redhat.com>,
	Bruce Fields <bfields@fieldses.org>
Subject: Re: [PATCH v2 01/25] NFSD: Fix TP_printk() format specifier in trace_nfsd_dirent()
Date: Mon, 12 Jul 2021 15:18:05 +0000	[thread overview]
Message-ID: <BC78B174-91E3-44C5-8B49-2C5F34BA8823@oracle.com> (raw)
In-Reply-To: <20210513105018.7539996a@gandalf.local.home>

Hello Steven-

> On May 13, 2021, at 10:50 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Wed, 12 May 2021 16:52:05 +0000
> Chuck Lever III <chuck.lever@oracle.com> wrote:
> 
>> The underlying need is to support non-NUL-terminated C strings.
>> 
>> I assumed that since the commentary around 9a6944fee68e claims
>> the proper way to trace C strings is to use __string and friends,
>> and those do not support non-NUL-terminated strings, that such
>> strings are really not first-class citizens. Thus I concluded
>> that my use of '%.*s' was incorrect.
>> 
>> Having some __string-style helpers that can deal with such
>> strings would be valuable.
> 
> I guess the best I can do is a strncpy version, that will add the '\0' in
> the ring buffer. That way we don't need to save the length as well (length
> would need to be at least 4 bytes, where as '\0' is one).
> 
> Something like this?

I don't see this change in v5.14-rc1.


> I added "__string_len()" and "__assign_str_len()". You use them just like
> __string() and __assign_str() but add a max length that you want to use
> (although, it will always allocate "len" regardless if the string is
> smaller). Then use __get_str() just like you use __string().
> 
> Would something like that work?
> 
> -- Steve
> 
> diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
> index 8268bf747d6f..7ab23535a0c8 100644
> --- a/include/trace/trace_events.h
> +++ b/include/trace/trace_events.h
> @@ -102,6 +102,9 @@ TRACE_MAKE_SYSTEM_STR();
> #undef __string
> #define __string(item, src) __dynamic_array(char, item, -1)
> 
> +#undef __string_len
> +#define __string_len(item, src, len) __dynamic_array(char, item, -1)
> +
> #undef __bitmask
> #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1)
> 
> @@ -197,6 +200,9 @@ TRACE_MAKE_SYSTEM_STR();
> #undef __string
> #define __string(item, src) __dynamic_array(char, item, -1)
> 
> +#undef __string_len
> +#define __string_len(item, src, len) __dynamic_array(char, item, -1)
> +
> #undef __bitmask
> #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
> 
> @@ -444,6 +450,9 @@ static struct trace_event_functions trace_event_type_funcs_##call = {	\
> #undef __string
> #define __string(item, src) __dynamic_array(char, item, -1)
> 
> +#undef __string_len
> +#define __string_len(item, src, len) __dynamic_array(char, item, -1)
> +
> #undef __bitmask
> #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
> 
> @@ -492,6 +501,9 @@ static struct trace_event_fields trace_event_fields_##call[] = {	\
> #define __string(item, src) __dynamic_array(char, item,			\
> 		    strlen((src) ? (const char *)(src) : "(null)") + 1)
> 
> +#undef __string_len
> +#define __string_len(item, src, len) __dynamic_array(char, item, (len) + 1)
> +
> /*
>  * __bitmask_size_in_bytes_raw is the number of bytes needed to hold
>  * num_possible_cpus().
> @@ -655,10 +667,18 @@ static inline notrace int trace_event_get_offsets_##call(		\
> #undef __string
> #define __string(item, src) __dynamic_array(char, item, -1)
> 
> +#undef __string_len
> +#define __string_len(item, src, len) __dynamic_array(char, item, -1)
> +
> #undef __assign_str
> #define __assign_str(dst, src)						\
> 	strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)");
> 
> +#undef __assign_str_len
> +#define __assign_str_len(dst, src, len)						\
> +	strncpy(__get_str(dst), (src) ? (const char *)(src) : "(null)", len);	\
> +	__get_str(dst)[len] = '\0';
> +
> #undef __bitmask
> #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
> 
> 
> 

--
Chuck Lever




  parent reply	other threads:[~2021-07-12 15:18 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 15:34 [PATCH v2 00/25] NFSD callback and lease management observability Chuck Lever
2021-05-12 15:35 ` [PATCH v2 01/25] NFSD: Fix TP_printk() format specifier in trace_nfsd_dirent() Chuck Lever
2021-05-12 16:26   ` Steven Rostedt
2021-05-12 16:52     ` Chuck Lever III
2021-05-13 14:50       ` Steven Rostedt
2021-05-13 14:53         ` Chuck Lever III
2021-05-13 15:02           ` Steven Rostedt
2021-05-13 15:10         ` Chuck Lever III
2021-05-13 18:43           ` Chuck Lever III
2021-05-13 19:00             ` Steven Rostedt
2021-05-13 19:08               ` Chuck Lever III
2021-05-13 19:17                 ` Steven Rostedt
2021-05-13 20:01                   ` Chuck Lever III
2021-07-12 15:18         ` Chuck Lever III [this message]
2021-07-12 17:09           ` Steven Rostedt
2021-05-12 16:53     ` Steven Rostedt
2021-05-12 15:35 ` [PATCH v2 02/25] NFSD: Fix TP_printk() format specifier in nfsd_clid_class Chuck Lever
2021-05-12 15:35 ` [PATCH v2 03/25] NFSD: Add nfsd_clid_cred_mismatch tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 04/25] NFSD: Add nfsd_clid_verf_mismatch tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 05/25] NFSD: Remove trace_nfsd_clid_inuse_err Chuck Lever
2021-05-12 15:35 ` [PATCH v2 06/25] NFSD: Add nfsd_clid_confirmed tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 07/25] NFSD: Add nfsd_clid_reclaim_complete tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 08/25] NFSD: Add nfsd_clid_destroyed tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 09/25] NFSD: Add a couple more nfsd_clid_expired call sites Chuck Lever
2021-05-13 16:42   ` David Wysochanski
2021-05-13 17:05     ` Chuck Lever III
2021-05-12 15:36 ` [PATCH v2 10/25] NFSD: Add an RPC authflavor tracepoint display helper Chuck Lever
2021-05-12 15:36 ` [PATCH v2 11/25] NFSD: Add tracepoints for SETCLIENTID edge cases Chuck Lever
2021-05-12 15:36 ` [PATCH v2 12/25] NFSD: Add tracepoints for EXCHANGEID " Chuck Lever
2021-05-12 15:36 ` [PATCH v2 13/25] NFSD: Constify @fh argument of knfsd_fh_hash() Chuck Lever
2021-05-12 15:36 ` [PATCH v2 14/25] NFSD: Capture every CB state transition Chuck Lever
2021-05-12 15:36 ` [PATCH v2 15/25] NFSD: Drop TRACE_DEFINE_ENUM for NFSD4_CB_<state> macros Chuck Lever
2021-05-12 15:36 ` [PATCH v2 16/25] NFSD: Add cb_lost tracepoint Chuck Lever
2021-05-12 15:36 ` [PATCH v2 17/25] NFSD: Adjust cb_shutdown tracepoint Chuck Lever
2021-05-12 15:36 ` [PATCH v2 18/25] NFSD: Remove spurious cb_setup_err tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 19/25] NFSD: Enhance the nfsd_cb_setup tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 20/25] NFSD: Add an nfsd_cb_lm_notify tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 21/25] NFSD: Add an nfsd_cb_offload tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 22/25] NFSD: Replace the nfsd_deleg_break tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 23/25] NFSD: Add an nfsd_cb_probe tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 24/25] NFSD: Remove the nfsd_cb_work and nfsd_cb_done tracepoints Chuck Lever
2021-05-12 15:37 ` [PATCH v2 25/25] NFSD: Update nfsd_cb_args tracepoint Chuck Lever

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=BC78B174-91E3-44C5-8B49-2C5F34BA8823@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=bfields@fieldses.org \
    --cc=dwysocha@redhat.com \
    --cc=linux-nfs@vger.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;
as well as URLs for NNTP newsgroup(s).