idle governor: Avoid lock acquisition to read pm_qos before entering idle
authorTim Chen <tim.c.chen@linux.intel.com>
Fri, 11 Feb 2011 20:49:04 +0000 (12:49 -0800)
committerSteve Conklin <sconklin@canonical.com>
Fri, 15 Jul 2011 17:21:09 +0000 (12:21 -0500)
commit5320ccdb22818b4e637456e027a9d2b943bf1920
treeafc458241ad6620b9c3457fc24d16fd073c492a5
parent43a38e2218410b026f8368605a230449d18dae43
idle governor: Avoid lock acquisition to read pm_qos before entering idle

BugLink: http://bugs.launchpad.net/bugs/793702

commit 333c5ae9948194428fe6c5ef5c088304fc98263b upstream.

Thanks to the reviews and comments by Rafael, James, Mark and Andi.
Here's version 2 of the patch incorporating your comments and also some
update to my previous patch comments.

I noticed that before entering idle state, the menu idle governor will
look up the current pm_qos target value according to the list of qos
requests received.  This look up currently needs the acquisition of a
lock to access the list of qos requests to find the qos target value,
slowing down the entrance into idle state due to contention by multiple
cpus to access this list.  The contention is severe when there are a lot
of cpus waking and going into idle.  For example, for a simple workload
that has 32 pair of processes ping ponging messages to each other, where
64 cpu cores are active in test system, I see the following profile with
37.82% of cpu cycles spent in contention of pm_qos_lock:

-     37.82%          swapper  [kernel.kallsyms]          [k]
_raw_spin_lock_irqsave
   - _raw_spin_lock_irqsave
      - 95.65% pm_qos_request
           menu_select
           cpuidle_idle_call
         - cpu_idle
              99.98% start_secondary

A better approach will be to cache the updated pm_qos target value so
reading it does not require lock acquisition as in the patch below.
With this patch the contention for pm_qos_lock is removed and I saw a
2.2X increase in throughput for my message passing workload.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Acked-by: James Bottomley <James.Bottomley@suse.de>
Acked-by: mark gross <markgross@thegnar.org>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
include/linux/pm_qos_params.h
kernel/pm_qos_params.c