kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* hot take question for the day
@ 2020-12-04 17:42 jim.cromie
  0 siblings, 0 replies; only message in thread
From: jim.cromie @ 2020-12-04 17:42 UTC (permalink / raw)
  To: kernelnewbies

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));
}

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-04 17:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 17:42 hot take question for the day jim.cromie

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