linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: Re: linux-next: build failure after merge of the kspp tree
Date: Tue, 25 Jan 2022 14:07:14 -0800	[thread overview]
Message-ID: <202201251402.0FB08DB@keescook> (raw)
In-Reply-To: <20220125162859.2b3cc8a0@gandalf.local.home>

On Tue, Jan 25, 2022 at 04:28:59PM -0500, Steven Rostedt wrote:
> On Tue, 25 Jan 2022 16:23:26 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > > >  #undef __get_rel_dynamic_array
> > > > -#define __get_rel_dynamic_array(field)	\
> > > > -		((void *)(&__entry->__rel_loc_##field) +	\
> > > > -		 sizeof(__entry->__rel_loc_##field) +		\
> > > > +#define __get_rel_dynamic_array(field)					\
> > > > +		((void *)__entry + 					\
> > > > +		 offsetof(typeof(*__entry), __rel_loc_##field) +	\
> > > > +		 sizeof(__entry->__rel_loc_##field) +			\
> > > >  		 (__entry->__rel_loc_##field & 0xffff))
> > > >  
> > > >  #undef __get_rel_dynamic_array_len    
> > > 
> 
> I also do not like the the inconsistency between
> sizeof(__entry->__rel_loc_##field) and sizeof(u32) that is used in the
> calculation part:
> 
> 
> #define __rel_dynamic_array(type, item, len)				\
> 	__item_length = (len) * sizeof(type);				\
> 	__data_offsets->item = __data_size +				\
> 			       offsetof(typeof(*entry), __data) -	\
> 			       offsetof(typeof(*entry), __rel_loc_##item) -	\
> 			       sizeof(u32);				\
> 	__data_offsets->item |= __item_length << 16;			\
> 	__data_size += __item_length;
> 
> Why is one using sizeof(u32) and the other using the size of the field?

It might make more sense to calculate everything as an offset within
__data[] instead of from the start of __entry. The patch I sent just did
in perf.h exactly what Masami did in trace_event.h. That worked. I had
an earlier version that did this horrible thing which could probably be
significantly improved, since I just subtract the offset of __data:

 #undef __get_rel_dynamic_array
 #define __get_rel_dynamic_array(field) \
-		((void *)(&__entry->__rel_loc_##field) +        \
-		 sizeof(__entry->__rel_loc_##field) +           \
-		 (__entry->__rel_loc_##field & 0xffff))
+		((void *)&__entry->__data[			\
+		 offsetof(typeof(*__entry), __rel_loc_##field)	\
+		 + sizeof(__entry->__rel_loc_##field)		\
+		 + (__entry->__rel_loc_##field & 0xffff)	\
+		 - offsetof(typeof(*__entry), __data)		\
+		])

> Just to let you know what is happening. As dynamic elements of the trace
> event needs to be appended at the end of the event, the above macros are
> defined and then run through the TRACE_EVENT() macro, where the
> TP_STRUCT__entry() is parsed to calculate where each item will be for that
> event.
> 
> static inline notrace int trace_event_get_offsets_##call(		\
> 	struct trace_event_data_offsets_##call *__data_offsets, proto)	\
> {									\
> 	int __data_size = 0;						\
> 	int __maybe_unused __item_length;				\
> 	struct trace_event_raw_##call __maybe_unused *entry;		\
> 									\
> 	tstruct;							\
> 									\
> 	return __data_size;						\
> }
> 
> 
> The tstruct is the TP_STRUCT__entry() and for each __rel_dynamic_array() or
> __dynamic_array(), the __data_size gets updated and saved into the
> __data_offsets that holds where each item is.
> 
> The rel versions sets the offset from its location to the data, where as
> the non rel versions sets the offset from the beginning of the event to the
> data.

Could this just be

#define __get_rel_dynamic_array(field) \
	((void *)(&__entry->data[__entry->__rel_loc_##field & 0xffff])

?

-- 
Kees Cook

  reply	other threads:[~2022-01-25 22:07 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25  3:50 linux-next: build failure after merge of the kspp tree Stephen Rothwell
2022-01-25  7:44 ` Kees Cook
2022-01-25 13:27   ` Masami Hiramatsu
2022-01-25 14:01     ` Steven Rostedt
2022-01-25 17:53       ` Kees Cook
2022-01-25 14:31     ` Masami Hiramatsu
2022-01-25 15:49       ` Steven Rostedt
2022-01-25 17:54       ` Kees Cook
2022-01-25 18:41         ` Steven Rostedt
2022-01-25 20:57       ` Kees Cook
2022-01-25 21:23         ` Steven Rostedt
2022-01-25 21:28           ` Steven Rostedt
2022-01-25 22:07             ` Kees Cook [this message]
2022-01-25 22:21               ` Steven Rostedt
2022-01-26  0:35                 ` Masami Hiramatsu
2022-01-26  1:16                   ` Steven Rostedt
2022-01-26  3:18                     ` Kees Cook
2022-01-26  3:26                       ` Steven Rostedt
2022-01-26 19:41                         ` Beau Belgrave
2022-01-26 21:00                           ` Steven Rostedt
2022-01-26  3:52                     ` Masami Hiramatsu
2022-01-26  4:06                       ` Steven Rostedt
2022-01-26  3:17                   ` Kees Cook
2022-01-25 22:01           ` Kees Cook
  -- strict thread matches above, loose matches on Subject: below --
2024-03-05  3:50 Stephen Rothwell
2024-03-05  9:54 ` Kees Cook
2023-09-14  1:50 Stephen Rothwell
2023-09-14  3:07 ` Kees Cook
2023-01-05  2:25 Stephen Rothwell
2023-01-05  3:22 ` Kees Cook
2023-01-05  4:24   ` Stephen Rothwell
2022-12-01  3:07 Stephen Rothwell
2022-12-01 16:31 ` Kees Cook
2022-07-28 10:55 Stephen Rothwell
2022-07-28 15:12 ` Matthias Kaehlcke
2022-05-05  7:40 Stephen Rothwell
2022-05-07 17:18 ` Kees Cook
2022-03-16  7:32 Stephen Rothwell
2022-03-17  1:01 ` Linus Walleij
2022-03-17  8:24   ` Marc Zyngier
2022-03-09 10:10 Stephen Rothwell
2022-03-09 16:52 ` Kees Cook
2022-03-09 16:58   ` Hans de Goede
2022-03-09 17:18     ` Kees Cook
2022-02-28 22:27 Stephen Rothwell
2022-02-28 23:02 ` Kees Cook
2022-03-02  9:16   ` Stephen Rothwell
2022-03-03  7:29     ` Stephen Rothwell
2022-01-30 23:09 Stephen Rothwell
2022-01-31  4:04 ` Kees Cook
2022-01-31  4:59   ` Stephen Rothwell
2022-01-31  6:19     ` Kees Cook
2022-01-31 19:10       ` Saeed Mahameed
2022-01-31 21:06         ` Kees Cook
2022-01-30 22:34 Stephen Rothwell
2022-01-30 23:24 ` Herbert Xu
2022-01-31  0:15   ` Stephen Rothwell
2022-01-31  0:20     ` Herbert Xu
2022-01-31  0:41       ` Stephen Rothwell
2022-01-25  3:24 Stephen Rothwell
2022-01-25  3:43 ` Kees Cook
2022-02-08  4:42   ` Stephen Rothwell
2022-02-08  6:13     ` Kees Cook
2022-01-25  2:55 Stephen Rothwell
2022-01-25  3:02 ` Stephen Rothwell
2022-01-25  3:22   ` Kees Cook
2022-01-25  0:57 Stephen Rothwell
2022-01-25  3:35 ` Kees Cook
2022-01-25 14:07 ` David Sterba
2021-09-16  3:34 Stephen Rothwell
2021-09-16  6:00 ` Kees Cook
2021-08-26  7:52 Stephen Rothwell
2021-08-26 15:38 ` Kees Cook
2020-06-23  3:51 Stephen Rothwell
2020-06-23  3:56 ` David Miller
2020-06-21 13:48 Stephen Rothwell
2020-06-21 15:36 ` Kees Cook
2018-07-27  9:02 Stephen Rothwell
2018-07-27  9:06 ` Stephen Rothwell
2018-07-27 10:55   ` Stephen Rothwell
2018-07-27 12:55     ` Will Deacon
2018-07-27 13:01       ` Will Deacon
2018-07-27 13:27         ` Will Deacon
2018-07-27 16:00           ` Kees Cook
2018-07-30  7:33       ` Stephen Rothwell
2018-07-30 14:47         ` Laura Abbott
2018-07-30 16:37           ` Will Deacon
2018-07-31 10:09         ` Will Deacon
2018-07-31 11:27           ` Stephen Rothwell
2017-11-08  5:23 Stephen Rothwell
2017-11-08 23:43 ` Kees Cook
2017-11-09  0:18   ` Darrick J. Wong
2017-11-09  0:31     ` Kees Cook
2017-06-20  4:56 Stephen Rothwell
2017-06-20  5:39 ` Kees Cook
2017-06-20  5:42   ` John Johansen
2017-06-20  5:39 ` John Johansen
2017-06-26 18:19   ` Kees Cook
2017-06-27  3:33     ` James Morris
2017-06-27 22:16       ` Kees Cook
2017-06-28  5:48         ` James Morris
2017-06-16  1:30 Stephen Rothwell
2017-06-16  2:51 ` Daniel Micay
2017-06-16  2:52   ` Daniel Micay
2017-06-16  3:20   ` Kees Cook
2017-06-16  3:31     ` Stephen Rothwell
2017-06-19  0:23       ` Stephen Rothwell
2017-06-19 21:01         ` Kees Cook

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=202201251402.0FB08DB@keescook \
    --to=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sfr@canb.auug.org.au \
    /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).