From: Coly Li <colyli@suse.de>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-bcache@vger.kernel.org, linux-block@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Kate Stewart <kstewart@linuxfoundation.org>
Subject: Re: [PATCH v3 3/3] lib/test_crc: Add test cases for crc calculation
Date: Wed, 18 Jul 2018 23:28:22 +0800 [thread overview]
Message-ID: <370a51bc-6029-c2df-67b4-22ef906ea62f@suse.de> (raw)
In-Reply-To: <CAHp75VcXDbDTebddnepeari8_ruynPudbtHGybFEQ=3Cz8Ddvg@mail.gmail.com>
On 2018/7/18 1:11 AM, Andy Shevchenko wrote:
> On Tue, Jul 17, 2018 at 5:55 PM, Coly Li <colyli@suse.de> wrote:
>> This patch adds a kernel module to test the consistency of multiple crc
>> calculation in Linux kernel. It is enabled with CONFIG_TEST_CRC enabled.
>>
>> The test results are printed into kernel message, which look like,
>>
>> test_crc: crc64: PASSED (0x4e6b1ff972fa8c55, expected 0x4e6b1ff972fa8c55)
>> test_crc: crc64_bch: PASSED (0x0e4f1391d7a4a62e, expected 0x0e4f1391d7a4a62e)
>> test_crc: crc64_update: FAILED (0x03d4d0d85685d9a1, expected 0x3d4d0d85685d9a1f)
>>
>> kernel 0day system has framework to check kernel message, then the above
>> result can be handled by 0day system. If crc calculation inconsistency
>> happens, it can be detected quite soon.
>>
>> lib/test_crc.c is a testing frame work for many crc consistency
>> testings. For now, there are only test caes for 3 crc routines,
>> - crc64()
>> - crc64_bch()
>> - crc64_update()
>
> Thanks for an update. My comments below.
>
>> Changelog:
>> v3: Add test cases passed/failed statistic
>> More fixes for review comments of v2
>> v2: Fixes for review comments of v1
>> v1: Initial version.
>
> Usually this part goes after --- line below.
>
OK, I change all the patches in this way.
>> Signed-off-by: Coly Li <colyli@suse.de>
>> Reviewed-by: Hannes Reinecke <hare@suse.de>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Kate Stewart <kstewart@linuxfoundation.org>
>
> Please, Cc me as well this one in next version (use my Intel address).
>
Added :-)
>> +#include <linux/async.h>
>> +#include <linux/delay.h>
>> +#include <linux/fs.h>
>> +#include <linux/list.h>
>> +#include <linux/module.h>
>> +#include <linux/printk.h>
>> +#include <linux/miscdevice.h>
>> +#include <linux/slab.h>
>> +#include <linux/uaccess.h>
>> +#include <linux/vmalloc.h>
>> +#include <linux/crc64.h>
>
> Do we need all of them?
>
I remove most of them, only keep linux/module.h and linux/crc64.h in v4
series.
>> +static int chk_and_msg(const char *name, u64 crc, u64 expval)
>> +{
>
>> + int ret = 0;
>> +
>> + if (crc == expval) {
>
>> + pr_info("test_crc: %s: PASSED:(0x%016llx, expected 0x%016llx)\n",
>> + name, crc, expval);
>
> This doesn't bring anything useful.
>
>> + } else {
>> + pr_err("test_crc: %s: FAILED:(0x%016llx, expected 0x%016llx)\n",
>> + name, crc, expval);
>> + ret = -EINVAL;
>> + }
>> +
>> + return ret;
>
> I would rewrite entire function as follows:
>
> static void ...(...)
> {
> total_tests++;
> if (crc == expval)
> return;
>
> pr_err(...);
> failed_tests++;
> }
>
>
>> +}
>
>> +static int __init test_crc_init(void)
>> +{
>> + int i;
>> + int v, err = 0;
>> +
>> + pr_info("Kernel CRC consitency testing:\n");
>
>> + for (i = 0; test_data[i].name; i++) {
>> + v = test_data[i].handler(&test_data[i]);
>> + if (v < 0)
>> + err++;
>> + }
>
> ...and correct this to simple
> for (...)
> test_data[i].handler(...);
>
>> + if (err == 0)
>> + pr_info("test_crc: all %d tests passed\n", i);
>> + else
>> + pr_err("test_crc: %d cases tested, %d passed, %d failed\n",
>> + i, i - err, err);
>
> ...and this accordingly.
>
> Note, that in the future someone can add more test cases one or more
> of which could not map 1:1 to i here.
> That's why the rationale to have two global variables for test statistics.
> Also it allows (as you see above) to get rid of return code from all
> of those test. We don't interested in them I believe.
Yes, your code is simpler and more elegant IMHO. I change the code as
you suggested in v4 series.
Thanks.
Coly Li
next prev parent reply other threads:[~2018-07-18 15:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-17 14:55 [PATCH v3 0/3] add crc64 calculation as kernel library Coly Li
2018-07-17 14:55 ` [PATCH v3 1/3] lib: add crc64 calculation routines Coly Li
2018-07-17 15:43 ` Andy Shevchenko
2018-07-18 13:58 ` Coly Li
2018-07-17 16:31 ` Eric Biggers
2018-07-18 14:02 ` Coly Li
2018-07-24 13:33 ` David Laight
2018-07-17 14:55 ` [PATCH v3 2/3] bcache: use routines from lib/crc64.c for CRC64 calculation Coly Li
2018-07-17 15:44 ` Andy Shevchenko
2018-07-17 14:55 ` [PATCH v3 3/3] lib/test_crc: Add test cases for crc calculation Coly Li
2018-07-17 16:57 ` Randy Dunlap
2018-07-18 14:53 ` Coly Li
2018-07-17 17:11 ` Andy Shevchenko
2018-07-18 15:28 ` Coly Li [this message]
2018-07-17 18:51 ` Noah Massey
2018-07-17 20:59 ` Andy Shevchenko
2018-07-18 18:30 ` Noah Massey
2018-07-18 15:28 ` Coly Li
2018-07-17 15:46 ` [PATCH v3 0/3] add crc64 calculation as kernel library Andy Shevchenko
2018-07-19 2:45 ` Coly Li
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=370a51bc-6029-c2df-67b4-22ef906ea62f@suse.de \
--to=colyli@suse.de \
--cc=andy.shevchenko@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kstewart@linuxfoundation.org \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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®