linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n
@ 2016-07-13 21:03 Arnd Bergmann
  2016-07-13 21:03 ` [PATCH net-next 2/2] devlink: fix trace format string Arnd Bergmann
  2016-07-14  6:21 ` [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n Jiri Pirko
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-07-13 21:03 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, Steven Rostedt, Ingo Molnar, David S . Miller,
	linux-kernel, Arnd Bergmann

A driver calling trace_devlink_hwmsg cannot be built when modules are disabled:

include/trace/events/devlink.h: In function 'trace_event_get_offsets_devlink_hwmsg':
include/trace/events/devlink.h:25:51: error: dereferencing pointer to incomplete type 'struct module'
   __string(owner_name, devlink->dev->driver->owner->name)

This changes the code to only print the module name when modules are actually
enabled, otherwise we hardcode the string "built-in".

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: e5224f0fe2ac ("devlink: add hardware messages tracing facility")
---
 include/trace/events/devlink.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/trace/events/devlink.h b/include/trace/events/devlink.h
index 333c32ac9bfa..26f92d3c7e9c 100644
--- a/include/trace/events/devlink.h
+++ b/include/trace/events/devlink.h
@@ -22,7 +22,11 @@ TRACE_EVENT(devlink_hwmsg,
 	TP_STRUCT__entry(
 		__string(bus_name, devlink->dev->bus->name)
 		__string(dev_name, dev_name(devlink->dev))
+#ifdef CONFIG_MODULES
 		__string(owner_name, devlink->dev->driver->owner->name)
+#else
+		__string(owner_name, "built-in")
+#endif
 		__field(bool, incoming)
 		__field(unsigned long, type)
 		__dynamic_array(u8, buf, len)
@@ -32,7 +36,11 @@ TRACE_EVENT(devlink_hwmsg,
 	TP_fast_assign(
 		__assign_str(bus_name, devlink->dev->bus->name);
 		__assign_str(dev_name, dev_name(devlink->dev));
+#ifdef CONFIG_MODULES
 		__assign_str(owner_name, devlink->dev->driver->owner->name);
+#else
+		__assign_str(owner_name, "built-in");
+#endif
 		__entry->incoming = incoming;
 		__entry->type = type;
 		memcpy(__get_dynamic_array(buf), buf, len);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/2] devlink: fix trace format string
  2016-07-13 21:03 [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n Arnd Bergmann
@ 2016-07-13 21:03 ` Arnd Bergmann
  2016-07-14  6:21 ` [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n Jiri Pirko
  1 sibling, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-07-13 21:03 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, Steven Rostedt, Ingo Molnar, David S . Miller,
	linux-kernel, Arnd Bergmann

Including devlink.h on ARM and probably other 32-bit architectures results in
a harmless warning:

In file included from ../include/trace/define_trace.h:95:0,
                 from ../include/trace/events/devlink.h:51,
                 from ../net/core/devlink.c:30:
include/trace/events/devlink.h: In function 'trace_raw_output_devlink_hwmsg':
include/trace/events/devlink.h:42:12: error: format '%lu' expects argument of type 'long unsigned int', but argument 10 has type 'size_t {aka unsigned int}' [-Werror=format=]

The correct format string for 'size_t' is %zu, not %lu, this works on all
architectures.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: e5224f0fe2ac ("devlink: add hardware messages tracing facility")
---
 include/trace/events/devlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/trace/events/devlink.h b/include/trace/events/devlink.h
index 26f92d3c7e9c..4b75a6f986fc 100644
--- a/include/trace/events/devlink.h
+++ b/include/trace/events/devlink.h
@@ -47,7 +47,7 @@ TRACE_EVENT(devlink_hwmsg,
 		__entry->len = len;
 	),
 
-	TP_printk("bus_name=%s dev_name=%s owner_name=%s incoming=%d type=%lu buf=0x[%*phD] len=%lu",
+	TP_printk("bus_name=%s dev_name=%s owner_name=%s incoming=%d type=%lu buf=0x[%*phD] len=%zu",
 		  __get_str(bus_name), __get_str(dev_name),
 		  __get_str(owner_name), __entry->incoming, __entry->type,
 		  (int) __entry->len, __get_dynamic_array(buf), __entry->len)
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n
  2016-07-13 21:03 [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n Arnd Bergmann
  2016-07-13 21:03 ` [PATCH net-next 2/2] devlink: fix trace format string Arnd Bergmann
@ 2016-07-14  6:21 ` Jiri Pirko
  2016-07-14  8:12   ` Arnd Bergmann
  1 sibling, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2016-07-14  6:21 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jiri Pirko, netdev, Steven Rostedt, Ingo Molnar,
	David S . Miller, linux-kernel

Wed, Jul 13, 2016 at 11:03:37PM CEST, arnd@arndb.de wrote:
>A driver calling trace_devlink_hwmsg cannot be built when modules are disabled:
>
>include/trace/events/devlink.h: In function 'trace_event_get_offsets_devlink_hwmsg':
>include/trace/events/devlink.h:25:51: error: dereferencing pointer to incomplete type 'struct module'
>   __string(owner_name, devlink->dev->driver->owner->name)
>
>This changes the code to only print the module name when modules are actually
>enabled, otherwise we hardcode the string "built-in".
>
>Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>Fixes: e5224f0fe2ac ("devlink: add hardware messages tracing facility")
>---
> include/trace/events/devlink.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
>diff --git a/include/trace/events/devlink.h b/include/trace/events/devlink.h
>index 333c32ac9bfa..26f92d3c7e9c 100644
>--- a/include/trace/events/devlink.h
>+++ b/include/trace/events/devlink.h
>@@ -22,7 +22,11 @@ TRACE_EVENT(devlink_hwmsg,
> 	TP_STRUCT__entry(
> 		__string(bus_name, devlink->dev->bus->name)
> 		__string(dev_name, dev_name(devlink->dev))
>+#ifdef CONFIG_MODULES
> 		__string(owner_name, devlink->dev->driver->owner->name)

I think would be better to use driver->name. I looks like it is always
present. I will do some tests and send a patch.


>+#else
>+		__string(owner_name, "built-in")
>+#endif
> 		__field(bool, incoming)
> 		__field(unsigned long, type)
> 		__dynamic_array(u8, buf, len)
>@@ -32,7 +36,11 @@ TRACE_EVENT(devlink_hwmsg,
> 	TP_fast_assign(
> 		__assign_str(bus_name, devlink->dev->bus->name);
> 		__assign_str(dev_name, dev_name(devlink->dev));
>+#ifdef CONFIG_MODULES
> 		__assign_str(owner_name, devlink->dev->driver->owner->name);
>+#else
>+		__assign_str(owner_name, "built-in");
>+#endif
> 		__entry->incoming = incoming;
> 		__entry->type = type;
> 		memcpy(__get_dynamic_array(buf), buf, len);
>-- 
>2.9.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n
  2016-07-14  6:21 ` [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n Jiri Pirko
@ 2016-07-14  8:12   ` Arnd Bergmann
  2016-07-14  8:51     ` Jiri Pirko
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2016-07-14  8:12 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: Jiri Pirko, netdev, Steven Rostedt, Ingo Molnar,
	David S . Miller, linux-kernel

On Thursday, July 14, 2016 8:21:11 AM CEST Jiri Pirko wrote:
> >diff --git a/include/trace/events/devlink.h b/include/trace/events/devlink.h
> >index 333c32ac9bfa..26f92d3c7e9c 100644
> >--- a/include/trace/events/devlink.h
> >+++ b/include/trace/events/devlink.h
> >@@ -22,7 +22,11 @@ TRACE_EVENT(devlink_hwmsg,
> >       TP_STRUCT__entry(
> >               __string(bus_name, devlink->dev->bus->name)
> >               __string(dev_name, dev_name(devlink->dev))
> >+#ifdef CONFIG_MODULES
> >               __string(owner_name, devlink->dev->driver->owner->name)
> 
> I think would be better to use driver->name. I looks like it is always
> present. I will do some tests and send a patch.
> 

Yes, good idea.

	Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n
  2016-07-14  8:12   ` Arnd Bergmann
@ 2016-07-14  8:51     ` Jiri Pirko
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2016-07-14  8:51 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jiri Pirko, netdev, Steven Rostedt, Ingo Molnar,
	David S . Miller, linux-kernel

Thu, Jul 14, 2016 at 10:12:43AM CEST, arnd@arndb.de wrote:
>On Thursday, July 14, 2016 8:21:11 AM CEST Jiri Pirko wrote:
>> >diff --git a/include/trace/events/devlink.h b/include/trace/events/devlink.h
>> >index 333c32ac9bfa..26f92d3c7e9c 100644
>> >--- a/include/trace/events/devlink.h
>> >+++ b/include/trace/events/devlink.h
>> >@@ -22,7 +22,11 @@ TRACE_EVENT(devlink_hwmsg,
>> >       TP_STRUCT__entry(
>> >               __string(bus_name, devlink->dev->bus->name)
>> >               __string(dev_name, dev_name(devlink->dev))
>> >+#ifdef CONFIG_MODULES
>> >               __string(owner_name, devlink->dev->driver->owner->name)
>> 
>> I think would be better to use driver->name. I looks like it is always
>> present. I will do some tests and send a patch.
>> 
>
>Yes, good idea.


I will take your second path, rebase and send along. Thanks.

>
>	Arnd
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-07-14  8:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-13 21:03 [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n Arnd Bergmann
2016-07-13 21:03 ` [PATCH net-next 2/2] devlink: fix trace format string Arnd Bergmann
2016-07-14  6:21 ` [PATCH net-next 1/2] devlink: fix build error for CONFIG_MODULES=n Jiri Pirko
2016-07-14  8:12   ` Arnd Bergmann
2016-07-14  8:51     ` Jiri Pirko

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).