hi all, there are many uses of : pr_debug("%s ...\n", __func__, ...) I tried to do a preprocessor catenation to replace the runtime work, but that falls afoul of the def. from gnu gcc web-page: The identifier __func__ is implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declaration static const char __func__[] = "function-name"; These identifiers are variables, not preprocessor macros, and may not be used to initialize char arrays or be concatenated with string literals. is there a kernel macro version that would allow this "optimization" ?
try #undef pr_fmt #define pr_fmt(fmt) "%s.c:%d: %s " fmt, __FILE__, __LINE__, __func__ On Tue, 3 Aug 2021 at 21:44, <jim.cromie@gmail.com> wrote:
hi all,
there are many uses of : pr_debug("%s ...\n", __func__, ...)
I tried to do a preprocessor catenation to replace the runtime work, but that falls afoul of the def.
from gnu gcc web-page:
The identifier __func__ is implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declaration
static const char __func__[] = "function-name";
These identifiers are variables, not preprocessor macros, and may not be used to initialize char arrays or be concatenated with string literals.
is there a kernel macro version that would allow this "optimization" ?
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- Constantine Shulyupin
Hi all! On 03/08/2021 20:43, jim.cromie@gmail.com wrote: [...]
there are many uses of : pr_debug("%s ...\n", __func__, ...)
I tried to do a preprocessor catenation to replace the runtime work, but that falls afoul of the def.
And that's a feature because preprocessor concatenation bloats the kernels memory footprint massively. [...]
is there a kernel macro version that would allow this "optimization" ?
pr_*() are slow per se so optimizing there (apart from readability and size od code+data) is wasted time. MfG, Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at There is NO CLOUD, just other people's computers. - FSFE LUGA : http://www.luga.at
On Tue, Aug 3, 2021 at 1:27 PM Bernd Petrovitsch <bernd@petrovitsch.priv.at> wrote:
Hi all!
On 03/08/2021 20:43, jim.cromie@gmail.com wrote: [...]
there are many uses of : pr_debug("%s ...\n", __func__, ...)
I tried to do a preprocessor catenation to replace the runtime work, but that falls afoul of the def.
And that's a feature because preprocessor concatenation bloats the kernels memory footprint massively.
[...]
is there a kernel macro version that would allow this "optimization" ?
pr_*() are slow per se so optimizing there (apart from readability and size od code+data) is wasted time.
Im not after optimization per se. but wrt it, best optimization is to not print, except when its useful. thats the value of dyndbg, silence until you need it. dynamic-debug lets you selectively enable pr_debug()s by their properties - module, function, filename, lineno, format all but last are properties of code organization, format uniquely contains "Application" context. in DRM context, that context could be any of DRM_UT_<category> If that category-info is in the format string (at compile time) then dynamic-debug can operate on the app-info in it too. Then dyndbg can replace drm_debug_enabled(), and save cycles. Ive done this, Daniel Vetter liked it, so unless Im hit by a bus, I will finish it. https://patchwork.freedesktop.org/series/92544/ Im just looking for corner cases of its applicability. note: __func__ and others are available from dyndbg framework, ( +pmfl ) So callsites doing too is "overhead" unless youre avoiding dyndbg ( memory use would be a 1st reason not to use it) In any case, if __func__ worked like a macro, the "optimization" would be available. And because its in the format, this would work echo "format $_func_name +p" > /proc/dynamic_debug/control of course, so would: echo "func $_func_name +p" > /proc/dynamic_debug/control but for that, you'd need to know func. to get it, you could echo +fm > /proc/dynamic_debug/control anyway, thats FMTYNTK thanks Jim
MfG, Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at There is NO CLOUD, just other people's computers. - FSFE LUGA : http://www.luga.at
participants (3)
-
Bernd Petrovitsch -
Constantine Shulyupin -
jim.cromie@gmail.com