From: Vinicius Peixoto <vpeixoto@lkcamp.dev>
To: "David Laight" <David.Laight@ACULAB.COM>,
"André Almeida" <andrealmeid@riseup.net>
Cc: Brendan Higgins <brendan.higgins@linux.dev>,
"~lkcamp/patches@lists.sr.ht" <~lkcamp/patches@lists.sr.ht>,
Rae Moar <rmoar@google.com>, David Gow <davidgow@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
"kunit-dev@googlegroups.com" <kunit-dev@googlegroups.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH 0/1] Add KUnit tests for lib/crc16.c
Date: Sun, 29 Sep 2024 21:57:45 -0300 [thread overview]
Message-ID: <7d2ad97c-6a0e-4113-9f30-c30b5db7a028@lkcamp.dev> (raw)
In-Reply-To: <7f67ae7f15524e4eab6b15cdfd750a04@AcuMS.aculab.com>
Hi David,
On 9/26/24 13:21, David Laight wrote:
> ...
>> The checksums for the randomly-generated test cases were calculated
>> using a reference implementation [1] and this test compares them against
>> the values yielded by the kernel's implementation.
>
> I'd just use a naïve implementation - doesn't really matter
> if it is a bit slow.
Thanks for the feedback. I agree that it makes more sense to use a naive
implementation to validate the results from the kernel's crc16 instead
of having a table of pre-computed results. I will include in v2 a
bog-standard implementation of crc16 similar to yours (using a loop
instead of a lookup table) to validate the results.
Thanks,
Vinicius
>
> Slow is relative - this code only takes 35ms to crc-64 over 5MB of data.
>
> {
> volatile const uint32_t *r = (const void *)buf;
> for (crc = 0; r < (const uint32_t *)buf_end; r++) {
> uint64_t val = le32toh(*r);
> crc ^= bswap64(val);
> for (i = 0; i < 32; i++) {
> if (crc & (1ull << 63))
> crc = (crc << 1) ^ 0x42f0e1eba9ea3693ull;
> else
> crc = crc << 1;
> }
> }
> }
>
> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2024-09-30 0:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-22 23:26 Vinicius Peixoto
2024-09-22 23:26 ` [PATCH 1/1] lib/crc16_kunit.c: add KUnit tests for crc16 Vinicius Peixoto
2024-09-24 21:33 ` [PATCH 0/1] Add KUnit tests for lib/crc16.c André Almeida
2024-09-24 23:00 ` Vinicius Peixoto
2024-09-26 16:21 ` David Laight
2024-09-30 0:57 ` Vinicius Peixoto [this message]
2024-09-25 11:26 ` David Laight
2024-09-30 1:18 ` Vinicius Peixoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7d2ad97c-6a0e-4113-9f30-c30b5db7a028@lkcamp.dev \
--to=vpeixoto@lkcamp.dev \
--cc=David.Laight@ACULAB.COM \
--cc=akpm@linux-foundation.org \
--cc=andrealmeid@riseup.net \
--cc=brendan.higgins@linux.dev \
--cc=davidgow@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=rmoar@google.com \
--cc=~lkcamp/patches@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®