From 6e4ee00333a93fdf949c283cce0f0e948cbae08f Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Tue, 18 Feb 2014 19:35:25 +0530 Subject: sched: Trying to reduce power usage Using macros cpu_relaxed_read, cpu_relaxed_read_long and cpu_read_relax in core.c to improve power efficiency. Bug 1440421 Change-Id: Ic49b88fa6fb0cb847fed49886b2865bed72203db Signed-off-by: Sumit Singh Reviewed-on: http://git-master/r/368841 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Bharat Nihalani Tested-by: Bharat Nihalani --- kernel/sched/core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'kernel') diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 960acc06a818..d10482a0c683 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5,6 +5,8 @@ * * Copyright (C) 1991-2002 Linus Torvalds * + * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. + * * 1996-12-23 Modified by Dave Grothe to fix bugs in semaphores and * make semaphores SMP safe * 1998-11-19 Implemented schedule_timeout() and related stuff @@ -1091,9 +1093,10 @@ unsigned long wait_task_inactive(struct task_struct *p, long match_state) * is actually now running somewhere else! */ while (task_running(rq, p)) { - if (match_state && unlikely(p->state != match_state)) + if (match_state && unlikely(cpu_relaxed_read_long + (&(p->state)) != match_state)) return 0; - cpu_relax(); + cpu_read_relax(); } /* @@ -1521,8 +1524,8 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) * If the owning (remote) cpu is still in the middle of schedule() with * this task as prev, wait until its done referencing the task. */ - while (p->on_cpu) - cpu_relax(); + while (cpu_relaxed_read(&(p->on_cpu))) + cpu_read_relax(); /* * Pairs with the smp_wmb() in finish_lock_switch(). */ -- cgit v1.2.3