1. 02 2月, 2013 9 次提交
  2. 15 11月, 2012 8 次提交
  3. 21 7月, 2012 1 次提交
    • S
      cpufreq: Fix sysfs deadlock with concurrent hotplug/frequency switch · a9144436
      Stephen Boyd 提交于
      Running one program that continuously hotplugs and replugs a cpu
      concurrently with another program that continuously writes to the
      scaling_setspeed node eventually deadlocks with:
      
      =============================================
      [ INFO: possible recursive locking detected ]
      3.4.0 #37 Tainted: G        W
      ---------------------------------------------
      filemonkey/122 is trying to acquire lock:
       (s_active#13){++++.+}, at: [<c01a3d28>] sysfs_remove_dir+0x9c/0xb4
      
      but task is already holding lock:
       (s_active#13){++++.+}, at: [<c01a22f0>] sysfs_write_file+0xe8/0x140
      
      other info that might help us debug this:
       Possible unsafe locking scenario:
      
             CPU0
             ----
        lock(s_active#13);
        lock(s_active#13);
      
       *** DEADLOCK ***
      
       May be due to missing lock nesting notation
      
      2 locks held by filemonkey/122:
       #0:  (&buffer->mutex){+.+.+.}, at: [<c01a2230>] sysfs_write_file+0x28/0x140
       #1:  (s_active#13){++++.+}, at: [<c01a22f0>] sysfs_write_file+0xe8/0x140
      
      stack backtrace:
      [<c0014fcc>] (unwind_backtrace+0x0/0x120) from [<c00ca600>] (validate_chain+0x6f8/0x1054)
      [<c00ca600>] (validate_chain+0x6f8/0x1054) from [<c00cb778>] (__lock_acquire+0x81c/0x8d8)
      [<c00cb778>] (__lock_acquire+0x81c/0x8d8) from [<c00cb9c0>] (lock_acquire+0x18c/0x1e8)
      [<c00cb9c0>] (lock_acquire+0x18c/0x1e8) from [<c01a3ba8>] (sysfs_addrm_finish+0xd0/0x180)
      [<c01a3ba8>] (sysfs_addrm_finish+0xd0/0x180) from [<c01a3d28>] (sysfs_remove_dir+0x9c/0xb4)
      [<c01a3d28>] (sysfs_remove_dir+0x9c/0xb4) from [<c02d0e5c>] (kobject_del+0x10/0x38)
      [<c02d0e5c>] (kobject_del+0x10/0x38) from [<c02d0f74>] (kobject_release+0xf0/0x194)
      [<c02d0f74>] (kobject_release+0xf0/0x194) from [<c0565a98>] (cpufreq_cpu_put+0xc/0x24)
      [<c0565a98>] (cpufreq_cpu_put+0xc/0x24) from [<c05683f0>] (store+0x6c/0x74)
      [<c05683f0>] (store+0x6c/0x74) from [<c01a2314>] (sysfs_write_file+0x10c/0x140)
      [<c01a2314>] (sysfs_write_file+0x10c/0x140) from [<c014af44>] (vfs_write+0xb0/0x128)
      [<c014af44>] (vfs_write+0xb0/0x128) from [<c014b06c>] (sys_write+0x3c/0x68)
      [<c014b06c>] (sys_write+0x3c/0x68) from [<c000e0e0>] (ret_fast_syscall+0x0/0x3c)
      
      This is because store() in cpufreq.c indirectly calls
      kobject_get() via cpufreq_cpu_get() and is the last one to call
      kobject_put() via cpufreq_cpu_put(). Sysfs code should not call
      kobject_get() or kobject_put() directly (see the comment around
      sysfs_schedule_callback() for more information).
      
      Fix this deadlock by introducing two new functions:
      
      	struct cpufreq_policy *cpufreq_cpu_get_sysfs(unsigned int cpu)
      	void cpufreq_cpu_put_sysfs(struct cpufreq_policy *data)
      
      which do the same thing as cpufreq_cpu_{get,put}() but don't call
      kobject functions.
      
      To easily trigger this deadlock you can insert an msleep() with a
      reasonably large value right after the fail label at the bottom
      of the store() function in cpufreq.c and then write
      scaling_setspeed in one task and offline the cpu in another. The
      first task will hang and be detected by the hung task detector.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      a9144436
  4. 21 3月, 2012 1 次提交
  5. 15 3月, 2012 1 次提交
  6. 06 1月, 2012 1 次提交
    • A
      [CPUFREQ] update lpj only if frequency has changed · d08de0c1
      Afzal Mohammed 提交于
      During scaling up of cpu frequency, loops_per_jiffy
      is updated upon invoking PRECHANGE notifier.
      If setting to new frequency fails in cpufreq driver,
      lpj is left at incorrect value.
      
      Hence update lpj only if cpu frequency is changed,
      i.e. upon invoking POSTCHANGE notifier.
      
      Penalty would be that during time period between
      changing cpu frequency & invocation of POSTCHANGE
      notifier, udelay(x) may not gurantee minimal delay
      of 'x' us for frequency scaling up operation.
      
      Perhaps a better solution would be to define
      CPUFREQ_ABORTCHANGE & handle accordingly, but then
      it would be more intrusive (using ABORTCHANGE may
      help drivers also; if any has registered notifier
      and expect POST for a PRECHANGE, their needs can
      be taken care using ABORT)
      Signed-off-by: NAfzal Mohammed <afzal@ti.com>
      Signed-off-by: NDave Jones <davej@redhat.com>
      d08de0c1
  7. 22 12月, 2011 1 次提交
    • K
      cpu: convert 'cpu' and 'machinecheck' sysdev_class to a regular subsystem · 8a25a2fd
      Kay Sievers 提交于
      This moves the 'cpu sysdev_class' over to a regular 'cpu' subsystem
      and converts the devices to regular devices. The sysdev drivers are
      implemented as subsystem interfaces now.
      
      After all sysdev classes are ported to regular driver core entities, the
      sysdev implementation will be entirely removed from the kernel.
      
      Userspace relies on events and generic sysfs subsystem infrastructure
      from sysdev devices, which are made available with this conversion.
      
      Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
      Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Chris Metcalf <cmetcalf@tilera.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Borislav Petkov <bp@amd64.org>
      Cc: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Zhang Rui <rui.zhang@intel.com>
      Cc: Dave Jones <davej@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <rmk+kernel@arm.linux.org.uk>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
      Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8a25a2fd
  8. 29 6月, 2011 1 次提交
  9. 04 5月, 2011 3 次提交
    • K
      [CPUFREQ] remove redundant sprintf from request_module call. · 1a8e1463
      Kees Cook 提交于
      Since format string handling is part of request_module, there is no
      need to construct the module name. As such, drop the redundant sprintf
      and heap usage.
      Signed-off-by: NKees Cook <kees.cook@canonical.com>
      Signed-off-by: NDave Jones <davej@redhat.com>
      1a8e1463
    • D
      [CPUFREQ] use dynamic debug instead of custom infrastructure · 2d06d8c4
      Dominik Brodowski 提交于
      With dynamic debug having gained the capability to report debug messages
      also during the boot process, it offers a far superior interface for
      debug messages than the custom cpufreq infrastructure. As a first step,
      remove the old cpufreq_debug_printk() function and replace it with a call
      to the generic pr_debug() function.
      
      How can dynamic debug be used on cpufreq? You need a kernel which has
      CONFIG_DYNAMIC_DEBUG enabled.
      
      To enabled debugging during runtime, mount debugfs and
      
      $ echo -n 'module cpufreq +p' > /sys/kernel/debug/dynamic_debug/control
      
      for debugging the complete "cpufreq" module. To achieve the same goal during
      boot, append
      
      	ddebug_query="module cpufreq +p"
      
      as a boot parameter to the kernel of your choice.
      
      For more detailled instructions, please see
      Documentation/dynamic-debug-howto.txt
      Signed-off-by: NDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: NDave Jones <davej@redhat.com>
      2d06d8c4
    • J
      [CPUFREQ] CPU hotplug, re-create sysfs directory and symlinks · 27ecddc2
      Jacob Shin 提交于
      When we discover CPUs that are affected by each other's
      frequency/voltage transitions, the first CPU gets a sysfs directory
      created, and rest of the siblings get symlinks. Currently, when we
      hotplug off only the first CPU, all of the symlinks and the sysfs
      directory gets removed. Even though rest of the siblings are still
      online and functional, they are orphaned, and no longer governed by
      cpufreq.
      
      This patch, given the above scenario, creates a sysfs directory for
      the first sibling and symlinks for the rest of the siblings.
      
      Please note the recursive call, it was rather too ugly to roll it
      out. And the removal of redundant NULL setting (it is already taken
      care of near the top of the function).
      Signed-off-by: NJacob Shin <jacob.shin@amd.com>
      Acked-by: NMark Langsdorf <mark.langsdorf@amd.com>
      Reviewed-by: NThomas Renninger <trenn@suse.de>
      Signed-off-by: NDave Jones <davej@redhat.com>
      Cc: stable@kernel.org
      27ecddc2
  10. 31 3月, 2011 1 次提交
  11. 24 3月, 2011 1 次提交
    • R
      cpufreq: Use syscore_ops for boot CPU suspend/resume (v2) · e00e56df
      Rafael J. Wysocki 提交于
      The cpufreq subsystem uses sysdev suspend and resume for
      executing cpufreq_suspend() and cpufreq_resume(), respectively,
      during system suspend, after interrupts have been switched off on the
      boot CPU, and during system resume, while interrupts are still off on
      the boot CPU.  In both cases the other CPUs are off-line at the
      relevant point (either they have been switched off via CPU hotplug
      during suspend, or they haven't been switched on yet during resume).
      For this reason, although it may seem that cpufreq_suspend() and
      cpufreq_resume() are executed for all CPUs in the system, they are
      only called for the boot CPU in fact, which is quite confusing.
      
      To remove the confusion and to prepare for elimiating sysdev
      suspend and resume operations from the kernel enirely, convernt
      cpufreq to using a struct syscore_ops object for the boot CPU
      suspend and resume and rename the callbacks so that their names
      reflect their purpose.  In addition, put some explanatory remarks
      into their kerneldoc comments.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      e00e56df
  12. 17 3月, 2011 1 次提交
  13. 02 3月, 2011 1 次提交
    • J
      [CPUFREQ] fix BUG on cpufreq policy init failure · 8f5bc2ab
      Jiri Slaby 提交于
      cpufreq_register_driver sets cpufreq_driver to a structure owned (and
      placed) in the caller's memory. If cpufreq policy fails in its ->init
      function, sysdev_driver_register returns nonzero in
      cpufreq_register_driver. Now, cpufreq_register_driver returns an error
      without setting cpufreq_driver back to NULL.
      
      Usually cpufreq policy modules are unloaded because they propagate the
      error to the module init function and return that.
      
      So a later access to any member of cpufreq_driver causes bugs like:
      BUG: unable to handle kernel paging request at ffffffffa00270a0
      IP: [<ffffffff8145eca3>] cpufreq_cpu_get+0x53/0xe0
      PGD 1805067 PUD 1809063 PMD 1c3f90067 PTE 0
      Oops: 0000 [#1] SMP
      last sysfs file: /sys/devices/virtual/net/tun0/statistics/collisions
      CPU 0
      Modules linked in: ...
      Pid: 5677, comm: thunderbird-bin Tainted: G        W   2.6.38-rc4-mm1_64+ #1389 To be filled by O.E.M./To Be Filled By O.E.M.
      RIP: 0010:[<ffffffff8145eca3>]  [<ffffffff8145eca3>] cpufreq_cpu_get+0x53/0xe0
      RSP: 0018:ffff8801aec37d98  EFLAGS: 00010086
      RAX: 0000000000000202 RBX: 0000000000000000 RCX: 0000000000000001
      RDX: ffffffffa00270a0 RSI: 0000000000001000 RDI: ffffffff8199ece8
      ...
      Call Trace:
       [<ffffffff8145f490>] cpufreq_quick_get+0x10/0x30
       [<ffffffff8103f12b>] show_cpuinfo+0x2ab/0x300
       [<ffffffff81136292>] seq_read+0xf2/0x3f0
       [<ffffffff8126c5d3>] ? __strncpy_from_user+0x33/0x60
       [<ffffffff8116850d>] proc_reg_read+0x6d/0xa0
       [<ffffffff81116e53>] vfs_read+0xc3/0x180
       [<ffffffff81116f5c>] sys_read+0x4c/0x90
       [<ffffffff81030dbb>] system_call_fastpath+0x16/0x1b
      ...
      
      It's all cause by weird fail path handling in cpufreq_register_driver.
      To fix that, shuffle the code to do proper handling with gotos.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NDave Jones <davej@redhat.com>
      8f5bc2ab
  14. 04 1月, 2011 1 次提交
    • T
      perf: Clean up power events by introducing new, more generic ones · 25e41933
      Thomas Renninger 提交于
      Add these new power trace events:
      
       power:cpu_idle
       power:cpu_frequency
       power:machine_suspend
      
      The old C-state/idle accounting events:
        power:power_start
        power:power_end
      
      Have now a replacement (but we are still keeping the old
      tracepoints for compatibility):
      
        power:cpu_idle
      
      and
        power:power_frequency
      
      is replaced with:
        power:cpu_frequency
      
      power:machine_suspend is newly introduced.
      
      Jean Pihet has a patch integrated into the generic layer
      (kernel/power/suspend.c) which will make use of it.
      
      the type= field got removed from both, it was never
      used and the type is differed by the event type itself.
      
      perf timechart userspace tool gets adjusted in a separate patch.
      Signed-off-by: NThomas Renninger <trenn@suse.de>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Acked-by: NArjan van de Ven <arjan@linux.intel.com>
      Acked-by: NJean Pihet <jean.pihet@newoldbits.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: rjw@sisk.pl
      LKML-Reference: <1294073445-14812-3-git-send-email-trenn@suse.de>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      LKML-Reference: <1290072314-31155-2-git-send-email-trenn@suse.de>
      25e41933
  15. 22 10月, 2010 1 次提交
  16. 04 8月, 2010 5 次提交
    • N
      [CPUFREQ] fix brace coding style issue. · 9c36f746
      Neal Buckendahl 提交于
      This patch fixes up a brace warning found by the checkpatch.pl tool
      Signed-off-by: NNeal Buckendahl <nealb001@tbcnet.com>
      Signed-off-by: NDave Jones <davej@redhat.com>
      9c36f746
    • T
      [CPUFREQ] x86 cpufreq: Make trace_power_frequency cpufreq driver independent · 6f4f2723
      Thomas Renninger 提交于
      and fix the broken case if a core's frequency depends on others.
      
      trace_power_frequency was only implemented in a rather ungeneric way
      in acpi-cpufreq driver's target() function only.
      -> Move the call to trace_power_frequency to
         cpufreq.c:cpufreq_notify_transition() where CPUFREQ_POSTCHANGE
         notifier is triggered.
         This will support power frequency tracing by all cpufreq drivers
      
      trace_power_frequency did not trace frequency changes correctly when
      the userspace governor was used or when CPU cores' frequency depend
      on each other.
      -> Moving this into the CPUFREQ_POSTCHANGE notifier and pass the cpu
         which gets switched automatically fixes this.
      
      Robert Schoene provided some important fixes on top of my initial
      quick shot version which are integrated in this patch:
      - Forgot some changes in power_end trace (TP_printk/variable names)
      - Variable dummy in power_end must now be cpu_id
      - Use static 64 bit variable instead of unsigned int for cpu_id
      Signed-off-by: NThomas Renninger <trenn@suse.de>
      CC: davej@redhat.com
      CC: arjan@infradead.org
      CC: linux-kernel@vger.kernel.org
      CC: robert.schoene@tu-dresden.de
      Tested-by: robert.schoene@tu-dresden.de
      Signed-off-by: NDave Jones <davej@redhat.com>
      6f4f2723
    • A
      [CPUFREQ] unexport (un)lock_policy_rwsem* functions · 226528c6
      Amerigo Wang 提交于
      lock_policy_rwsem_* and unlock_policy_rwsem_* functions are scheduled
      to be unexported when 2.6.33. Now there are no other callers of them
      out of cpufreq.c, unexport them and make them static.
      Signed-off-by: NWANG Cong <amwang@redhat.com>
      Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
      Signed-off-by: NDave Jones <davej@redhat.com>
      226528c6
    • X
      [CPUFREQ] fix memory leak in cpufreq_add_dev · cad70a6a
      Xiaotian Feng 提交于
      We didn't free policy->related_cpus in error path err_unlock_policy.
      This is catched by following kmemleak report:
      
      unreferenced object 0xffff88022a0b96d0 (size 512):
        comm "modprobe", pid 886, jiffies 4294689177 (age 780.694s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffffffff8111ebe5>] create_object+0x186/0x281
          [<ffffffff814fad4f>] kmemleak_alloc+0x60/0xa7
          [<ffffffff8111127a>] kmem_cache_alloc_node_notrace+0x120/0x142
          [<ffffffff81262e4f>] alloc_cpumask_var_node+0x2c/0xd7
          [<ffffffff81262f0b>] alloc_cpumask_var+0x11/0x13
          [<ffffffff81262f1c>] zalloc_cpumask_var+0xf/0x11
          [<ffffffff8140fac0>] cpufreq_add_dev+0x11f/0x547
          [<ffffffff81334bda>] sysdev_driver_register+0xc2/0x11d
          [<ffffffff8140e334>] cpufreq_register_driver+0xcb/0x1b8
          [<ffffffffa032e040>] 0xffffffffa032e040
          [<ffffffff810021ba>] do_one_initcall+0x5e/0x15c
          [<ffffffff81087f94>] sys_init_module+0xa6/0x1e6
          [<ffffffff81009bc2>] system_call_fastpath+0x16/0x1b
          [<ffffffffffffffff>] 0xffffffffffffffff
      Signed-off-by: NXiaotian Feng <dfeng@redhat.com>
      Cc: Thomas Renninger <trenn@suse.de>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Signed-off-by: NDave Jones <davej@redhat.com>
      cad70a6a
    • A
      [CPUFREQ] revert "[CPUFREQ] remove rwsem lock from CPUFREQ_GOV_STOP call (second call site)" · ffe6275f
      Andrej Gelenberg 提交于
      395913d0 ("[CPUFREQ] remove rwsem lock
      from CPUFREQ_GOV_STOP call (second call site)") is not needed, because
      there is no rwsem lock in cpufreq_ondemand and cpufreq_conservative
      anymore.  Lock should not be released until the work done.
      
      Addresses https://bugzilla.kernel.org/show_bug.cgi?id=1594Signed-off-by: NAndrej Gelenberg <andrej.gelenberg@udo.edu>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Acked-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: NDave Jones <davej@redhat.com>
      ffe6275f
  17. 27 7月, 2010 2 次提交
  18. 22 7月, 2010 1 次提交
    • T
      x86 cpufreq, perf: Make trace_power_frequency cpufreq driver independent · 4c21adf2
      Thomas Renninger 提交于
      and fix the broken case if a core's frequency depends on others.
      
      trace_power_frequency was only implemented in a rather ungeneric
      way in acpi-cpufreq driver's target() function only.
      
      -> Move the call to trace_power_frequency to
         cpufreq.c:cpufreq_notify_transition() where CPUFREQ_POSTCHANGE
         notifier is triggered.
         This will support power frequency tracing by all cpufreq
         drivers.
      
      trace_power_frequency did not trace frequency changes correctly
      when the userspace governor was used or when CPU cores'
      frequency depend on each other.
      
      -> Moving this into the CPUFREQ_POSTCHANGE notifier and pass the cpu
         which gets switched automatically fixes this.
      
      Robert Schoene provided some important fixes on top of my
      initial quick shot version which are integrated in this patch:
      - Forgot some changes in power_end trace (TP_printk/variable names)
      - Variable dummy in power_end must now be cpu_id
      - Use static 64 bit variable instead of unsigned int for cpu_id
      
      [akpm@linux-foundation.org: build fix]
      Signed-off-by: NThomas Renninger <trenn@suse.de>
      Cc: davej@codemonkey.org.uk
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Cc: Dave Jones <davej@codemonkey.org.uk>
      Acked-by: NArjan van de Ven <arjan@infradead.org>
      Cc: Robert Schoene <robert.schoene@tu-dresden.de>
      Tested-by: NRobert Schoene <robert.schoene@tu-dresden.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      4c21adf2