From patchwork Wed Jun 1 08:56:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 68995 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2409985qge; Wed, 1 Jun 2016 01:58:37 -0700 (PDT) X-Received: by 10.107.57.7 with SMTP id g7mr3994937ioa.194.1464771501055; Wed, 01 Jun 2016 01:58:21 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zh6si17235978pab.23.2016.06.01.01.58.20 for ; Wed, 01 Jun 2016 01:58:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757603AbcFAI6S (ORCPT ); Wed, 1 Jun 2016 04:58:18 -0400 Received: from arroyo.ext.ti.com ([198.47.19.12]:50767 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757537AbcFAI6Q (ORCPT ); Wed, 1 Jun 2016 04:58:16 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id u518vR4d005308; Wed, 1 Jun 2016 03:57:27 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u518vRdg020530; Wed, 1 Jun 2016 03:57:27 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Wed, 1 Jun 2016 03:57:26 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u518ug0c002676; Wed, 1 Jun 2016 03:57:22 -0500 From: Tero Kristo To: , , , , CC: , , Tero Kristo Subject: [PATCH 13/28] crypto: engine: avoid unnecessary context switches Date: Wed, 1 Jun 2016 11:56:14 +0300 Message-ID: <1464771389-10640-14-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464771389-10640-1-git-send-email-t-kristo@ti.com> References: <1464771389-10640-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Crypto engine will now hi-jack the currently running thread for executing crypto functionality. Only if we are not running a thread (in interrupt context) the kthread will be scheduled. This will improve performance of crypto operations using crypto engine. Signed-off-by: Tero Kristo --- crypto/crypto_engine.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index a55c82d..aac5870 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -136,6 +136,14 @@ static void crypto_pump_work(struct kthread_work *work) crypto_pump_requests(engine, true); } +static void queue_pump_work(struct crypto_engine *engine) +{ + if (in_interrupt()) + queue_kthread_work(&engine->kworker, &engine->pump_requests); + else + crypto_pump_requests(engine, true); +} + /** * crypto_transfer_request - transfer the new request into the engine queue * @engine: the hardware engine @@ -156,10 +164,11 @@ int crypto_transfer_request(struct crypto_engine *engine, ret = ablkcipher_enqueue_request(&engine->queue, req); + spin_unlock_irqrestore(&engine->queue_lock, flags); + if (!engine->busy && need_pump) - queue_kthread_work(&engine->kworker, &engine->pump_requests); + queue_pump_work(engine); - spin_unlock_irqrestore(&engine->queue_lock, flags); return ret; } EXPORT_SYMBOL_GPL(crypto_transfer_request); @@ -210,7 +219,7 @@ void crypto_finalize_request(struct crypto_engine *engine, req->base.complete(&req->base, err); - queue_kthread_work(&engine->kworker, &engine->pump_requests); + queue_pump_work(engine); } EXPORT_SYMBOL_GPL(crypto_finalize_request); @@ -234,7 +243,7 @@ int crypto_engine_start(struct crypto_engine *engine) engine->running = true; spin_unlock_irqrestore(&engine->queue_lock, flags); - queue_kthread_work(&engine->kworker, &engine->pump_requests); + queue_pump_work(engine); return 0; }