From: David Laight <David.Laight@ACULAB.COM>
To: 'Vinicius Peixoto' <vpeixoto@lkcamp.dev>,
Brendan Higgins <brendan.higgins@linux.dev>,
David Gow <davidgow@google.com>, Rae Moar <rmoar@google.com>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"kunit-dev@googlegroups.com" <kunit-dev@googlegroups.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
"~lkcamp/patches@lists.sr.ht" <~lkcamp/patches@lists.sr.ht>
Subject: RE: [PATCH 0/1] Add KUnit tests for lib/crc16.c
Date: Wed, 25 Sep 2024 11:26:43 +0000 [thread overview]
Message-ID: <51c4ba25f9284a749b451ca203fcc124@AcuMS.aculab.com> (raw)
In-Reply-To: <20240922232643.535329-1-vpeixoto@lkcamp.dev>
From: Vinicius Peixoto
> Sent: 23 September 2024 00:27
>
> Hi all,
>
> This patch was developed during a hackathon organized by LKCAMP [1],
> with the objective of writing KUnit tests, both to introduce people to
> the kernel development process and to learn about different subsystems
> (with the positive side effect of improving the kernel test coverage, of
> course).
>
> We noticed there were tests for CRC32 in lib/crc32test.c and thought it
> would be nice to have something similar for CRC16, since it seems to be
> widely used in network drivers (as well as in some ext4 code).
>
> Although this patch turned out quite big, most of the LOCs come from
> tables containing randomly-generated test data that we use to validate
> the kernel's implementation of CRC-16.
>
> We would really appreciate any feedback/suggestions on how to improve
> this. Thanks! :-)
Would is be better to use a trivial PRNG to generate repeatable 'random enough'
data, rather than having a large static array?
As a matter of interest, how in crc16 implemented (I know I could look).
The code version:
uint32_t
crc_step(uint32_t crc, uint32_t byte_val)
{
uint32_t t = crc ^ (byte_val & 0xff);
t = (t ^ t << 4) & 0xff;
return crc >> 8 ^ t << 8 ^ t << 3 ^ t >> 4;
}
may well be faster than a lookup table version.
Especially on modern multi-issue cpu and/or for small buffers where the lookup
table won't necessarily be resident in the D-cache.
It is slightly slower than the table lookup on the simple Nios-II cpu.
But we use a custom instruction to do it in one clock.
David
>
> Vinicius Peixoto (1):
> lib/crc16_kunit.c: add KUnit tests for crc16
>
> lib/Kconfig.debug | 8 +
> lib/Makefile | 1 +
> lib/crc16_kunit.c | 715 ++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 724 insertions(+)
> create mode 100644 lib/crc16_kunit.c
>
> --
> 2.43.0
>
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2024-09-25 11:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-22 23:26 [PATCH 0/1] Add KUnit tests for lib/crc16.c 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
2024-09-25 11:26 ` David Laight [this message]
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=51c4ba25f9284a749b451ca203fcc124@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=akpm@linux-foundation.org \
--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=vpeixoto@lkcamp.dev \
--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