Re: [PATCH 1/3] lib: crc32: Greatly shrink CRC combining code

From: Daniel Borkmann
Date: Wed Jun 04 2014 - 17:07:37 EST


On 06/04/2014 08:32 PM, George Spelvin wrote:
Thanks for the nitpicks!

I think you might want to cc Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
to let this go via akpm's tree for misc changes, perhaps?

I don't care, but akpm is fine by me. I'll send out a v2 after I resolve
one minor point with you; see below.

Once that's done, may I add a Reviewed-by: or Acked-by: line from you?

Yes, feel free to add my Reviewed-by tag and keep me in Cc.

Looks good to me! Do you have any performance numbers to share?

Actually, I didn't bother benchmarking it because the improvement was
so obvious, but here's a quick test showing a 35.5x performance gain.

That's great!

...
-extern u32 crc32_le_combine(u32 crc1, u32 crc2, size_t len2);
+u32 crc32_le_shift(u32 crc, size_t len) __attribute_const__;

Perhaps a newline here.

Question: where do you think a newline should go? It's not obvious
to me. My style has been to keep as much of a declaration on one line
as possible so "git grep <function> include" is as informative as possible.

It's just nit, but since you've asked, end result like this:

--snip--
u32 crc32_le_shift(u32 crc, size_t len) __attribute_const__;

static inline u32 crc32_le_combine(u32 crc1, u32 crc2, size_t len2)
{
return crc32_le_shift(crc1, len2) ^ crc2;
}
--snap--

Now that I've gotten an ack, I'm happy to be more aggressive about
tweaking comments. I just wanted to focus the diff on the code changes.

Sounds good, thanks!

+/**
+ * crc32_generic_shift - Append len 0 bytes to crc, in logarithmic time
+ * @crc: The original little-endian CRC (i.e. lsbit is x^31 coefficient)
+ * @len: The number of bytes. @crc is multiplied by x^(8*@len)
+ # @polynomial: The modulus used to reduce the result to 32 bits.

^^ seems this should have been a '*'

Yes, obviously. Thanks for catching that.

+static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len,
+ u32 polynomial)

u32 polynomial is not correctly aligned to the opening '(' from the previous line.

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