Skip to contentSkip to conversation

linux-next: manual merge of the ftrace tree with the nfsd tree

PATCH Stephen Rothwell 3 participants 6 messages Mar 15, 2022 – Mar 16, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

Today's linux-next merge of the ftrace tree got a conflict in:

include/trace/trace_events.h

between commit:

d07c9ad62247 ("tracing: Introduce helpers to safely handle dynamic-sized sockaddrs")

from the nfsd tree and commit:

af6b9668e85f ("tracing: Move the defines to create TRACE_EVENTS into their own files")

from the ftrace tree.

Well, this is a pain :-(

I fixed it up (I used the latter version of this file and then added the following merge fix patch) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

From: Stephen Rothwell <[email protected]>
Date: Tue, 15 Mar 2022 14:47:18 +1100
Subject: [PATCH] fix up for "tracing: Move the defines to create TRACE_EVENTS into their own files"

---
 include/trace/stages/stage1_defines.h |  6 ++++++
 include/trace/stages/stage2_defines.h | 10 ++++++++--
 include/trace/stages/stage3_defines.h |  6 ++++++
 include/trace/stages/stage4_defines.h |  6 ++++++
 include/trace/stages/stage5_defines.h |  6 ++++++
 include/trace/stages/stage6_defines.h | 18 ++++++++++++++++++
 include/trace/stages/stage7_defines.h |  2 ++
 7 files changed, 52 insertions(+), 2 deletions(-)
include/trace/stages/stage1_defines.h +6 -0
index 8ab88c766d2b..a16783419687 100644
@@ -29,6 +29,9 @@
 #undef __bitmask
 #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1)
 
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
+
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(type, item, len) u32 __rel_loc_##item;
 
@@ -41,5 +44,8 @@
 #undef __rel_bitmask
 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1)
 
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
+
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...) args
include/trace/stages/stage2_defines.h +8 -2
index 9f2341df40da..42fd1e8813ec 100644
@@ -29,11 +29,14 @@
 #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)
 
-#undef __string_len
-#define __string_len(item, src, len) __dynamic_array(char, item, -1)
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
 
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(type, item, len)	u32 item;
@@ -46,3 +49,6 @@
 
 #undef __rel_bitmask
 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
+
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
include/trace/stages/stage3_defines.h +6 -0
index 0bc131993b7a..e3b183e9d18e 100644
@@ -51,6 +51,12 @@
 		trace_print_bitmask_seq(p, __bitmask, __bitmask_size);	\
 	})
 
