sched: Add function single_task_running to let a task check if it is the only task...
authorTim Chen <tim.c.chen@linux.intel.com>
Thu, 31 Jul 2014 17:29:48 +0000 (10:29 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 25 Aug 2014 12:32:23 +0000 (20:32 +0800)
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, the batching process can take
advantgae of the available cpu cycles to a make decision to continue
processing the existing accumulated work to minimize delay,
otherwise it will yield.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
include/linux/sched.h
kernel/sched/core.c

index 5c2c885ee52b3996a2665dc3d8c0e21ff9245aaf..e6d2c056d8e0a6b851cc2292e775f40eaa86bc69 100644 (file)
@@ -167,6 +167,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 void get_iowait_load(unsigned long *nr_waiters, unsigned long *load);
index ec1a286684a56047a4352350edf4c0686e4ba70e..59965ec0b7de6fec0cc7e72ac8b03402dac1f8c1 100644 (file)
@@ -2366,6 +2366,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;
This page took 0.035399 seconds and 5 git commands to generate.