Thread (16 messages) flat view 16 messages, 7 authors, 2019-05-13

RE: [PATCH v2 4/7] lib/hexdump.c: Replace ascii bool in hex_dump_to_buffer with flags

From: Alastair D'Silva <hidden>
Date: 2019-05-08 11:49:25
Also in: dri-devel, intel-gfx, linux-fbdev, linux-fsdevel, linux-scsi, linux-wireless, lkml

-----Original Message-----
From: David Laight <redacted>
Sent: Wednesday, 8 May 2019 7:20 PM
To: 'Alastair D'Silva' <redacted>; alastair@d-silva.org
Cc: Jani Nikula <jani.nikula@linux.intel.com>; Joonas Lahtinen
[off-list ref]; Rodrigo Vivi [off-list ref];
David Airlie [off-list ref]; Daniel Vetter [off-list ref]; Dan
Carpenter [off-list ref]; Karsten Keil <isdn@linux-
pingi.de>; Jassi Brar [off-list ref]; Tom Lendacky
[off-list ref]; David S. Miller [off-list ref];
Jose Abreu [off-list ref]; Kalle Valo
[off-list ref]; Stanislaw Gruszka [off-list ref];
Benson Leung [off-list ref]; Enric Balletbo i Serra
[off-list ref]; James E.J. Bottomley
[off-list ref]; Martin K. Petersen [off-list ref];
Greg Kroah-Hartman [off-list ref]; Alexander Viro
[off-list ref]; Petr Mladek [off-list ref]; Sergey
Senozhatsky [off-list ref]; Steven Rostedt
[off-list ref]; Andrew Morton [off-list ref];
intel-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-
kernel@vger.kernel.org; netdev@vger.kernel.org;
ath10k@lists.infradead.org; linux-wireless@vger.kernel.org; linux-
scsi@vger.kernel.org; linux-fbdev@vger.kernel.org;
devel@driverdev.osuosl.org; linux-fsdevel@vger.kernel.org
Subject: RE: [PATCH v2 4/7] lib/hexdump.c: Replace ascii bool in
hex_dump_to_buffer with flags

From: Alastair D'Silva
quoted
Sent: 08 May 2019 08:02
To: alastair@d-silva.org
...
quoted
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -480,13 +480,13 @@ enum {
 	DUMP_PREFIX_OFFSET
 };

-extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
-			      int groupsize, char *linebuf, size_t linebuflen,
-			      bool ascii);
-
 #define HEXDUMP_ASCII			(1 << 0)
 #define HEXDUMP_SUPPRESS_REPEATED	(1 << 1)
These ought to be BIT(0) and BIT(1)
Thanks, I'll address that.
quoted
+extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
+			      int groupsize, char *linebuf, size_t linebuflen,
+			      u64 flags);
Why 'u64 flags' ?
How many flags do you envisage ??
Your HEXDUMP_ASCII (etc) flags are currently signed values and might get
sign extended causing grief.
'unsigned int flags' is probably sufficient.
I was trying to avoid having to change the prototype again in the future, but it's not a big deal, if enough work goes in to require more than 32 bits, it can be updated at that point.
I've not really looked at the code, it seems OTT in places though.
I'll wait for more concrete criticisms here, this it a bit too vague to take any action on.
If someone copies it somewhere where the performance matters (I've user
space code which is dominated by its tracing!) then you don't want all the
function calls and conditionals even if you want some of the functionality.
Calling hexdump (even in it's unaltered form) in performance critical code is always going to suck. As you mentioned before, it's all based around printf. A performance conscious user would be better off building their code around hex_asc_hi/lo instead (see lib/vsprintf.c:hex_string).

-- 
Alastair D'Silva           mob: 0423 762 819
skype: alastair_dsilva     msn: alastair@d-silva.org
blog: http://alastair.d-silva.org    Twitter: @EvilDeece


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help