Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2762109imm; Mon, 16 Jul 2018 13:48:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcJjoCR+LlqFGCl+Iw4g35cTNcU5aNg/s+176LWnUmpixtWwjyMTbR1L5/U13+ASRHiAq1O X-Received: by 2002:a63:2404:: with SMTP id k4-v6mr16675111pgk.191.1531774085400; Mon, 16 Jul 2018 13:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531774085; cv=none; d=google.com; s=arc-20160816; b=AOzHTv7sLBHyOevOudYKdnP7ZbfJ3S5t5ozDhiolaOj4/001Ge3VWz7SOER2AqXOYG pyIjvFTJ08Ml9SdbmTiEvCjOVDHU9F8r2Lj2x5Fa5ct8EbVmTgJ0caDP+asZHYNx7MH4 OCPyX9RewIJqm4hOtBbBzBlKruXW6dt7OaSEnFgBxMAyfyp3QgyrasSzUDXo+FiV/ioP ODUw3pSizDwwZMU7eRgcugOBBO+Fxt8kL4ZMBixqTrT/24OAYOnESEO6mJNHB8PODSgI JTzANp8LjsuliygZsMHsM98+Hr6yGxnDyVyYcuxTaTpT2PTXrf8CFnc34AbXJ+9WhNDX KO0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=etkEXwGfXyUJQa+sYW985/GS+26wbrqrTfhHlLeZzlU=; b=vBPhHEZ+LHNRMqavLXfO3MGRy8GqrS/+l1c8Rg1rO5GdipOMGJIgL3Af1PXVO1MFix I+m+YmoADQ0hdqCAgoVrxjPGqkis9NlDu+8FBwIbWkx2GpvANHCt//AzRX/dvzg1ongq Lu8qLfD/5JJwhkPxdAtgCU3/L2Ty8YsHDj2+gdE+tmNMxf1ACdY9t7afVBc8EOxlPLcG X42QSxM86TQv9pHKVlConM4P0z69En4mjQrW42h5cfRDKv7d7RmlfgtpFOe8Kns+ZHi+ F4J+sImyLZ9PgfrFMiZeP8CdsWAeUtFz8S0b7mg895jDM6C40Xe0XMo5VgG9jeXSr7hj m1OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SMKxML5f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4-v6si21053506pgg.537.2018.07.16.13.47.50; Mon, 16 Jul 2018 13:48:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SMKxML5f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729778AbeGPVQW (ORCPT + 99 others); Mon, 16 Jul 2018 17:16:22 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:33319 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728413AbeGPVQW (ORCPT ); Mon, 16 Jul 2018 17:16:22 -0400 Received: by mail-vk0-f68.google.com with SMTP id y70-v6so20091214vkc.0; Mon, 16 Jul 2018 13:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=etkEXwGfXyUJQa+sYW985/GS+26wbrqrTfhHlLeZzlU=; b=SMKxML5fwDle0VbDSeVOkxwWGKQablH/tgkPs6ns2ENPvrg4zfWBV9EF/nOQ1yHOII mJGUCBG8LDoZLvGwsyE4ax2AELEvVTvxXwqujOmNNT5D3yW74zNx5XHGk9jgEEjStZEn iXfecMav+eWgcogaBXXPkbrS1Igqpgq4kvgaDMkDmzZrmq/TyupFrt+gMnU45YpM2NcO ZEmgdjKiznH/USjyqL0+x7NDTwLpOs70T/irfOZ0Qol7UIHLBanwJNkaWP1dKeJD7RN2 KT0fyglhbFYkV4k3H/nPyhs+KhrBIbew9eMRu//dF/5Z5e/VRIp4ow4sOEZyMWt14VCM HvMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=etkEXwGfXyUJQa+sYW985/GS+26wbrqrTfhHlLeZzlU=; b=MiioyBBfCbjzTBKk+cR7psT7+pELstkL4UjFFa+1uJUmTtmprK7T/cGBnHIvOVr0i4 8vpibAj9xqPemYwQx428HWcxwUxLki0krCLHSRhpNfsA321KE+l0+8Mjb0ZeIqOOglKl 0iSwcbCBue6rwcGkdodTNV5cAEMEtubp4xsOX0tu3x7Xe9Tx9sduXMEASZGxwHP1x83d 4Gckm7pt1rMcSwhaQmEAO0d8FO+fLoNQAHNj7PpIlo3Z2V2nssbmI7aPnYcsfv3PjaeY bBkmEmksEWmVIjl0MISPf7+4rFZg7giBl3yt63vHM0537ZivXDTmcRisUdZMSlQc0uFQ KW6w== X-Gm-Message-State: AOUpUlF6X1yNRb/6MupSiLd0mbzmnL98TM51/0TZdJVPSb2oQ5aBCLQT nRq2vr43qS74gGWgdmvCeo2mQlKsGyg0k3P9sKeROCKx X-Received: by 2002:a1f:50c:: with SMTP id 12-v6mr10318562vkf.26.1531774034622; Mon, 16 Jul 2018 13:47:14 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:2149:0:0:0:0:0 with HTTP; Mon, 16 Jul 2018 13:47:14 -0700 (PDT) In-Reply-To: <20180716165507.23100-5-colyli@suse.de> References: <20180716165507.23100-1-colyli@suse.de> <20180716165507.23100-5-colyli@suse.de> From: Andy Shevchenko Date: Mon, 16 Jul 2018 23:47:14 +0300 Message-ID: Subject: Re: [PATCH 4/4] lib/test_crc: Add test cases for crc calculation To: Coly Li Cc: Linux Kernel Mailing List , linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, Greg Kroah-Hartman , "Luis R . Rodriguez" , Linus Torvalds , Thomas Gleixner , Kate Stewart Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 16, 2018 at 7:55 PM, Coly Li 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_le: PASSED (0x4e6b> + 1ff972fa8c55, expval 0x4e6b1ff972fa8c55) > test_crc: crc64_le_bch: PASSED (0x0e4f1391d7a4a62e, expval 0x0e4f1391d7a4a62e) > test_crc: crc64_le_update: FAILED (0x03d4d0d85685d9a1, expval 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 can is a testing frame work for all crc consistency > testings. For now, there are only test caes for 3 crc routines, > - crc64_le() > - crc64_le_bch() > - crc64_le_update() > +config TEST_CRC > + tristate "CRC calculation test driver" > + default n Default default is n. > + depends on CRC64 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include Perhaps in order? Moreover, either init.h or module.h depending on the Kconfig (here seems module.h is a right choice). > +struct crc_test_record { > + Redundant. > + char *name; > + __le64 data[4]; > + __le64 initval; > + __le64 expval; > + int (*handler)(struct crc_test_record *rec); > +}; > + > +static int chk_and_msg(const char *name, __le64 crc, __le64 expval) > +{ > + int ret = 0; > + > + if (crc == expval) { > + pr_info("test_crc: %s: PASSED:(0x%016llx, expval 0x%016llx)", > + name, crc, expval); > + } else { > + pr_err("test_crc: %s: FAILED:(0x%016llx, expval 0x%016llx)", > + name, crc, expval); > + ret = -EINVAL; > + } > + > + return ret; Perhaps collect statistics instead how it's done in many other tests? > +} > + > +/* Add your crc test caese here */ caese ? > +static int test_crc64_le(struct crc_test_record *rec) > +{ > + __le64 crc; > + > + crc = crc64_le(rec->data, sizeof(rec->data)); > + return chk_and_msg(rec->name, crc, rec->expval); > + Redundant. > +} > + { .name = NULL, } Simple {} would work. > +static int __init test_crc_init(void) > +{ > + int i; > + int v, ret = 0; > + > + pr_info("Kernel crc consitency testing:"); > + for (i = 0; test_data[i].name; i++) { > + v = test_data[i].handler(&test_data[i]); > + if (v < 0 && ret == 0) > + ret = -EINVAL; A bit strange. Anyway, better to collect statistics and print it at the end with corresponding return code. > + } > + > + return ret; > +} > +late_initcall(test_crc_init); Why? > +static void __exit test_crc_exit(void) { } > +module_exit(test_crc_exit); > +MODULE_LICENSE("GPL"); It's not the same as in SPDX. -- With Best Regards, Andy Shevchenko