Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp17369imm; Thu, 26 Jul 2018 13:03:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcVnWgFUfrAL1eD0UJpGBgMZtrxwVpexolFpa3BVwUMufdJbotmHe3upCpltnIeGZ4WdclM X-Received: by 2002:a62:2f84:: with SMTP id v126-v6mr3500098pfv.115.1532635405849; Thu, 26 Jul 2018 13:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532635405; cv=none; d=google.com; s=arc-20160816; b=F3VSdmMmEb+F8cWQFHhuzevNVBdZUIhTEFh3WsR01dHYQmqWnsDgy1KCr5ZAeD5uO7 JEaOajrFIgrqDnBSFYeeHiFVno9D3BZ3xyjnQ3DSbEm4O43peFKoH17iyXuwpoa94V6Q h9OJd7jxogVL6kf96CUVjXUKsytIaax2nn1PCVmG74vZ/3w5KTJNGbc++o/Uu6Qnw2rB JmY2jzvl5avk2q14hBwH+2lcwkf0Goik7SJsUcAUjzPPNTl6DXFlQBUElsI6Bcc57vE5 O/09jMPvfW5ebCdTh4RaORHTMpinaF5OZKC8mors+G7yl6K+ffKXoY2wbOOcLShu4hFB hblg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=pHF4/Rk412QMJU0anfdNOdZabtviCFs4zxIjiRTQ2nY=; b=R+H6A05s9Jsq0sYJ6DGDBj/5QX6S9dTyiPd0GmOy/g7bM2O3Y7MO5fJpcWGlKil5Kw POEGmOMf0OT3f9T32IYhp2rbyiV8DdhZUjaml3I8zZyg1IEpPqIaoDGUeI8GN8IngRI0 TVGTM+EEUPkbJ6/+cxoKjTTCVO2i6pkMx02zzzV6v+IWvPaDiQPc9gAqfQgOFwAG0Bj/ mqQOPc8ARNisOLbp+rVbA0ZnXb2hCb0bQ27zKMARgHexaDL99fVSzikikeRH2+bnb3Oh 1jiV2L+F9ewyXlRfwxGeAJOke+1tcKSjC7o0E/UurMeuFcMzpZV+/VgnmL6sLyZE/3sj +Uag== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z137-v6si2078451pgz.144.2018.07.26.13.03.02; Thu, 26 Jul 2018 13:03:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731585AbeGZVUg (ORCPT + 99 others); Thu, 26 Jul 2018 17:20:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42086 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730701AbeGZVUg (ORCPT ); Thu, 26 Jul 2018 17:20:36 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.92]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 395DED1E; Thu, 26 Jul 2018 20:02:11 +0000 (UTC) Date: Thu, 26 Jul 2018 13:02:10 -0700 From: Andrew Morton To: Coly Li Cc: linux-kernel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , Michael Lyle , Kent Overstreet , Linus Torvalds , Thomas Gleixner , Kate Stewart , Eric Biggers , Randy Dunlap Subject: Re: [PATCH v5 1/2] lib: add crc64 calculation routines Message-Id: <20180726130210.97450a74c164a02d7cfd79c1@linux-foundation.org> In-Reply-To: <20180726053352.2781-2-colyli@suse.de> References: <20180726053352.2781-1-colyli@suse.de> <20180726053352.2781-2-colyli@suse.de> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Jul 2018 13:33:51 +0800 Coly Li wrote: > This patch adds the re-write crc64 calculation routines for Linux kernel. > The CRC64 polynomial arithmetic follows ECMA-182 specification, inspired > by CRC paper of Dr. Ross N. Williams > (see http://www.ross.net/crc/download/crc_v3.txt) and other public domain > implementations. > > All the changes work in this way, > - When Linux kernel is built, host program lib/gen_crc64table.c will be > compiled to lib/gen_crc64table and executed. > - The output of gen_crc64table execution is an array called as lookup > table (a.k.a POLY 0x42f0e1eba9ea369) which contain 256 64-bit long > numbers, this talbe is dumped into header file lib/crc64table.h. > - Then the header file is included by lib/crc64.c for normal 64bit crc > calculation. > - Function declaration of the crc64 calculation routines is placed in > include/linux/crc64.h > > Currently bcache is the only user of crc64_be(), another potential user > is bcachefs which is on the way to be in mainline kernel. Therefore it > makes sense to move crc64 calculation into lib/crc64.c as public code. delta from v4: --- a/include/linux/crc64.h~lib-add-crc64-calculation-routines-v5 +++ a/include/linux/crc64.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * See lib/crc64.c for the related specification and polynomical arithmetic. + * See lib/crc64.c for the related specification and polynomial arithmetic. */ #ifndef _LINUX_CRC64_H #define _LINUX_CRC64_H --- a/lib/crc64.c~lib-add-crc64-calculation-routines-v5 +++ a/lib/crc64.c @@ -12,7 +12,7 @@ * from, * http://www.ross.net/crc/download/crc_v3.txt * - * crc64table[256] is the lookup table of a table-driver 64-bit CRC + * crc64table[256] is the lookup table of a table-driven 64-bit CRC * calculation, which is generated by gen_crc64table.c in kernel build * time. The polynomial of crc64 arithmetic is from ECMA-182 specification * as well, which is defined as, @@ -35,8 +35,8 @@ MODULE_LICENSE("GPL v2"); /** * crc64_be - Calculate bitwise big-endian ECMA-182 CRC64 - * @crc: seed value for computation. 0 for a new CRC computing, or the - * previous crc64 value if computing incrementally. + * @crc: seed value for computation. 0 or (u64)~0 for a new CRC calculation, + or the previous crc64 value if computing incrementally. * @p: pointer to buffer over which CRC64 is run * @len: length of buffer @p */ --- a/lib/gen_crc64table.c~lib-add-crc64-calculation-routines-v5 +++ a/lib/gen_crc64table.c @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Generate lookup table for the talbe-driven CRC64 calculation. + * Generate lookup table for the table-driven CRC64 calculation. * * gen_crc64table is executed in kernel build time and generates * lib/crc64table.h. This header is included by lib/crc64.c for - * the table-driver CRC64 calculation. + * the table-driven CRC64 calculation. * * See lib/crc64.c for more information about which specification - * and polynomical arithmetic that gen_crc64table.c follows to + * and polynomial arithmetic that gen_crc64table.c follows to * generate the lookup table. * * Copyright 2018 SUSE Linux. @@ -20,7 +20,7 @@ #define CRC64_ECMA182_POLY 0x42F0E1EBA9EA3693ULL -static int64_t crc64_table[256] = {0}; +static uint64_t crc64_table[256] = {0}; static void generate_crc64_table(void) {