hot take question for the day
jim.cromie at gmail.com
jim.cromie at gmail.com
Fri Dec 4 12:42:13 EST 2020
so I was looking at the following code, from dynamic_debug.c,
I saw a minor code optimization, and wondered whether
its already optimized away by compiler.
Instead of actually testing it ( I intend to eventually )
I figure Id ask if you all want to take an educated guess ?
or perhaps just do the test, and post results.
And since Im making a game of it, I might suggest a prize -
that by prepping a patch, showing its effect (none? tiny?
not observable in objdump?) and submitting it, I would ack it
I suspect that Greg might take it ; its a legit sub-optimality and
fix is at least decluttering and deobfuscating.
so heres the snippet.
if you got this far, you can find the prob (or 2)
static char *dynamic_emit_prefix(struct _ddebug *dp, char *buf)
{
int pos_after_tid;
int pos = 0;
*buf = '\0';
if (dp->flags & _DPRINTK_FLAGS_INCL_TID) {
if (in_interrupt())
pos += snprintf(buf + pos, remaining(pos), "<intr> ");
else
pos += snprintf(buf + pos, remaining(pos), "[%d] ",
task_pid_vnr(current));
}
More information about the Kernelnewbies
mailing list