+#undef __get_sockaddr
+#define __get_sockaddr(field)	((struct sockaddr *)__get_dynamic_array(field))
+
+#undef __get_rel_sockaddr
+#define __get_rel_sockaddr(field)	((struct sockaddr *)__get_rel_dynamic_array(field))
+
 #undef __print_flags
 #define __print_flags(flag, delim, flag_array...)			\
 	({								\
include/trace/stages/stage4_defines.h +6 -0
index 780a10fa5279..e80cdc397a43 100644
@@ -41,6 +41,9 @@
 #undef __bitmask
 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
 
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
+
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(_type, _item, _len) {			\
 	.type = "__rel_loc " #_type "[]", .name = #_item,		\
@@ -55,3 +58,6 @@
 
 #undef __rel_bitmask
 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
+
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
include/trace/stages/stage5_defines.h +6 -0
index fb15394aae31..7ee5931300e6 100644
@@ -81,3 +81,9 @@
 #undef __rel_bitmask
 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item,	\
 					 __bitmask_size_in_longs(nr_bits))
+
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
+
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
include/trace/stages/stage6_defines.h +18 -0
index b3a1f26026be..2ac88e1a7677 100644
@@ -45,6 +45,15 @@
 #define __assign_bitmask(dst, src, nr_bits)					\
 	memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
 
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
+
+#undef __get_sockaddr
+#define __get_sockaddr(field)	((struct sockaddr *)__get_dynamic_array(field))
+
+#define __assign_sockaddr(dest, src, len)					\
+	memcpy(__get_dynamic_array(dest), src, len)
+
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(type, item, len)				\
 	__entry->__rel_loc_##item = __data_offsets.item;
@@ -76,6 +85,15 @@
 #define __assign_rel_bitmask(dst, src, nr_bits)					\
 	memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
 
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
+
+#undef __get_rel_sockaddr
+#define __get_rel_sockaddr(field)	((struct sockaddr *)__get_rel_dynamic_array(field))
+
+#define __assign_rel_sockaddr(dest, src, len)					\
+	memcpy(__get_rel_dynamic_array(dest), src, len)
+
 #undef TP_fast_assign
 #define TP_fast_assign(args...) args
 
include/trace/stages/stage7_defines.h +2 -0
index d65445328f18..8a7ec24c246d 100644
@@ -13,10 +13,12 @@
 #undef __get_dynamic_array_len
 #undef __get_str
 #undef __get_bitmask
+#undef __get_sockaddr
 #undef __get_rel_dynamic_array
 #undef __get_rel_dynamic_array_len
 #undef __get_rel_str
 #undef __get_rel_bitmask
+#undef __get_rel_sockaddr
 #undef __print_array
 #undef __print_hex_dump
 
Signature · 40 lines
2.34.1

However, my x86_64 allmodconfig build then failed like this:

In file included from include/trace/define_custom_trace.h:55,
                 from samples/trace_events/trace_custom_sched.h:95,
                 from samples/trace_events/trace_custom_sched.c:24:
samples/trace_events/./trace_custom_sched.h: In function 'ftrace_test_custom_probe_sched_switch':
include/trace/trace_custom_events.h:178:42: error: passing argument 1 of 'check_trace_callback_type_sched_switch' from incompatible pointer type [-Werror=incompatible-pointer-types]
  178 |         check_trace_callback_type_##call(trace_custom_event_raw_event_##template); \
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                          |
      |                                          void (*)(void *, bool,  struct task_struct *, struct task_struct *) {aka void (*)(void *, _Bool,  struct task_struct *, struct task_struct *)}
include/trace/trace_custom_events.h:34:9: note: in expansion of macro 'DEFINE_CUSTOM_EVENT'
   34 |         DEFINE_CUSTOM_EVENT(name, name, PARAMS(proto), PARAMS(args));
      |         ^~~~~~~~~~~~~~~~~~~
samples/trace_events/./trace_custom_sched.h:21:1: note: in expansion of macro 'TRACE_CUSTOM_EVENT'
   21 | TRACE_CUSTOM_EVENT(sched_switch,
      | ^~~~~~~~~~~~~~~~~~
In file included from include/linux/trace_events.h:11,
                 from samples/trace_events/trace_custom_sched.c:10:
include/linux/tracepoint.h:279:49: note: expected 'void (*)(void *, bool,  unsigned int,  struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool,  unsigned int,  struct task_struct *, struct task_struct *)'} but argument is of type 'void (*)(void *, bool,  struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool,  struct task_struct *, struct task_struct *)'}
  279 |         check_trace_callback_type_##name(void (*cb)(data_proto))        \
      |                                          ~~~~~~~^~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
  419 |         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
      |         ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
  553 |         DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
      |         ^~~~~~~~~~~~~
include/trace/events/sched.h:222:1: note: in expansion of macro 'TRACE_EVENT'
  222 | TRACE_EVENT(sched_switch,
      | ^~~~~~~~~~~

So I gave up and uses the ftrace tree from next-20220310 for today.

I am going to need some help with this mess, please.
-- 
Cheers,
Stephen Rothwell
#1 lore raw
Quoted 14 lines · Stephen Rothwell

Hi all,

Today's linux-next merge of the ftrace tree got a conflict in:

include/trace/trace_events.h

between commit:

d07c9ad62247 ("tracing: Introduce helpers to safely handle dynamic-sized sockaddrs")

Quoted 7 lines

from the nfsd tree and commit:

af6b9668e85f ("tracing: Move the defines to create TRACE_EVENTS into their own files")

from the ftrace tree.

Well, this is a pain :-(

Apologies. Steven, can you take the sockaddr patches in your tree and resolve the x86_64 build issue?

Quoted 220 lines

I fixed it up (I used the latter version of this file and then added the following merge fix patch) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

From: Stephen Rothwell <[email protected]>
Date: Tue, 15 Mar 2022 14:47:18 +1100
Subject: [PATCH] fix up for "tracing: Move the defines to create TRACE_EVENTS into their own files"

---

include/trace/stages/stage1_defines.h |  6 ++++++
include/trace/stages/stage2_defines.h | 10 ++++++++--
include/trace/stages/stage3_defines.h |  6 ++++++
include/trace/stages/stage4_defines.h |  6 ++++++
include/trace/stages/stage5_defines.h |  6 ++++++
include/trace/stages/stage6_defines.h | 18 ++++++++++++++++++
include/trace/stages/stage7_defines.h |  2 ++
7 files changed, 52 insertions(+), 2 deletions(-)
include/trace/stages/stage1_defines.h +6 -0
index 8ab88c766d2b..a16783419687 100644
@@ -29,6 +29,9 @@
 #undef __bitmask
 #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1)
 
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
+
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(type, item, len) u32 __rel_loc_##item;
 
@@ -41,5 +44,8 @@
 #undef __rel_bitmask
 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(char, item, -1)
 
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
+
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...) args
include/trace/stages/stage2_defines.h +8 -2
index 9f2341df40da..42fd1e8813ec 100644
@@ -29,11 +29,14 @@
 #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)
 
-#undef __string_len
-#define __string_len(item, src, len) __dynamic_array(char, item, -1)
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
 
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(type, item, len)	u32 item;
@@ -46,3 +49,6 @@
 
 #undef __rel_bitmask
 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
+
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
include/trace/stages/stage3_defines.h +6 -0
index 0bc131993b7a..e3b183e9d18e 100644
@@ -51,6 +51,12 @@
 		trace_print_bitmask_seq(p, __bitmask, __bitmask_size);	\
 	})
 
+#undef __get_sockaddr
+#define __get_sockaddr(field)	((struct sockaddr *)__get_dynamic_array(field))
+
+#undef __get_rel_sockaddr
+#define __get_rel_sockaddr(field)	((struct sockaddr *)__get_rel_dynamic_array(field))
+
 #undef __print_flags
 #define __print_flags(flag, delim, flag_array...)			\
 	({								\
include/trace/stages/stage4_defines.h +6 -0
index 780a10fa5279..e80cdc397a43 100644
@@ -41,6 +41,9 @@
 #undef __bitmask
 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
 
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
+
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(_type, _item, _len) {			\
 	.type = "__rel_loc " #_type "[]", .name = #_item,		\
@@ -55,3 +58,6 @@
 
 #undef __rel_bitmask
 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1)
+
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
include/trace/stages/stage5_defines.h +6 -0
index fb15394aae31..7ee5931300e6 100644
@@ -81,3 +81,9 @@
 #undef __rel_bitmask
 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item,	\
 					 __bitmask_size_in_longs(nr_bits))
+
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
+
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
include/trace/stages/stage6_defines.h +18 -0
index b3a1f26026be..2ac88e1a7677 100644
@@ -45,6 +45,15 @@
 #define __assign_bitmask(dst, src, nr_bits)					\
 	memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
 
+#undef __sockaddr
+#define __sockaddr(field, len) __dynamic_array(u8, field, len)
+
+#undef __get_sockaddr
+#define __get_sockaddr(field)	((struct sockaddr *)__get_dynamic_array(field))
+
+#define __assign_sockaddr(dest, src, len)					\
+	memcpy(__get_dynamic_array(dest), src, len)
+
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(type, item, len)				\
 	__entry->__rel_loc_##item = __data_offsets.item;
@@ -76,6 +85,15 @@
 #define __assign_rel_bitmask(dst, src, nr_bits)					\
 	memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits))
 
+#undef __rel_sockaddr
+#define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len)
+
+#undef __get_rel_sockaddr
+#define __get_rel_sockaddr(field)	((struct sockaddr *)__get_rel_dynamic_array(field))
+
+#define __assign_rel_sockaddr(dest, src, len)					\
+	memcpy(__get_rel_dynamic_array(dest), src, len)
+
 #undef TP_fast_assign
 #define TP_fast_assign(args...) args
 
