Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278479

Re: [PATCH] HID: debug: improve hid_debug_event()

From Jiri Kosina <jikos@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] HID: debug: improve hid_debug_event()
Date 2015-11-27 00:10 +0100
Message-ID <qzdPP-3ct-1@gated-at.bofh.it> (permalink)
References <qyl35-86O-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 24 Nov 2015, Rasmus Villemoes wrote:

> The code in hid_debug_event() causes horrible code generation. First,
> we do a strlen() call for every byte we copy (we're doing a store to
> global memory, so gcc has no way of proving that strlen(buf) doesn't
> change). Second, since both i, list->tail and HID_DEBUG_BUFSIZE have
> signed type, the modulo computation has to take into account the
> possibility that list->tail+i is negative, so it's not just a simple
> and.
> 
> Fix the former by simply not doing strlen() at all (we have to load
> buf[i] anyway, so testing it is almost free) and the latter by
> changing i to unsigned. This cuts 29% (69 bytes) of the size of the
> function.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Agreed, this is much better. Applied to for-4.5/core, thanks Rasmus.

-- 
Jiri Kosina
SUSE Labs

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] HID: debug: improve hid_debug_event() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-11-24 13:40 +0100
  Re: [PATCH] HID: debug: improve hid_debug_event() Joe Perches <joe@perches.com> - 2015-11-25 21:40 +0100
    Re: [PATCH] HID: debug: improve hid_debug_event() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-11-26 22:10 +0100
  Re: [PATCH] HID: debug: improve hid_debug_event() Jiri Kosina <jikos@kernel.org> - 2015-11-27 00:10 +0100

csiph-web