Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3785641imm; Tue, 17 Jul 2018 10:12:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpewf0YMifXVGvnz97Psiy+DBRy9Yp5Tt0CylNRLcePvISAQOOyY1fOiMJFefNyEoXDN8PdE X-Received: by 2002:a65:594b:: with SMTP id g11-v6mr2444005pgu.260.1531847566062; Tue, 17 Jul 2018 10:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531847566; cv=none; d=google.com; s=arc-20160816; b=Rrq8zVJSknC7vprWseJ+HcjVX/vP4HPfY1kbj+QvkKKPeXddecTemiXG6YeP7zpsbq LCg/BcRu+F7ZSHgtx10S9wabeSKv7uQxEZQvVaA3WAL2VmMcQAQ9X+rvjYk8dbBwHxmm SWXUOjxLGdJQHJhQUYT/Y1rtjKMn/IHSr5e2lG8f0n1v9BB1qrhkqG4Eh1Gx26+e3lzs k+n6JZmkxGocxvMbg6DWz8hspRP6gVi+3k4EtA6BgqejcvRUGNhxhyL59vY3PZLolT6Z C0Bx8vNd9B4hucUiIwaLZyDsNg0JtSQ8axej8A8cDJdNwT3Nn3yuYFeuYRtxS6fInaoa uC7A== 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=RsqQ7ZdcR1E6QV9d8XKRn8KzhUfdTvA66gHft7FhVKI=; b=R0ijr34tJhoq7F3QfVb3dgWkkUvZycXoLhz4O1dlrPRU0z5hp/+z8mVr7VEzA+KsXX i18cssGxqoBgn3KpxLTFqI7EvZZ5xLVO//xhM6DLfMDn4oNE+bfRFd/UTfWtL+DCcTRC LUDrJuI5uiKnLF828eEkSvVUEV9XzLzRHJOjyBcPupaHiiuPdtHtnY3sWjDPtZtMa2sb ZcIF3Jg3EDDy6niERvfirxFRo7guw/od7OGU/jw8RFlH3eZgUet+Kv8Nkn7tGlp0l39B Yf2xXVoDL5jySTdY3Kv66xvT7MJAn0Skbuu7IX1Nmw1bcztXI42G+MVxEe2j0urQt5Qm 100w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IyNv7yUp; 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 k2-v6si1403867pfh.252.2018.07.17.10.12.30; Tue, 17 Jul 2018 10:12:46 -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=IyNv7yUp; 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 S1730798AbeGQRp2 (ORCPT + 99 others); Tue, 17 Jul 2018 13:45:28 -0400 Received: from mail-ua0-f195.google.com ([209.85.217.195]:45293 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729665AbeGQRp1 (ORCPT ); Tue, 17 Jul 2018 13:45:27 -0400 Received: by mail-ua0-f195.google.com with SMTP id k8-v6so1141855uaq.12; Tue, 17 Jul 2018 10:11:50 -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=RsqQ7ZdcR1E6QV9d8XKRn8KzhUfdTvA66gHft7FhVKI=; b=IyNv7yUpJsuCfZZykHm5/V+HfGlIZ3WQNR/UID/P2J7QA9vLKdHKhZ/E4VFwRy+R9Q 4aY/GEZlboq8wk8o4hzMOk30MyyLNz1Y/71w0Gke6q+62hsG9Y1O+G/8T7DbucKmzxNc S+8MEZvElMuTZioQaHSEaeqmsUQfT3EDkC64Iv6/sbX8vlndYo0nWQrRUIz3Nujt05Yp 8iJ0ye2WJOT3CopbhUlEYMQT768r44XEOPi1Nhv1sU+6QlJUmZt1PXdcrU5LXd+Ymn4D 64b3/uMf15J1e8wySxi7tSMllfp/YaKkPQWmwX2B0wGVImk2qiGhiwxxzZIZaBS6oaFV i8Uw== 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=RsqQ7ZdcR1E6QV9d8XKRn8KzhUfdTvA66gHft7FhVKI=; b=YeSyySyP/OWM+70DsHpaWYfuBKVo8iizyUeDyS5otjvBAmXjHU83aVr2RbwBjQwNFR cRQB00m0ieaxI9+Qg+ykoBDXaH0TxOCLRVrhyeciRIMWIhjJ8RDVln6UUQBHkcmSp7aH EpjhmxKXGGU/nenJuUc2APra/hBey+l3fN/uAVKGWo9YLd2MBQ4l+37g15LPsSP+Ie0L 0zqvcnP4QkxZw1FZMocWtqBtCE56yiMLHoKCE2bO9bPI2DMuyZaXu5PpdkenU+Lwp83U tbag2h8KCvng5mR+Eb2iNFoOyoqlurlzvdzgQVgW/+bt1PdNi32ctY38X//i4rXNn5wT geZw== X-Gm-Message-State: AOUpUlE4lyrFHD7YRJ3Y+BgVdREehg3M04KVJPJUCf7k1qND53TxRi4b s1/snwTRIYTEjtrKha7p0GPE1f6QTHNteB6S0iBn8leu X-Received: by 2002:ab0:4c24:: with SMTP id l36-v6mr1588425uaf.199.1531847509736; Tue, 17 Jul 2018 10:11:49 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:2149:0:0:0:0:0 with HTTP; Tue, 17 Jul 2018 10:11:49 -0700 (PDT) In-Reply-To: <20180717145525.50852-4-colyli@suse.de> References: <20180717145525.50852-1-colyli@suse.de> <20180717145525.50852-4-colyli@suse.de> From: Andy Shevchenko Date: Tue, 17 Jul 2018 20:11:49 +0300 Message-ID: Subject: Re: [PATCH v3 3/3] 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 , 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 Tue, Jul 17, 2018 at 5: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: 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. > Signed-off-by: Coly Li > Reviewed-by: Hannes Reinecke > Cc: Greg Kroah-Hartman > Cc: Linus Torvalds > Cc: Thomas Gleixner > Cc: Kate Stewart Please, Cc me as well this one in next version (use my Intel address). > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include Do we need all of them? > +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. > + > + return (err == 0) ? 0 : -EINVAL; > +} -- With Best Regards, Andy Shevchenko