Commit c7b24d2b authored by Paul E. McKenney's avatar Paul E. McKenney

rcu: Improve RCU-tasks energy efficiency

The current RCU-tasks implementation uses strict polling to detect
callback arrivals.  This works quite well, but is not so good for
energy efficiency.  This commit therefore replaces the strict polling
with a wait queue.
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent 52db30ab
...@@ -365,6 +365,7 @@ early_initcall(check_cpu_stall_init); ...@@ -365,6 +365,7 @@ early_initcall(check_cpu_stall_init);
/* Global list of callbacks and associated lock. */ /* Global list of callbacks and associated lock. */
static struct rcu_head *rcu_tasks_cbs_head; static struct rcu_head *rcu_tasks_cbs_head;
static struct rcu_head **rcu_tasks_cbs_tail = &rcu_tasks_cbs_head; static struct rcu_head **rcu_tasks_cbs_tail = &rcu_tasks_cbs_head;
static DECLARE_WAIT_QUEUE_HEAD(rcu_tasks_cbs_wq);
static DEFINE_RAW_SPINLOCK(rcu_tasks_cbs_lock); static DEFINE_RAW_SPINLOCK(rcu_tasks_cbs_lock);
/* Track exiting tasks in order to allow them to be waited for. */ /* Track exiting tasks in order to allow them to be waited for. */
...@@ -378,13 +379,17 @@ module_param(rcu_task_stall_timeout, int, 0644); ...@@ -378,13 +379,17 @@ module_param(rcu_task_stall_timeout, int, 0644);
void call_rcu_tasks(struct rcu_head *rhp, void (*func)(struct rcu_head *rhp)) void call_rcu_tasks(struct rcu_head *rhp, void (*func)(struct rcu_head *rhp))
{ {
unsigned long flags; unsigned long flags;
bool needwake;
rhp->next = NULL; rhp->next = NULL;
rhp->func = func; rhp->func = func;
raw_spin_lock_irqsave(&rcu_tasks_cbs_lock, flags); raw_spin_lock_irqsave(&rcu_tasks_cbs_lock, flags);
needwake = !rcu_tasks_cbs_head;
*rcu_tasks_cbs_tail = rhp; *rcu_tasks_cbs_tail = rhp;
rcu_tasks_cbs_tail = &rhp->next; rcu_tasks_cbs_tail = &rhp->next;
raw_spin_unlock_irqrestore(&rcu_tasks_cbs_lock, flags); raw_spin_unlock_irqrestore(&rcu_tasks_cbs_lock, flags);
if (needwake)
wake_up(&rcu_tasks_cbs_wq);
} }
EXPORT_SYMBOL_GPL(call_rcu_tasks); EXPORT_SYMBOL_GPL(call_rcu_tasks);
...@@ -495,8 +500,12 @@ static int __noreturn rcu_tasks_kthread(void *arg) ...@@ -495,8 +500,12 @@ static int __noreturn rcu_tasks_kthread(void *arg)
/* If there were none, wait a bit and start over. */ /* If there were none, wait a bit and start over. */
if (!list) { if (!list) {
schedule_timeout_interruptible(HZ); wait_event_interruptible(rcu_tasks_cbs_wq,
WARN_ON(signal_pending(current)); rcu_tasks_cbs_head);
if (!rcu_tasks_cbs_head) {
WARN_ON(signal_pending(current));
schedule_timeout_interruptible(HZ/10);
}
continue; continue;
} }
...@@ -602,6 +611,7 @@ static int __noreturn rcu_tasks_kthread(void *arg) ...@@ -602,6 +611,7 @@ static int __noreturn rcu_tasks_kthread(void *arg)
list = next; list = next;
cond_resched(); cond_resched();
} }
schedule_timeout_uninterruptible(HZ/10);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment