From: Tim Chen <tim.c.chen@linux.intel.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
"H. Peter Anvin" <hpa@zytor.com>,
"David S.Miller" <davem@davemloft.net>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>
Cc: Chandramouli Narayanan <mouli@linux.intel.com>,
Vinodh Gopal <vinodh.gopal@intel.com>,
James Guilford <james.guilford@intel.com>,
Wajdi Feghali <wajdi.k.feghali@intel.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Jussi Kivilinna <jussi.kivilinna@iki.fi>,
Thomas Gleixner <tglx@linutronix.de>,
Tadeusz Struk <tadeusz.struk@intel.com>,
tkhai@yandex.ru, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v5 3/7] crypto: SHA1 multibuffer crypto opportunistic flush
Date: Tue, 22 Jul 2014 15:09:35 -0700 [thread overview]
Message-ID: <1406066975.2970.805.camel@schen9-DESK> (raw)
In-Reply-To: <cover.1406033477.git.tim.c.chen@linux.intel.com>
The crypto daemon can take advantage of available cpu
cycles to flush any unfinished jobs if it is the
only task running on the cpu, and there are no more crypto
jobs to process.
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
crypto/mcryptd.c | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/crypto/mcryptd.c b/crypto/mcryptd.c
index 622d6b4..dbc20d1 100644
--- a/crypto/mcryptd.c
+++ b/crypto/mcryptd.c
@@ -116,9 +116,40 @@ static int mcryptd_enqueue_request(struct mcryptd_queue *queue,
return err;
}
-/* Called in workqueue context, do one real cryption work (via
+/*
+ * Try to opportunisticlly flush the partially completed jobs if
+ * crypto daemon is the only task running.
+ */
+static void mcryptd_opportunistic_flush(void)
+{
+ struct mcryptd_flush_list *flist;
+ struct mcryptd_alg_cstate *cstate;
+
+ flist = per_cpu_ptr(mcryptd_flist, smp_processor_id());
+ while (single_task_running()) {
+ mutex_lock(&flist->lock);
+ if (list_empty(&flist->list)) {
+ mutex_unlock(&flist->lock);
+ return;
+ }
+ cstate = list_entry(flist->list.next,
+ struct mcryptd_alg_cstate, flush_list);
+ if (!cstate->flusher_engaged) {
+ mutex_unlock(&flist->lock);
+ return;
+ }
+ list_del(&cstate->flush_list);
+ cstate->flusher_engaged = false;
+ mutex_unlock(&flist->lock);
+ cstate->alg_state->flusher(cstate);
+ }
+}
+
+/*
+ * Called in workqueue context, do one real cryption work (via
* req->complete) and reschedule itself if there are more work to
- * do. */
+ * do.
+ */
static void mcryptd_queue_worker(struct work_struct *work)
{
struct mcryptd_cpu_queue *cpu_queue;
@@ -144,8 +175,10 @@ static void mcryptd_queue_worker(struct work_struct *work)
preempt_enable();
local_bh_enable();
- if (!req)
+ if (!req) {
+ mcryptd_opportunistic_flush();
return;
+ }
if (backlog)
backlog->complete(backlog, -EINPROGRESS);
--
1.7.11.7
next prev parent reply other threads:[~2014-07-22 22:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1406033477.git.tim.c.chen@linux.intel.com>
2014-07-22 22:09 ` [PATCH v5 0/7] crypto: SHA1 multibuffer implementation Tim Chen
2014-07-22 22:09 ` [PATCH v5 1/7] sched: Add function single_task_running to let a task check if it is the only task running on a cpu Tim Chen
2014-07-22 22:09 ` [PATCH v5 2/7] crypto: SHA1 multibuffer crypto hash infrastructure Tim Chen
2014-07-25 7:08 ` Peter Zijlstra
2014-07-25 16:25 ` Tim Chen
2014-07-29 22:28 ` Tim Chen
2014-07-30 10:01 ` Peter Zijlstra
2014-07-25 7:26 ` Peter Zijlstra
2014-07-25 16:47 ` Tim Chen
2014-07-22 22:09 ` Tim Chen [this message]
2014-07-25 7:22 ` [PATCH v5 3/7] crypto: SHA1 multibuffer crypto opportunistic flush Peter Zijlstra
2014-07-22 22:09 ` [PATCH v5 4/7] crypto: SHA1 multibuffer algorithm data structures Tim Chen
2014-07-22 22:09 ` [PATCH v5 5/7] crypto: SHA1 multibuffer submit and flush routines for AVX2 Tim Chen
2014-07-22 22:09 ` [PATCH v5 6/7] crypto: SHA1 multibuffer crypto computation (x8 AVX2) Tim Chen
2014-07-22 22:09 ` [PATCH v5 7/7] crypto: SHA1 multibuffer scheduler Tim Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406066975.2970.805.camel@schen9-DESK \
--to=tim.c.chen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=james.guilford@intel.com \
--cc=jussi.kivilinna@iki.fi \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mouli@linux.intel.com \
--cc=peterz@infradead.org \
--cc=tadeusz.struk@intel.com \
--cc=tglx@linutronix.de \
--cc=tkhai@yandex.ru \
--cc=vinodh.gopal@intel.com \
--cc=wajdi.k.feghali@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox