1. 04 7月, 2013 1 次提交
    • V
      cpufreq: Fix serialization of frequency transitions · 266c13d7
      Viresh Kumar 提交于
      Commit 7c30ed ("cpufreq: make sure frequency transitions are serialized")
      interacts poorly with systems that have a single core freqency for all
      cores.  On such systems we have a single policy for all cores with
      several CPUs.  When we do a frequency transition the governor calls the
      pre and post change notifiers which causes cpufreq_notify_transition()
      per CPU.  Since the policy is the same for all of them all CPUs after
      the first and the warnings added are generated by checking a per-policy
      flag the warnings will be triggered for all cores after the first.
      
      Fix this by allowing notifier to be called for n times. Where n is the number of
      cpus in policy->cpus.
      Reported-and-tested-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      266c13d7
  2. 28 6月, 2013 2 次提交
  3. 21 6月, 2013 3 次提交
    • V
      cpufreq: make __cpufreq_notify_transition() static · 0956df9c
      Viresh Kumar 提交于
      __cpufreq_notify_transition() is used only in cpufreq.c,
      make it static.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0956df9c
    • V
      cpufreq: Fix minor formatting issues · bb176f7d
      Viresh Kumar 提交于
      There were a few noticeable formatting issues in core cpufreq code.
      This cleans them up to make code look better.  The changes include:
       - Whitespace cleanup.
       - Rearrangements of code.
       - Multiline comments fixes.
       - Formatting changes to fit 80 columns.
      
      Copyright information in cpufreq.c is also updated to include my name
      for 2013.
      
      [rjw: Changelog]
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      bb176f7d
    • X
      cpufreq: Fix governor start/stop race condition · 95731ebb
      Xiaoguang Chen 提交于
      Cpufreq governors' stop and start operations should be carried out
      in sequence.  Otherwise, there will be unexpected behavior, like in
      the example below.
      
      Suppose there are 4 CPUs and policy->cpu=CPU0, CPU1/2/3 are linked
      to CPU0.  The normal sequence is:
      
       1) Current governor is userspace.  An application tries to set the
          governor to ondemand.  It will call __cpufreq_set_policy() in
          which it will stop the userspace governor and then start the
          ondemand governor.
      
       2) Current governor is userspace.  The online of CPU3 runs on CPU0.
          It will call cpufreq_add_policy_cpu() in which it will first
          stop the userspace governor, and then start it again.
      
      If the sequence of the above two cases interleaves, it becomes:
      
       1) Application stops userspace governor
       2)                                  Hotplug stops userspace governor
      
      which is a problem, because the governor shouldn't be stopped twice
      in a row.  What happens next is:
      
       3) Application starts ondemand governor
       4)                                  Hotplug starts a governor
      
      In step 4, the hotplug is supposed to start the userspace governor,
      but now the governor has been changed by the application to ondemand,
      so the ondemand governor is started once again, which is incorrect.
      
      The solution is to prevent policy governors from being stopped
      multiple times in a row.  A governor should only be stopped once for
      one policy.  After it has been stopped, no more governor stop
      operations should be executed.
      
      Also add a mutex to serialize governor operations.
      
      [rjw: Changelog.  And you owe me a beverage of my choice.]
      Signed-off-by: NXiaoguang Chen <chenxg@marvell.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      95731ebb
  4. 04 6月, 2013 1 次提交
  5. 27 5月, 2013 4 次提交
  6. 22 5月, 2013 1 次提交
    • V
      cpufreq: Drop rwsem lock around CPUFREQ_GOV_POLICY_EXIT · 955ef483
      Viresh Kumar 提交于
      With the rwsem lock around
      __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT), we
      get circular dependency when we call sysfs_remove_group().
      
       ======================================================
       [ INFO: possible circular locking dependency detected ]
       3.9.0-rc7+ #15 Not tainted
       -------------------------------------------------------
       cat/2387 is trying to acquire lock:
        (&per_cpu(cpu_policy_rwsem, cpu)){+++++.}, at: [<c02f6179>] lock_policy_rwsem_read+0x25/0x34
      
       but task is already holding lock:
        (s_active#41){++++.+}, at: [<c00f9bf7>] sysfs_read_file+0x4f/0xcc
      
       which lock already depends on the new lock.
      
       the existing dependency chain (in reverse order) is:
      
      -> #1 (s_active#41){++++.+}:
              [<c0055a79>] lock_acquire+0x61/0xbc
              [<c00fabf1>] sysfs_addrm_finish+0xc1/0x128
              [<c00f9819>] sysfs_hash_and_remove+0x35/0x64
              [<c00fbe6f>] remove_files.isra.0+0x1b/0x24
              [<c00fbea5>] sysfs_remove_group+0x2d/0xa8
              [<c02f9a0b>] cpufreq_governor_interactive+0x13b/0x35c
              [<c02f61df>] __cpufreq_governor+0x2b/0x8c
              [<c02f6579>] __cpufreq_set_policy+0xa9/0xf8
              [<c02f6b75>] store_scaling_governor+0x61/0x100
              [<c02f6f4d>] store+0x39/0x60
              [<c00f9b81>] sysfs_write_file+0xed/0x114
              [<c00b3fd1>] vfs_write+0x65/0xd8
              [<c00b424b>] sys_write+0x2f/0x50
              [<c000cdc1>] ret_fast_syscall+0x1/0x52
      
      -> #0 (&per_cpu(cpu_policy_rwsem, cpu)){+++++.}:
              [<c0055253>] __lock_acquire+0xef3/0x13dc
              [<c0055a79>] lock_acquire+0x61/0xbc
              [<c03ee1f5>] down_read+0x25/0x30
              [<c02f6179>] lock_policy_rwsem_read+0x25/0x34
              [<c02f6edd>] show+0x21/0x58
              [<c00f9c0f>] sysfs_read_file+0x67/0xcc
              [<c00b40a7>] vfs_read+0x63/0xd8
              [<c00b41fb>] sys_read+0x2f/0x50
              [<c000cdc1>] ret_fast_syscall+0x1/0x52
      
       other info that might help us debug this:
      
        Possible unsafe locking scenario:
      
              CPU0                    CPU1
              ----                    ----
         lock(s_active#41);
                                      lock(&per_cpu(cpu_policy_rwsem, cpu));
                                      lock(s_active#41);
         lock(&per_cpu(cpu_policy_rwsem, cpu));
      
        *** DEADLOCK ***
      
       2 locks held by cat/2387:
        #0:  (&buffer->mutex){+.+.+.}, at: [<c00f9bcd>] sysfs_read_file+0x25/0xcc
        #1:  (s_active#41){++++.+}, at: [<c00f9bf7>] sysfs_read_file+0x4f/0xcc
      
       stack backtrace:
       [<c0011d55>] (unwind_backtrace+0x1/0x9c) from [<c03e9a09>] (print_circular_bug+0x19d/0x1e8)
       [<c03e9a09>] (print_circular_bug+0x19d/0x1e8) from [<c0055253>] (__lock_acquire+0xef3/0x13dc)
       [<c0055253>] (__lock_acquire+0xef3/0x13dc) from [<c0055a79>] (lock_acquire+0x61/0xbc)
       [<c0055a79>] (lock_acquire+0x61/0xbc) from [<c03ee1f5>] (down_read+0x25/0x30)
       [<c03ee1f5>] (down_read+0x25/0x30) from [<c02f6179>] (lock_policy_rwsem_read+0x25/0x34)
       [<c02f6179>] (lock_policy_rwsem_read+0x25/0x34) from [<c02f6edd>] (show+0x21/0x58)
       [<c02f6edd>] (show+0x21/0x58) from [<c00f9c0f>] (sysfs_read_file+0x67/0xcc)
       [<c00f9c0f>] (sysfs_read_file+0x67/0xcc) from [<c00b40a7>] (vfs_read+0x63/0xd8)
       [<c00b40a7>] (vfs_read+0x63/0xd8) from [<c00b41fb>] (sys_read+0x2f/0x50)
       [<c00b41fb>] (sys_read+0x2f/0x50) from [<c000cdc1>] (ret_fast_syscall+0x1/0x52)
      
      This lock isn't required while calling __cpufreq_governor(policy,
      CPUFREQ_GOV_POLICY_EXIT). Remove it.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      955ef483
  7. 16 5月, 2013 1 次提交
  8. 12 5月, 2013 1 次提交
    • V
      cpufreq: Issue CPUFREQ_GOV_POLICY_EXIT notifier before dropping policy refcount · d96038e0
      Viresh Kumar 提交于
      We must call __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT) before
      calling cpufreq_cpu_put(data), so that policy kobject have valid
      fields. Otherwise, removing last online cpu of policy->cpus causes
      this crash for ondemand/conservative governor.
      
       [<c00fb076>] (sysfs_find_dirent+0xe/0xa8) from [<c00fb1bd>] (sysfs_get_dirent+0x21/0x58)
       [<c00fb1bd>] (sysfs_get_dirent+0x21/0x58) from [<c00fc259>] (sysfs_remove_group+0x85/0xbc)
       [<c00fc259>] (sysfs_remove_group+0x85/0xbc) from [<c02faad9>] (cpufreq_governor_dbs+0x369/0x4a0)
       [<c02faad9>] (cpufreq_governor_dbs+0x369/0x4a0) from [<c02f66d7>] (__cpufreq_governor+0x2b/0x8c)
       [<c02f66d7>] (__cpufreq_governor+0x2b/0x8c) from [<c02f6893>] (__cpufreq_remove_dev.isra.12+0x15b/0x250)
       [<c02f6893>] (__cpufreq_remove_dev.isra.12+0x15b/0x250) from [<c03e91c7>] (cpufreq_cpu_callback+0x2f/0x3c)
       [<c03e91c7>] (cpufreq_cpu_callback+0x2f/0x3c) from [<c0036fe1>] (notifier_call_chain+0x45/0x54)
       [<c0036fe1>] (notifier_call_chain+0x45/0x54) from [<c001e611>] (__cpu_notify+0x1d/0x34)
       [<c001e611>] (__cpu_notify+0x1d/0x34) from [<c03e5833>] (_cpu_down+0x63/0x1ac)
       [<c03e5833>] (_cpu_down+0x63/0x1ac) from [<c03e5997>] (cpu_down+0x1b/0x30)
       [<c03e5997>] (cpu_down+0x1b/0x30) from [<c03e60eb>] (store_online+0x27/0x54)
       [<c03e60eb>] (store_online+0x27/0x54) from [<c0295629>] (dev_attr_store+0x11/0x18)
       [<c0295629>] (dev_attr_store+0x11/0x18) from [<c00f9edd>] (sysfs_write_file+0xed/0x114)
       [<c00f9edd>] (sysfs_write_file+0xed/0x114) from [<c00b42a9>] (vfs_write+0x65/0xd8)
       [<c00b42a9>] (vfs_write+0x65/0xd8) from [<c00b4523>] (sys_write+0x2f/0x50)
       [<c00b4523>] (sys_write+0x2f/0x50) from [<c000cdc1>] (ret_fast_syscall+0x1/0x52)
      
      Of course this only impacted drivers which have
      have_governor_per_policy set to true. i.e. big LITTLE cpufreq driver.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      d96038e0
  9. 29 4月, 2013 1 次提交
    • R
      cpufreq: Revert incorrect commit 5800043b · 1c3d85dd
      Rafael J. Wysocki 提交于
      Commit 5800043b (cpufreq: convert cpufreq_driver to using RCU) causes
      the following call trace to be spit on boot:
      
       BUG: sleeping function called from invalid context at /scratch/rafael/work/linux-pm/mm/slab.c:3179
       in_atomic(): 0, irqs_disabled(): 0, pid: 292, name: systemd-udevd
       2 locks held by systemd-udevd/292:
        #0:  (subsys mutex){+.+.+.}, at: [<ffffffff8146851a>] subsys_interface_register+0x4a/0xe0
        #1:  (rcu_read_lock){.+.+.+}, at: [<ffffffff81538210>] cpufreq_add_dev_interface+0x60/0x5e0
       Pid: 292, comm: systemd-udevd Not tainted 3.9.0-rc8+ #323
       Call Trace:
        [<ffffffff81072c90>] __might_sleep+0x140/0x1f0
        [<ffffffff811581c2>] kmem_cache_alloc+0x42/0x2b0
        [<ffffffff811e7179>] sysfs_new_dirent+0x59/0x130
        [<ffffffff811e63cb>] sysfs_add_file_mode+0x6b/0x110
        [<ffffffff81538210>] ? cpufreq_add_dev_interface+0x60/0x5e0
        [<ffffffff810a3254>] ? __lock_is_held+0x54/0x80
        [<ffffffff811e647d>] sysfs_add_file+0xd/0x10
        [<ffffffff811e6541>] sysfs_create_file+0x21/0x30
        [<ffffffff81538280>] cpufreq_add_dev_interface+0xd0/0x5e0
        [<ffffffff81538210>] ? cpufreq_add_dev_interface+0x60/0x5e0
        [<ffffffffa000337f>] ? acpi_processor_get_platform_limit+0x32/0xbb [processor]
        [<ffffffffa022f540>] ? do_drv_write+0x70/0x70 [acpi_cpufreq]
        [<ffffffff810a3254>] ? __lock_is_held+0x54/0x80
        [<ffffffff8106c97e>] ? up_read+0x1e/0x40
        [<ffffffff8106e632>] ? __blocking_notifier_call_chain+0x72/0xc0
        [<ffffffff81538dbd>] cpufreq_add_dev+0x62d/0xae0
        [<ffffffff815389b8>] ? cpufreq_add_dev+0x228/0xae0
        [<ffffffff81468569>] subsys_interface_register+0x99/0xe0
        [<ffffffffa014d000>] ? 0xffffffffa014cfff
        [<ffffffff81535d5d>] cpufreq_register_driver+0x9d/0x200
        [<ffffffffa014d000>] ? 0xffffffffa014cfff
        [<ffffffffa014d0e9>] acpi_cpufreq_init+0xe9/0x1000 [acpi_cpufreq]
        [<ffffffff810002fa>] do_one_initcall+0x11a/0x170
        [<ffffffff810b4b87>] load_module+0x1cf7/0x2920
        [<ffffffff81322580>] ? ddebug_proc_open+0xb0/0xb0
        [<ffffffff816baee0>] ? retint_restore_args+0xe/0xe
        [<ffffffff810b5887>] sys_init_module+0xd7/0x120
        [<ffffffff816bb6d2>] system_call_fastpath+0x16/0x1b
      
      which is quite obvious, because that commit put (multiple instances
      of) sysfs_create_file() under rcu_read_lock()/rcu_read_unlock(),
      although sysfs_create_file() may cause memory to be allocated with
      GFP_KERNEL and that may sleep, which is not permitted in RCU read
      critical section.
      
      Revert the buggy commit altogether along with some changes on top
      of it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      1c3d85dd
  10. 22 4月, 2013 1 次提交
  11. 12 4月, 2013 1 次提交
    • V
      cpufreq: Call __cpufreq_governor() with correct policy->cpus mask · e4969eba
      Viresh Kumar 提交于
      __cpufreq_governor() must be called with a correct policy->cpus mask.
      In __cpufreq_remove_dev() we initially clear policy->cpus with
      cpumask_clear_cpu() and then call
      __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT). If the governor
      is doing some per-cpu stuff in EXIT callback, this can create
      uncertain behavior.
      
      Generic governors in drivers/cpufreq/ doesn't do any per-cpu stuff
      in EXIT callback and so we don't face any issues currently. But its
      better to keep the code clean, so we don't face any issues in future.
      
      Now, we call cpumask_clear_cpu() only when multiple cpus are managed
      by policy.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      e4969eba
  12. 10 4月, 2013 1 次提交
  13. 02 4月, 2013 1 次提交
  14. 01 4月, 2013 3 次提交
    • V
      cpufreq: governor: Implement per policy instances of governors · 4d5dcc42
      Viresh Kumar 提交于
      Currently, there can't be multiple instances of single governor_type.
      If we have a multi-package system, where we have multiple instances
      of struct policy (per package), we can't have multiple instances of
      same governor. i.e. We can't have multiple instances of ondemand
      governor for multiple packages.
      
      Governors directory in sysfs is created at /sys/devices/system/cpu/cpufreq/
      governor-name/. Which again reflects that there can be only one
      instance of a governor_type in the system.
      
      This is a bottleneck for multicluster system, where we want different
      packages to use same governor type, but with different tunables.
      
      This patch uses the infrastructure provided by earlier patch and
      implements init/exit routines for ondemand and conservative
      governors.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      4d5dcc42
    • V
      cpufreq: Add per policy governor-init/exit infrastructure · 7bd353a9
      Viresh Kumar 提交于
      Currently, there can't be multiple instances of single governor_type.
      If we have a multi-package system, where we have multiple instances
      of struct policy (per package), we can't have multiple instances of
      same governor. i.e. We can't have multiple instances of ondemand
      governor for multiple packages.
      
      Governors directory in sysfs is created at /sys/devices/system/cpu/cpufreq/
      governor-name/. Which again reflects that there can be only one
      instance of a governor_type in the system.
      
      This is a bottleneck for multicluster system, where we want different
      packages to use same governor type, but with different tunables.
      
      This patch is inclined towards providing this infrastructure. Because
      we are required to allocate governor's resources dynamically now, we
      must do it at policy creation and end. And so got
      CPUFREQ_GOV_POLICY_INIT/EXIT.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      7bd353a9
    • N
      cpufreq: Convert the cpufreq_driver_lock to a rwlock · 0d1857a1
      Nathan Zimmer 提交于
      This eliminates the contention I am seeing in __cpufreq_cpu_get.
      It also nicely stages the lock to be replaced by the rcu.
      Signed-off-by: NNathan Zimmer <nzimmer@sgi.com>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0d1857a1
  15. 09 2月, 2013 8 次提交
  16. 06 2月, 2013 1 次提交
  17. 02 2月, 2013 9 次提交