Re: [PATCH] tracing/probe: fix typo in pr_fmt in trace_uprobe.c
From: Masahiro Yamada
Date: Wed Dec 06 2017 - 06:01:15 EST
2017-11-17 2:05 GMT+09:00 Joe Perches <joe@xxxxxxxxxxx>:
> On Wed, 2017-11-15 at 21:55 -0500, Steven Rostedt wrote:
>> On Wed, 15 Nov 2017 14:55:19 -0800
>> Joe Perches <joe@xxxxxxxxxxx> wrote:
>>
>> > Maybe use the much more common below instead?
>> >
>> > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>>
>> Is there someplace this is documented. My git grep foo isn't finding it
>> for me.
>
> Not so far as I know.
>
> Maybe Michal Marek or Masahiro Yamada might add some
> documentation in the future about these KBUILD defines.
>
> btw, there are about 1800 #define pr_fmt uses and most
> of them use KBUILD_MODNAME
>
> $ git grep -P "^\s*#\s*define\s+pr_fmt\b" | \
> cut -f2- -d":" | \
> sed -r 's/^\s*#\s*define\s+pr_fmt([^ ]+)\s++/#define pr_fmt\1 /' | \
> sed -r 's/\)\s+/) /' | sort | uniq -c | sort -rn | head -10
> 1166 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> 134 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
> 32 #define pr_fmt(fmt) "%s: " fmt, __func__
> 22 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
> 17 #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
> 13 #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
> 11 #define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
> 10 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
> 10 #define pr_fmt(fmt) "IPv6: " fmt
> 9 #define pr_fmt(fmt) fmt
>
Slightly related topic.
Does KBUILD_MODNAME need to be correct,
or defined all the time?
One object could be shared among multiple modules, like follows:
obj-m += foo.o
obj-m += bar.o
foo-objs := foo-bar-common.o foo-main.o
bar-objs := foo-bar-common.o bar-main.o
In this case, it is debatable
what we should define for KBUILD_MODNAME
when compiling foo-bar-common.o
[1] -DKBUILD_MODNAME='"foo-bar-common"'
(define base name of object name)
[2] -DKBUILD_MODNAME='"foo:bar"'
(define colon separated module names)
[3] Do not define KBUILD_MODNAME at all
or any other idea?
[3] is the current behavior of Kbuild.
If KBUILD_MODNAME is referenced, it is a build error.
One object is shared among multiple modules,
for example:
lib/zstd/Makefile
drivers/mtd/tests/Makefile
drivers/net/ethernet/cavium/liquidio/Makefile
--
Best Regards
Masahiro Yamada