Received: by 10.223.176.46 with SMTP id f43csp223737wra; Thu, 18 Jan 2018 16:28:54 -0800 (PST) X-Google-Smtp-Source: ACJfBouV8CILDkPpTS8tz4pfHcLuPOesfrcCbSkglrYY5XTQYDqYH1vkfjyvdk27GNhP0l6tmzoU X-Received: by 10.101.67.65 with SMTP id k1mr16295050pgq.159.1516321734440; Thu, 18 Jan 2018 16:28:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516321734; cv=none; d=google.com; s=arc-20160816; b=SkWPQymETWq/9vFhb+Kv5jqjOsEoXOOCm1gMzw/jaMU/+fqoaClpjytNly70Bmkpwi ZD2Vfo5fp5AiKzMWfoH/n/1vrAuKdkHz+goKeUsGpR6k3tSu37ZkqZRYsb35V4SwMtO2 bS+TYWrep+1swW9Ps2RwXCdoBsHbYIjBWCt9IveiFQJAcpMLKfvClofGogG6fqg0qWiz oAyQUX7rFYEszQeZ9FZaYrreMEs/y0oVPYWVAU+fW7gJSjpZaXEXa+Pqun+93DsioJPH VCSh4eq45H44BInabespDpHbjZyGYQRB/bsVM1pR1AHF2ZF0GLu1F3DTK6ULRh6wW3+s Uzlw== 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:date:cc:to:from:subject:message-id :arc-authentication-results; bh=jGNtH2Enjacrhc+NhIwQhsYKJDQIu8LPRwdYvgEadZA=; b=m5Y0OPQ1t5eM12A005/mMrp/e6brJF5H6khikErR6JCCM/M2lsHDNUW56Sz4+I12dq 79dA9+bdPV1lsuehH4UGHUH63T3MZfjfIcns5De+bx/rb5OHfhLW6hFI8eAWstVO0D5C FALhPQqiB3zfh5WDUGZW+FZ7zWbVrN37tGqfCv6x2tlxCXzarJN8O9v3RxtSoFlgscBd PHE9p/Bb/8EyYogWQg7DzAPipR5MeJROPcRkpdhq+SA97R6iU9pTubjDo8+j+cFpMioK 8gVODAzT0MPOL8OHsFJtnY92WkSnopOFQuJn+9raFehejU+9YtJqdxBrl02hDpYXjbHH qJog== 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 t5si7039057pgc.788.2018.01.18.16.28.41; Thu, 18 Jan 2018 16:28:54 -0800 (PST) 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 S1754957AbeASA2I (ORCPT + 99 others); Thu, 18 Jan 2018 19:28:08 -0500 Received: from mga02.intel.com ([134.134.136.20]:42224 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750762AbeASA16 (ORCPT ); Thu, 18 Jan 2018 19:27:58 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 16:27:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,379,1511856000"; d="scan'208";a="11374480" Received: from megha-z97x-ud7-th.sc.intel.com (HELO [143.183.85.162]) ([143.183.85.162]) by fmsmga007.fm.intel.com with ESMTP; 18 Jan 2018 16:27:57 -0800 Message-ID: <1516322661.2526.3.camel@megha-Z97X-UD7-TH> Subject: Re: [PATCH V8 1/5] crypto: Multi-buffer encryption infrastructure support From: Megha Dey To: Herbert Xu Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, davem@davemloft.net Date: Thu, 18 Jan 2018 16:44:21 -0800 In-Reply-To: <20180118113905.GA19904@gondor.apana.org.au> References: <1515542948-24041-1-git-send-email-megha.dey@linux.intel.com> <1515542948-24041-2-git-send-email-megha.dey@linux.intel.com> <20180118113905.GA19904@gondor.apana.org.au> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 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, 2018-01-18 at 22:39 +1100, Herbert Xu wrote: > On Tue, Jan 09, 2018 at 04:09:04PM -0800, Megha Dey wrote: > > > > +static void mcryptd_skcipher_encrypt(struct crypto_async_request *base, > > + int err) > > +{ > > + struct skcipher_request *req = skcipher_request_cast(base); > > + struct mcryptd_skcipher_request_ctx *rctx = skcipher_request_ctx(req); > > + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); > > + struct mcryptd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm); > > + struct crypto_skcipher *child = ctx->child; > > + struct skcipher_request subreq; > > + > > + if (unlikely(err == -EINPROGRESS)) > > + goto out; > > + > > + /* set up the skcipher request to work on */ > > + skcipher_request_set_tfm(&subreq, child); > > + skcipher_request_set_callback(&subreq, > > + CRYPTO_TFM_REQ_MAY_SLEEP, 0, 0); > > + skcipher_request_set_crypt(&subreq, req->src, req->dst, > > + req->cryptlen, req->iv); > > + > > + /* > > + * pass addr of descriptor stored in the request context > > + * so that the callee can get to the request context > > + */ > > + rctx->desc = subreq; > > + err = crypto_skcipher_encrypt(&rctx->desc); > > + > > + if (err) { > > + req->base.complete = rctx->complete; > > + goto out; > > + } > > + return; > > + > > +out: > > + mcryptd_skcipher_complete(req, err); > > +} > > OK this looks better but it's still abusing the crypto API interface. > In particular, you're sharing data with the underlying algorithm > behind the crypto API's back. Also, the underlying algorithm does > callback completion behind the API's back through the shared data > context. > > It seems to me that the current mcryptd scheme is flawed. You > want to batch multiple requests and yet this isn't actually being > done by mcryptd at all. The actual batching happens at the very > lowest level, i.e., in the crypto algorithm below mcryptd. For > example, with your patch, the batching appears to happen in > aes_cbc_job_mgr_submit. > > So the mcryptd template is in fact completely superfluous. You > can remove it and just have all the main encrypt/decrypt functions > invoke the underlying encrypt/decrypt function directly and achieve > the same result. > > Am I missing something? Hi Herbert, After discussing with Tim, it seems like the mcryptd is responsible for queuing up the encrypt requests and dispatching them to the actual multi-buffer raw algorithm. It also flushes the queue if we wait too long without new requests coming in to force dispatch of the requests in queue. Its function is analogous to cryptd but it has its own multi-lane twists so we haven't reused the cryptd interface. > > Cheers,