From patchwork Wed Jun 22 13:23:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 9192931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DFF9F601C0 for ; Wed, 22 Jun 2016 13:34:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D15F528406 for ; Wed, 22 Jun 2016 13:34:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C513F28409; Wed, 22 Jun 2016 13:34:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5D76C28406 for ; Wed, 22 Jun 2016 13:34:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFiGn-0001O8-JJ; Wed, 22 Jun 2016 13:32:41 +0000 Received: from arroyo.ext.ti.com ([198.47.19.12]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFi9f-0006rq-3e for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2016 13:25:20 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id u5MDOwVX024758; Wed, 22 Jun 2016 08:24:58 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5MDOwPF014786; Wed, 22 Jun 2016 08:24:58 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Wed, 22 Jun 2016 08:24:58 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5MDONwE022607; Wed, 22 Jun 2016 08:24:56 -0500 From: Tero Kristo To: , , , , , Subject: [PATCHv2 12/27] crypto: engine: avoid unnecessary context switches Date: Wed, 22 Jun 2016 16:23:45 +0300 Message-ID: <1466601840-18486-13-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466601840-18486-1-git-send-email-t-kristo@ti.com> References: <1466601840-18486-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160622_062519_428202_24C63C8F X-CRM114-Status: UNSURE ( 8.43 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; }