include/trace/stages/stage7_defines.h +2 -0
index d65445328f18..8a7ec24c246d 100644
@@ -13,10 +13,12 @@
 #undef __get_dynamic_array_len
 #undef __get_str
 #undef __get_bitmask
+#undef __get_sockaddr
 #undef __get_rel_dynamic_array
 #undef __get_rel_dynamic_array_len
 #undef __get_rel_str
 #undef __get_rel_bitmask
+#undef __get_rel_sockaddr
 #undef __print_array
 #undef __print_hex_dump
 
Signature · 40 lines
2.34.1

However, my x86_64 allmodconfig build then failed like this:

In file included from include/trace/define_custom_trace.h:55,
                from samples/trace_events/trace_custom_sched.h:95,
                from samples/trace_events/trace_custom_sched.c:24:
samples/trace_events/./trace_custom_sched.h: In function 'ftrace_test_custom_probe_sched_switch':
include/trace/trace_custom_events.h:178:42: error: passing argument 1 of 'check_trace_callback_type_sched_switch' from incompatible pointer type [-Werror=incompatible-pointer-types]
 178 |         check_trace_callback_type_##call(trace_custom_event_raw_event_##template); \
     |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     |                                          |
     |                                          void (*)(void *, bool,  struct task_struct *, struct task_struct *) {aka void (*)(void *, _Bool,  struct task_struct *, struct task_struct *)}
include/trace/trace_custom_events.h:34:9: note: in expansion of macro 'DEFINE_CUSTOM_EVENT'
  34 |         DEFINE_CUSTOM_EVENT(name, name, PARAMS(proto), PARAMS(args));
     |         ^~~~~~~~~~~~~~~~~~~
samples/trace_events/./trace_custom_sched.h:21:1: note: in expansion of macro 'TRACE_CUSTOM_EVENT'
  21 | TRACE_CUSTOM_EVENT(sched_switch,
     | ^~~~~~~~~~~~~~~~~~
In file included from include/linux/trace_events.h:11,
                from samples/trace_events/trace_custom_sched.c:10:
include/linux/tracepoint.h:279:49: note: expected 'void (*)(void *, bool,  unsigned int,  struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool,  unsigned int,  struct task_struct *, struct task_struct *)'} but argument is of type 'void (*)(void *, bool,  struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool,  struct task_struct *, struct task_struct *)'}
 279 |         check_trace_callback_type_##name(void (*cb)(data_proto))        \
     |                                          ~~~~~~~^~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
 419 |         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
     |         ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
 553 |         DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     |         ^~~~~~~~~~~~~
include/trace/events/sched.h:222:1: note: in expansion of macro 'TRACE_EVENT'
 222 | TRACE_EVENT(sched_switch,
     | ^~~~~~~~~~~

So I gave up and uses the ftrace tree from next-20220310 for today.

I am going to need some help with this mess, please.
-- 
Cheers,
Stephen Rothwell

--
Chuck Lever

maintainer
#2 lore raw
Quoted 5 lines · On Tue, 15 Mar 2022 13:33:30 +0000 Chuck Lever III <[email protected]>…
Quoted 5 lines

af6b9668e85f ("tracing: Move the defines to create TRACE_EVENTS into their own files")

from the ftrace tree.

Well, this is a pain :-(

Welcome to the include/trace directory ;-)

Quoted 3 lines

Apologies. Steven, can you take the sockaddr patches in your tree and resolve the x86_64 build issue?

My apologies, I forgot that there was changes in other trees that affect this.

Anyway, I'll go and do a merge myself and see what happens. The point of linux-next is to resolve these kinds of issues. I believe the reason you took those changes was because you have a dependency on them, and I think they should stay in your tree.

Let me do the merge myself and verify what Stephen did was correct or needs to be updated. This will also need to be done for Linus as well.

Thanks,

-- Steve

maintainer
#3 lore raw
In reply to Chuck Lever III
Quoted 14 lines · On Tue, 15 Mar 2022 13:33:30 +0000 Chuck Lever III <[email protected]>…
Quoted 14 lines · Stephen Rothwell

Hi all,

Today's linux-next merge of the ftrace tree got a conflict in:

include/trace/trace_events.h

between commit:

d07c9ad62247 ("tracing: Introduce helpers to safely handle dynamic-sized sockaddrs")

from the nfsd tree and commit:

Quoted 8 lines
Quoted 5 lines

af6b9668e85f ("tracing: Move the defines to create TRACE_EVENTS into their own files")

from the ftrace tree.

Well, this is a pain :-(

Apologies. Steven, can you take the sockaddr patches in your tree and resolve the x86_64 build issue?

Actually, the issue is not with your tree. It's a conflict with:

fa2c3254d7cff ("sched/tracing: Don't re-read p->state when emitting sched_switch event")

Which changed the sched_switch event that my example was attaching to.

At least this proves that it will not compile if your custom event does not match the prototype of the event that the custom event is modifying :-)

Quoted 14 lines
Quoted 14 lines

However, my x86_64 allmodconfig build then failed like this:

In file included from include/trace/define_custom_trace.h:55,
from samples/trace_events/trace_custom_sched.h:95,
from samples/trace_events/trace_custom_sched.c:24:
samples/trace_events/./trace_custom_sched.h: In function 'ftrace_test_custom_probe_sched_switch':
include/trace/trace_custom_events.h:178:42: error: passing argument 1 of 'check_trace_callback_type_sched_switch' from incompatible pointer type [-Werror=incompatible-pointer-types]

 178 |         check_trace_callback_type_##call(trace_custom_event_raw_event_##template); \
     |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     |                                          |
     |                                          void (*)(void *, bool,  struct task_struct *, struct task_struct *) {aka void (*)(void *, _Bool,  struct task_struct *, struct task_struct *)}

include/trace/trace_custom_events.h:34:9: note: in expansion of macro 'DEFINE_CUSTOM_EVENT'
34 | DEFINE_CUSTOM_EVENT(name, name, PARAMS(proto), PARAMS(args));

Quoted 8 lines
Quoted 8 lines
     |         ^~~~~~~~~~~~~~~~~~~
samples/trace_events/./trace_custom_sched.h:21:1: note: in expansion of macro 'TRACE_CUSTOM_EVENT'
  21 | TRACE_CUSTOM_EVENT(sched_switch,
     | ^~~~~~~~~~~~~~~~~~

In file included from include/linux/trace_events.h:11,
from samples/trace_events/trace_custom_sched.c:10:
include/linux/tracepoint.h:279:49: note: expected 'void (*)(void *, bool, unsigned int, struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool, unsigned int, struct task_struct *, struct task_struct *)'} but argument is of type 'void (*)(void *, bool, struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool, struct task_struct *, struct task_struct *)'}
279 | check_trace_callback_type_##name(void (*cb)(data_proto)) \

It's the type check code that failed. The above is complaining that it expects:

'void (*)(void *, bool, unsigned int, struct task_struct *, struct
task_struct *)' {aka 'void (*)(void *, _Bool, unsigned int, struct task_struct *, struct task_struct *)'}

But it found:

'void (*)(void *, bool, struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool, struct task_struct *, struct task_struct *)'}

That's because the sched_switch event had the int prev_state added to it, but my custom event was unaware of that.

Stephen, I pushed out a branch on my tree that merges my for-next branch with next-20220315 and pushed it to:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git

branch: trace-merge-next-20220315

-- Steve

Quoted 22 lines
Quoted 11 lines
     |                                          ~~~~~~~^~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
 419 |         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
     |         ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
 553 |         DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
     |         ^~~~~~~~~~~~~
include/trace/events/sched.h:222:1: note: in expansion of macro 'TRACE_EVENT'
 222 | TRACE_EVENT(sched_switch,
     | ^~~~~~~~~~~
Quoted 6 lines

So I gave up and uses the ftrace tree from next-20220310 for today.

I am going to need some help with this mess, please.

Signature · 2 lines
Cheers,
Stephen Rothwell  

--
Chuck Lever

#4 lore raw
Quoted 27 lines · Steven Rostedt
Quoted 20 lines · On Tue, 15 Mar 2022 13:33:30 +0000 Chuck Lever III <[email protected]>…
Quoted 19 lines · Stephen Rothwell

Hi all,

Today's linux-next merge of the ftrace tree got a conflict in:

include/trace/trace_events.h

between commit:

d07c9ad62247 ("tracing: Introduce helpers to safely handle dynamic-sized sockaddrs")

from the nfsd tree and commit:

af6b9668e85f ("tracing: Move the defines to create TRACE_EVENTS into their own files")

from the ftrace tree.

Well, this is a pain :-(

Quoted 8 lines
Quoted 2 lines

Apologies. Steven, can you take the sockaddr patches in your tree and resolve the x86_64 build issue?

Actually, the issue is not with your tree. It's a conflict with:

fa2c3254d7cff ("sched/tracing: Don't re-read p->state when emitting sched_switch event")

Which changed the sched_switch event that my example was attaching to.

Thanks for troubleshooting!

Quoted 43 lines

At least this proves that it will not compile if your custom event does not match the prototype of the event that the custom event is modifying :-)

Quoted 14 lines
Quoted 14 lines

However, my x86_64 allmodconfig build then failed like this:

In file included from include/trace/define_custom_trace.h:55,
from samples/trace_events/trace_custom_sched.h:95,
from samples/trace_events/trace_custom_sched.c:24:
samples/trace_events/./trace_custom_sched.h: In function 'ftrace_test_custom_probe_sched_switch':
include/trace/trace_custom_events.h:178:42: error: passing argument 1 of 'check_trace_callback_type_sched_switch' from incompatible pointer type [-Werror=incompatible-pointer-types]

178 |         check_trace_callback_type_##call(trace_custom_event_raw_event_##template); \
    |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |                                          |
    |                                          void (*)(void *, bool,  struct task_struct *, struct task_struct *) {aka void (*)(void *, _Bool,  struct task_struct *, struct task_struct *)}

include/trace/trace_custom_events.h:34:9: note: in expansion of macro 'DEFINE_CUSTOM_EVENT'
34 | DEFINE_CUSTOM_EVENT(name, name, PARAMS(proto), PARAMS(args));

Quoted 8 lines
Quoted 8 lines
    |         ^~~~~~~~~~~~~~~~~~~
samples/trace_events/./trace_custom_sched.h:21:1: note: in expansion of macro 'TRACE_CUSTOM_EVENT'
 21 | TRACE_CUSTOM_EVENT(sched_switch,
    | ^~~~~~~~~~~~~~~~~~

In file included from include/linux/trace_events.h:11,
from samples/trace_events/trace_custom_sched.c:10:
include/linux/tracepoint.h:279:49: note: expected 'void (*)(void *, bool, unsigned int, struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool, unsigned int, struct task_struct *, struct task_struct *)'} but argument is of type 'void (*)(void *, bool, struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool, struct task_struct *, struct task_struct *)'}
279 | check_trace_callback_type_##name(void (*cb)(data_proto)) \

It's the type check code that failed. The above is complaining that it expects:

'void (*)(void *, bool, unsigned int, struct task_struct *, struct
task_struct *)' {aka 'void (*)(void *, _Bool, unsigned int, struct task_struct *, struct task_struct *)'}

But it found:

'void (*)(void *, bool, struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool, struct task_struct *, struct task_struct *)'}

That's because the sched_switch event had the int prev_state added to it, but my custom event was unaware of that.

Quoted 32 lines

Stephen, I pushed out a branch on my tree that merges my for-next branch with next-20220315 and pushed it to:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git

branch: trace-merge-next-20220315

-- Steve

Quoted 20 lines
Quoted 11 lines
    |                                          ~~~~~~~^~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
419 |         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
    |         ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
553 |         DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
    |         ^~~~~~~~~~~~~
