Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3646103imm; Fri, 24 Aug 2018 23:14:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ3kLyptRLZA97I0vy7YKrojlwAeFIRKWtvTFZIv+vADUzLiPI/Y7ocbsUFGJf3q/2/Jesf X-Received: by 2002:a63:d443:: with SMTP id i3-v6mr4458724pgj.216.1535177672953; Fri, 24 Aug 2018 23:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535177672; cv=none; d=google.com; s=arc-20160816; b=AbUAw6GLoOvjKQ+aIx/0sMcWYWAs0jf/nUVrKxeNUcB9MqxGHJ39K6yCll9jzIog/w QCjP+cndJBL21J0OyUFZ1sD6ENTZ/TY24xc239lIMe0bvTY1kLgsui+5YKQPp/i2Xxio Ag69ncuRz3j3BshqAj4VD7V7zFdM7ENuCbiIczbPgfNx84NxSoLYMaCt+Nx9JziIWivU UfEaITenaJYOWEusQFPf+Ke7z/amE2Il4zdECkGI53kqx819h/X5UN/DuTwzxlKGRJev ehLdIZdSLqzytywJCWjkzY7FWE+weU4IWEpBUo/U2+2m1CVQLvS1gsyJZ+/bQzw+3Vwb oQGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=FNOBsVCgffdO1JCz4fZA6vHXquRoGK6hkTzN+XEk//U=; b=tVi+OyiSH3j5UOuJ6n765a4GMzk0E4LQnOfrxpHVZyaWkBgliOQp6Scmyjrlldjy5I UeqBQOv085VjEftO9GD0Swr3aNBwsuw31HuV6SD6uB8IDUtzZDScWtns0TWA0P5Utl8y q1HIJjXkd4bl955bSr5qfKViRpqtnIenrYFJW0Z9xlfItBTlF+1r4a+QmUtdIIZXpAql r5OO7bvCOxkV1BHxFDYf0mJIvUJmpYYfly5NGnQ073JXSIW8a43mv6/b2XdVQomFVQvL y650G9u85oIAVQPn8LUUevWhot/0iH0WITDE0GhvKXaXbjnQb8iWyZfplK2FcdTIbb62 HDbQ== 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 s17-v6si8807401pgi.284.2018.08.24.23.14.03; Fri, 24 Aug 2018 23:14:32 -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 S1726694AbeHYJuI (ORCPT + 99 others); Sat, 25 Aug 2018 05:50:08 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:47050 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbeHYJuI (ORCPT ); Sat, 25 Aug 2018 05:50:08 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1ftRnw-0005y1-2F; Sat, 25 Aug 2018 14:12:12 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1ftRnp-0002vD-HM; Sat, 25 Aug 2018 14:12:05 +0800 Date: Sat, 25 Aug 2018 14:12:05 +0800 From: Herbert Xu To: "Martin K. Petersen" Cc: Ard Biesheuvel , Jeffrey Lien , Christoph Hellwig , "linux-kernel@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "tim.c.chen@linux.intel.com" , David Darrington , Jeff Furlong Subject: Re: [PATCH] Performance Improvement in CRC16 Calculations. Message-ID: <20180825061205.ygrjjazkooqghrqy@gondor.apana.org.au> References: <1533928331-21303-1-git-send-email-jeff.lien@wdc.com> <20180822062016.GA10356@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 24, 2018 at 05:46:15PM -0400, Martin K. Petersen wrote: > > +#ifdef CONFIG_MODULES > + struct module *mod = data; > + > + if (val != MODULE_STATE_LIVE || > + strncmp(mod->name, "crct10dif", strlen("crct10dif"))) > + return 0; > + > + /* Fall back to library function while we replace the tfm */ > + static_key_slow_inc(&crct10dif_fallback); > + > + crypto_free_shash(crct10dif_tfm); > + crct10dif_tfm = crypto_alloc_shash("crct10dif", 0, 0); > + if (IS_ERR(crct10dif_tfm)) { > + crct10dif_tfm = NULL; > + goto out; > + } > + > + static_key_slow_dec(&crct10dif_fallback); I don't think this is safe unless you do some kind of locking which would slow down the data path. The easiest fix would be to keep the old tfm around forever, or use RCU if RCU read locking is acceptable to your use-case. We already have a notifier mechanism in the crypto API for algorithm registration events. However, it currently only notifies for untested algorithms. So we need to add an event for tested algorithms and also export this for use outside of the crypto API. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt