Linux cryptographic layer development
 help / color / mirror / Atom feed
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 1/7] sched: Add function single_task_running to let a task check if it is the only task running on a cpu
Date: Tue, 22 Jul 2014 15:09:29 -0700	[thread overview]
Message-ID: <1406066969.2970.803.camel@schen9-DESK> (raw)
In-Reply-To: <cover.1406033477.git.tim.c.chen@linux.intel.com>

This function will help an async task processing batched jobs from workqueue
decide if it wants to keep processing on more chunks of batched work that
can be delayed, or to accumulate more work for more efficient batched
processing later.

If no other tasks are running on the cpu, it can take advantgae of
the available cpu cycles to complete the existing accumulated work for
immediate processing to minimize delay, otherwise it will yield.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
 include/linux/sched.h |  1 +
 kernel/sched/core.c   | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 7cb07fd..eefa943 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -168,6 +168,7 @@ extern int nr_threads;
 DECLARE_PER_CPU(unsigned long, process_counts);
 extern int nr_processes(void);
 extern unsigned long nr_running(void);
+extern bool single_task_running(void);
 extern unsigned long nr_iowait(void);
 extern unsigned long nr_iowait_cpu(int cpu);
 extern unsigned long this_cpu_load(void);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9cae286..03c8675 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2283,6 +2283,18 @@ unsigned long nr_running(void)
 	return sum;
 }
 
+/*
+ * Check if only the current task is running on the cpu.
+ */
+bool single_task_running(void)
+{
+	if (cpu_rq(smp_processor_id())->nr_running == 1)
+		return true;
+	else
+		return false;
+}
+EXPORT_SYMBOL(single_task_running);
+
 unsigned long long nr_context_switches(void)
 {
 	int i;
-- 
1.7.11.7

  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 ` Tim Chen [this message]
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 ` [PATCH v5 3/7] crypto: SHA1 multibuffer crypto opportunistic flush Tim Chen
2014-07-25  7:22   ` 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=1406066969.2970.803.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