include/trace/events/sched.h:222:1: note: in expansion of macro 'TRACE_EVENT'
222 | TRACE_EVENT(sched_switch,
    | ^~~~~~~~~~~
Quoted 6 lines

So I gave up and uses the ftrace tree from next-20220310 for today.

I am going to need some help with this mess, please.

Signature · 2 lines
Cheers,
Stephen Rothwell  

--
Chuck Lever

--
Chuck Lever

#5 lore raw
In reply to Stephen Rothwell

Hi Stephen,

Quoted 33 lines · On Tue, 15 Mar 2022 14:58:28 +1100 Stephen Rothwell <[email protected]>…

However, my x86_64 allmodconfig build then failed like this:

In file included from include/trace/define_custom_trace.h:55,
from samples/trace_events/trace_custom_sched.h:95,
from samples/trace_events/trace_custom_sched.c:24:
samples/trace_events/./trace_custom_sched.h: In function 'ftrace_test_custom_probe_sched_switch':
include/trace/trace_custom_events.h:178:42: error: passing argument 1 of 'check_trace_callback_type_sched_switch' from incompatible pointer type [-Werror=incompatible-pointer-types]

  178 |         check_trace_callback_type_##call(trace_custom_event_raw_event_##template); \
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                          |
      |                                          void (*)(void *, bool,  struct task_struct *, struct task_struct *) {aka void (*)(void *, _Bool,  struct task_struct *, struct task_struct *)}
include/trace/trace_custom_events.h:34:9: note: in expansion of macro 'DEFINE_CUSTOM_EVENT'
   34 |         DEFINE_CUSTOM_EVENT(name, name, PARAMS(proto), PARAMS(args));
      |         ^~~~~~~~~~~~~~~~~~~
samples/trace_events/./trace_custom_sched.h:21:1: note: in expansion of macro 'TRACE_CUSTOM_EVENT'
   21 | TRACE_CUSTOM_EVENT(sched_switch,
      | ^~~~~~~~~~~~~~~~~~
In file included from include/linux/trace_events.h:11,
                 from samples/trace_events/trace_custom_sched.c:10:
include/linux/tracepoint.h:279:49: note: expected 'void (*)(void *, bool,  unsigned int,  struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool,  unsigned int,  struct task_struct *, struct task_struct *)'} but argument is of type 'void (*)(void *, bool,  struct task_struct *, struct task_struct *)' {aka 'void (*)(void *, _Bool,  struct task_struct *, struct task_struct *)'}
  279 |         check_trace_callback_type_##name(void (*cb)(data_proto))        \
      |                                          ~~~~~~~^~~~~~~~~~~~~~~
include/linux/tracepoint.h:419:9: note: in expansion of macro '__DECLARE_TRACE'
  419 |         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
      |         ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:553:9: note: in expansion of macro 'DECLARE_TRACE'
  553 |         DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
      |         ^~~~~~~~~~~~~
include/trace/events/sched.h:222:1: note: in expansion of macro 'TRACE_EVENT'
  222 | TRACE_EVENT(sched_switch,
      | ^~~~~~~~~~~
Quoted 3 lines

So I gave up and uses the ftrace tree from next-20220310 for today.

I am going to need some help with this mess, please.

Thanks for the example merge. The extra merge resolution patch ended up this:

From: Stephen Rothwell <[email protected]>
Date: Wed, 16 Mar 2022 14:01:59 +1100
Subject: [PATCH] fixup for "sched/tracing: Don't re-read p->state when emitting sched_switch event"

---
 samples/trace_events/trace_custom_sched.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
samples/trace_events/trace_custom_sched.h +2 -1
index a3d14de6a2e5..9fdd8e7c2a45 100644
@@ -25,10 +25,11 @@ TRACE_CUSTOM_EVENT(sched_switch,
 	 * that the custom event is using.
 	 */
 	TP_PROTO(bool preempt,
+		 unsigned int prev_state,
 		 struct task_struct *prev,
 		 struct task_struct *next),
 
-	TP_ARGS(preempt, prev, next),
+	TP_ARGS(preempt, prev_state, prev, next),
 
 	/*
 	 * The next fields are where the customization happens.
Signature · 5 lines
2.34.1

-- 
Cheers,
Stephen Rothwell