public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Bob Pearson <rpearson@systemfabricworks.com>
Cc: linux-kernel@vger.kernel.org, fzago@systemfabricworks.com,
	Joakim Tjernlund <joakim.tjernlund@transmode.se>,
	George Spelvin <linux@horizon.com>
Subject: Re: [PATCH v6 03/10] crc32-replace-self-test.diff
Date: Fri, 2 Sep 2011 16:51:38 -0700	[thread overview]
Message-ID: <20110902165138.927100ce.akpm@linux-foundation.org> (raw)
In-Reply-To: <4E5EB5E6.3040202@systemfabricworks.com>

On Wed, 31 Aug 2011 17:29:58 -0500
Bob Pearson <rpearson@systemfabricworks.com> wrote:

> Replaced the unit test provided in crc32.c, which doesn't have a
> makefile and doesn't compile with current headers, with a simpler
> self test routine that also gives a measure of performance and
> runs at module init time. The self test option can be enabled
> through a configuration option CONFIG_CRC32_SELFTEST.
> 
> The test stresses the pre and post loops and is thus not very
> realistic since actual uses will likely have addresses and lengths
> that are at least 4 byte aligned. However, the main loop is long
> enough so that the performance is dominated by that loop.
> 
> The expected values for crc32_le and crc32_be were generated
> with the original version of crc32.c using CRC_BITS_LE = 8 and
> CRC_BITS_BE = 8. These values were then used to check all the
> values of the BITS parameters in both the original and new versions.
> 
> The performance results show some variability from run to run
> in spite of attempts to both warm the cache and reduce the amount
> of OS noise by limiting interrutps during the test. To get comparable
> results and to analyse options wrt performance the best time
> reported over a small sample of runs has been taken.
> 

I don't object to a self-test which actually works, but it seems pretty
lame that the self-test exists in kernel mode when it is so simple to
prepare a much more useful and powerful correctness/performance test
harness in userspace.

> ...
>
> -static u32 test_step(u32 init, unsigned char *buf, size_t len)
> -{
> -	u32 crc1, crc2;
> -	size_t i;
> +		crc ^= crc32_be(test[i].crc, test_buf +
> +		    test[i].start, test[i].length);
> +	}
>  
> -	crc1 = crc32_be(init, buf, len);
> -	store_be(crc1, buf + len);
> -	crc2 = crc32_be(init, buf, len + 4);
> -	if (crc2)
> -		printf("\nCRC cancellation fail: 0x%08x should be 0\n",
> -		       crc2);
> -
> -	for (i = 0; i <= len + 4; i++) {
> -		crc2 = crc32_be(init, buf, i);
> -		crc2 = crc32_be(crc2, buf + i, len + 4 - i);
> -		if (crc2)
> -			printf("\nCRC split fail: 0x%08x\n", crc2);
> +	/* reduce OS noise */

This comment is useless.

> +	local_irq_save(flags);
> +	local_irq_disable();

local_irq_save() already does local_irq_disable().

local_irq_disable() doesn't protect against actions of other CPUs.  I'd
know if this was a bug if the comment wasn't useless :)

> +	getnstimeofday(&start);
> +	for (i = 0; i < 100; i++) {
> +		if (test[i].crc_le != crc32_le(test[i].crc, test_buf +
> +		    test[i].start, test[i].length))
> +			errors++;
> +
> +		if (test[i].crc_be != crc32_be(test[i].crc, test_buf +
> +		    test[i].start, test[i].length))
> +			errors++;
>  	}
> ...

  reply	other threads:[~2011-09-02 23:51 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110831213729.395283830@systemfabricworks.com>
2011-08-31 22:29 ` [PATCH v6 01/10] crc32-remove-trailing-whitespace.diff Bob Pearson
2011-08-31 22:29 ` [PATCH v6 02/10] crc32-move-to-documentation.diff Bob Pearson
2011-08-31 22:29 ` [PATCH v6 03/10] crc32-replace-self-test.diff Bob Pearson
2011-09-02 23:51   ` Andrew Morton [this message]
2011-09-06 16:14     ` Bob Pearson
2011-08-31 22:30 ` [PATCH v6 04/10] crc32-add-pointer-to-tab.diff Bob Pearson
2011-09-01  8:16   ` Joakim Tjernlund
2011-08-31 22:30 ` [PATCH v6 05/10] crc32-misc-cleanup.diff Bob Pearson
2011-09-02 23:50   ` Andrew Morton
2011-09-03  1:44     ` Stephen Rothwell
2011-09-06 13:40       ` Joakim Tjernlund
2011-09-06 14:50         ` Stephen Rothwell
2011-09-06 19:38           ` Andrew Morton
2011-09-06 20:18             ` Bob Pearson
2011-09-07  7:39               ` Joakim Tjernlund
2011-09-07 16:30             ` Bob Pearson
2011-09-07 17:51               ` Joakim Tjernlund
2011-09-06 16:05     ` Bob Pearson
2011-08-31 22:30 ` [PATCH v6 06/10] crc32-fix-check-endian-warnings.diff Bob Pearson
2011-08-31 22:30 ` [PATCH v6 07/10] crc32-add-real-8-bit.diff Bob Pearson
2011-08-31 22:30 ` [PATCH v6 08/10] crc32-add-slicing-by-8.diff Bob Pearson
2011-09-07  7:31   ` Joakim Tjernlund
2011-09-07 19:44     ` Bob Pearson
     [not found]   ` <OF3D37A60B.7A33B855-ONC1257904.00276B5B-C1257904.002951AF@LocalDomain>
2011-09-07  8:30     ` Joakim Tjernlund
2011-08-31 22:30 ` [PATCH v6 09/10] crc32-optimize-loops-for-x86.diff Bob Pearson
2011-08-31 22:30 ` [PATCH v6 10/10] crc32-final.diff Bob Pearson
2011-09-01  3:03 ` [PATCH v6 08/10] crc32-add-slicing-by-8.diff Bob Pearson
2011-09-07  7:32   ` Joakim Tjernlund

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=20110902165138.927100ce.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=fzago@systemfabricworks.com \
    --cc=joakim.tjernlund@transmode.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    --cc=rpearson@systemfabricworks.com \
    /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