* [PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c'
@ 2012-02-06 21:10 Christophe JAILLET
2012-02-07 6:54 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2012-02-06 21:10 UTC (permalink / raw)
To: kernel-janitors
Hi,
I don't know if it worses a patch, but function 'nla_strlcpy' in file
'\lib\nlattr.c' could be improved a bit.
There is no need to memset(0) the whole buffer. Only the end of it has
to be cleared.
Usually, 'dstsize' is small (most of the time IFNAMSIZ = 16 bytes), so
the gain should be real small, if noticeable.
I'm not sure of who to cc: the mail. I've just added Alexey Kuznetsov
which is one of the author of the modified file and still in the
MAINTAINERS list.
Hope this helps,
Best regards.
Signed-off-by: Christophe Jaillet<christophe.jaillet@wanadoo.fr>
--- a/lib/nlattr.c 2012-02-06 21:40:04.421875000 +0100
+++ b/lib/nlattr.c 2012-02-06 21:50:43.093750000 +0100
@@ -248,8 +248,8 @@
if (dstsize > 0) {
size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
- memset(dst, 0, dstsize);
memcpy(dst, src, len);
+ memset(dst + len, 0, dstsize - len);
}
return srclen;
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c'
2012-02-06 21:10 [PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c' Christophe JAILLET
@ 2012-02-07 6:54 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2012-02-07 6:54 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]
On Mon, Feb 06, 2012 at 10:10:27PM +0100, Christophe JAILLET wrote:
> Hi,
>
> I don't know if it worses a patch, but function 'nla_strlcpy' in
> file '\lib\nlattr.c' could be improved a bit.
> There is no need to memset(0) the whole buffer. Only the end of it
> has to be cleared.
>
> Usually, 'dstsize' is small (most of the time IFNAMSIZ = 16 bytes),
> so the gain should be real small, if noticeable.
>
> I'm not sure of who to cc: the mail. I've just added Alexey
> Kuznetsov which is one of the author of the modified file and still
> in the MAINTAINERS list.
>
So if we're not going to notice the speedup, then it's not worth it.
Mostly this is only used when people type "ifup eth0" and so a
speedup wouldn't even matter. It is used in taskstats so maybe if
you did a benchmark and showed that it was faster then that would
be a compelling argument. But every patch needs to have a reason to
apply it, and "maybe this helps but maybe not" is not good enough
salesmanship, you need actual data.
Use the ./scripts/get_maintainer.pl to find which places to send
this.
Also your email client mangled the patch so it doesn't apply. Read
Documentation/email-clients.txt. Send the patch to yourself first
and verify that you can do a "cat raw_email.txt | patch -p1".
regards,
dan carpenter
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-07 6:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-06 21:10 [PATCH] small speedup in 'nla_strlcpy' in file '\lib\nlattr.c' Christophe JAILLET
2012-02-07 6:54 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox