mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Chuck Lever <chuck.lever@oracle.com>
Subject: Re: [GIT PULL] tracing: Add __string_len() and __assign_str_len() helpers
Date: Wed, 14 Jul 2021 18:03:37 -0400	[thread overview]
Message-ID: <20210714180337.3e78394c@oasis.local.home> (raw)
In-Reply-To: <20210714175633.3b53346a@oasis.local.home>

On Wed, 14 Jul 2021 17:56:33 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> static inline notrace int trace_event_get_offsets_foo(
> 	struct trace_event_data_offsets_foo *__data_offsets, const char *foobar, int len)
> {
> 	int __data_size = 0;
> 	int __maybe_unused __item_length;
> 	struct trace_event_raw_foo __maybe_unused *entry;
> 
> // The "(len)+1" will be used to calculate the __item_length below
> 
> 	__item_length = (len + 1) * sizeof(char);
> 
> // the dynamic fields (strings and such) are located after the static
> // fields in the trace event, and the offset is recorded in the bottom
> // 16 bits of a 32 bit word, and the size in the top 16 bits.
> 
> 	__data_offsets->item = __data_size +
> 			       offsetof(typeof(*entry), __data);
> 	__data_offsets->item |= __item_length << 16;

I missed a manual substitution of the macro. This should have been:

 	__data_offsets->str = __data_size +
 			       offsetof(typeof(*entry), __data);
 	__data_offsets->str |= __item_length << 16;

As the macro creates the trace_event_data_offsets_foo structure (which
__data_offsets is declared as), which contains a field for every
__string/__string_len/__dynamic_array() in TP_STRUCT__entry.

The -">str" comes from the "str" in "__string_len(str, foobar, len)".

-- Steve


> 	__data_size += __item_length;
> 
> 
> // Each "__string_len()" or "__string()" in the TP_STRUCT__entry is inserted
> // into this macro created function. Thus, the above code is duplicated for
> // each field that uses __string(), __string_len() or __dynamic_array().
> 
> 
> 	return __data_size;
> }


  reply	other threads:[~2021-07-14 22:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 21:11 Steven Rostedt
2021-07-14 19:20 ` Linus Torvalds
2021-07-14 21:56   ` Steven Rostedt
2021-07-14 22:03     ` Steven Rostedt [this message]
2021-07-14 22:13     ` 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=20210714180337.3e78394c@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=torvalds@linux-foundation.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®