Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6981989imm; Tue, 24 Jul 2018 06:34:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf+23Fx9MQNlF9m+xGIndyhuh3BxSXjvOIhZfUBQb/ngOu0OoYeP4EeQwUVM6UoP5XbrIFj X-Received: by 2002:a62:5047:: with SMTP id e68-v6mr17994976pfb.157.1532439248206; Tue, 24 Jul 2018 06:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532439248; cv=none; d=google.com; s=arc-20160816; b=SsIJORPIrQC6heqmiSLz/szOffvXxL9xhTLgbWVMJUyFwikMYKVfBRQqSyGQc1a/kD bAsXdzIWF6/A1R30rA5aqUUk2C6sdOIqR57dOyQ9czwNrU3mrAY4RJLGqAYaYdLJAEra 7EENHn9krEipCg1UNuC8XXJrjLd7Z+oa5uF4v4PGuaoxnis8qmIjAZwS6LVHsTV2vYmn D2zg8bWtFGMCYgpGsNFnJzS57dqINkU2+bacMp/62bcF327riNT2SBC0wiV3pBaEUp08 iJgc+Dzl0llTmVfcCEC1UlNPPzWdCC0PKwWEel0j0bs7GpNIZS52AgOBxXT50DVTGEnR y6Bg== 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 :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=3+X7CWcoVMTyzNhcJ2BEdb+zF6Wk2KGi6NCv6IXB+D8=; b=IoJZvc7MlXK/Sd69g+I+oV3YwAYcqvoShmp9h/36elQIfb0ObLPXmza813i3u5ENBF DRrcwRDvda2E9SbgETMET+Kxh23nEIjEtKwpE8LKUGeucdHhflaeLVuY2Unus81VZLdE jPwJkT7zJMbq9RC4yZZMQlIOHsEksq0LuFY/+Ee2Isn/QkmUF26zwl23eSTxqQluBbgM RRMtXgFwB7UUTJLryzfT/2zmbIQ8j6NhJmblde5VY5UMFVbOb0m/Ue/FTRKXh3CO5FOG PrijZtXW5mLObDZgsP/Ua9mdZ02KFUvUo6qcok2uPrhosFPDdfkIHAL1yVhiOfDdGMx5 mG3w== 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 t8-v6si10717946ply.139.2018.07.24.06.33.53; Tue, 24 Jul 2018 06:34:08 -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 S2388409AbeGXOiq convert rfc822-to-8bit (ORCPT + 99 others); Tue, 24 Jul 2018 10:38:46 -0400 Received: from eu-smtp-delivery-211.mimecast.com ([207.82.80.211]:21818 "EHLO eu-smtp-delivery-211.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388321AbeGXOip (ORCPT ); Tue, 24 Jul 2018 10:38:45 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-146-LRpw1op3NzGtioWc_5wF_g-1; Tue, 24 Jul 2018 14:32:13 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 24 Jul 2018 14:33:52 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 24 Jul 2018 14:33:52 +0100 From: David Laight To: 'Coly Li' , "linux-kernel@vger.kernel.org" CC: "linux-bcache@vger.kernel.org" , "linux-block@vger.kernel.org" , "Greg Kroah-Hartman" , Andy Shevchenko , Michael Lyle , "Kent Overstreet" , Linus Torvalds , Thomas Gleixner , "Kate Stewart" , Eric Biggers Subject: RE: [PATCH v3 1/3] lib: add crc64 calculation routines Thread-Topic: [PATCH v3 1/3] lib: add crc64 calculation routines Thread-Index: AQHUHd56Kh2dY2MEf0SFas4KUCk7F6SeZsQg Date: Tue, 24 Jul 2018 13:33:52 +0000 Message-ID: <86570dc992b64bd5a9df0898e10ce643@AcuMS.aculab.com> References: <20180717145525.50852-1-colyli@suse.de> <20180717145525.50852-2-colyli@suse.de> In-Reply-To: <20180717145525.50852-2-colyli@suse.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] MIME-Version: 1.0 X-MC-Unique: LRpw1op3NzGtioWc_5wF_g-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Coly Li > Sent: 17 July 2018 15:55 > > This patch adds the re-write crc64 calculation routines for Linux kernel. > The CRC64 polynomical 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. That seems excessive for a fixed table. No real point doing more than putting a commented out copy of the code with the initialisation data. > - The output of gen_crc64table execution is an array called as lookup > table (a.k.a POLY 0x42f0e1eba9ea369) which contain 256 64bits-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. How long are the buffers being processed? For short buffers a lot of bytes will suffer cache line misses. For longer buffers you'll be displacing 2k of data from the L1 data cache. That could easily have a knock on effect on the surrounding code. You might find that a nibble based loop and lookup table is faster. Or, relying on the linearity of CRCs, separate lookup tables for the high and low nibbles of each byte. So replacing: crc = crc64table[t] ^ (crc << 8); with: crc = crc64table_hi[t >> 4] ^ crc64table_lo[t & 15] ^ (crc << 8); David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)