Archived
14
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
linux-2.6/include
Venki Pallipadi 9e76988e93 [CPUFREQ] Eliminate cpufreq_userspace scaling_setspeed deadlock
Eliminate cpufreq_userspace scaling_setspeed deadlock.

Luming Yu recently uncovered yet another cpufreq related deadlock.
One thread that continuously switches the governors and the other thread that
repeatedly cats the contents of cpufreq directory causes both these threads to
go into a deadlock.

Detailed examination of the deadlock showed the exact flow before the deadlock
as:

Thread 1			Thread 2
________			________
				cats files under /sys/devices/.../cpufreq/
Set governor to userspace
  Adds a new sysfs entry for
  scaling_setspeed
				cats files under /sys/devices/.../cpufreq/

Set governor to performance
  Holds cpufreq_rw_sem in write
  mode
  Sends a STOP notify to
  userspace governor
				cat /sys/devices/.../cpufreq/scaling_setspeed
				  Gets a handle on the above sysfs entry with
				  sysfs_get_active
				  Blocks while trying to get cpufreq_rw_sem
				  in read mode
  Remove a sysfs entry for
  scaling_setspeed
    Blocks on sysfs_deactivate
    while waiting for earlier
    get_active (on other thread)
    to drain

At this point both threads go into deadlock and any other thread that tries to
do anything with sysfs cpufreq will also block.

There seems to be no easy way to avoid this deadlock as long as
cpufreq_userspace adds/removes the sysfs entry under same kobject as cpufreq.
Below patch moves scaling_setspeed to cpufreq.c, keeping it always and calling
back the governor on read/write. This is the cleanest fix I could think of,
even though adding two callbacks in governor structure just for this seems
unnecessary.

Note that the change makes scaling_setspeed under /sys/.../cpufreq permanent
and returns <unsupported> when governor is not userspace.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Dave Jones <davej@redhat.com>
2008-02-06 22:57:58 -05:00
..
acpi include/acpi/: Spelling fixes 2008-02-03 17:07:16 +02:00
asm-alpha alpha: fix warning by fixing flush_tlb_kernel_range() 2008-02-05 09:44:22 -08:00
asm-arm Merge branch 'async-tx-for-linus' of git://lost.foo-projects.org/~dwillia2/git/iop into fix 2008-02-06 11:16:11 -08:00
asm-avr32 Fix __const_udelay declaration and definition mismatches 2008-02-06 10:41:06 -08:00
asm-blackfin remove mm_{ptov,vtop}() 2008-02-06 10:41:01 -08:00
asm-cris cris: remove unused __dummy, CONST_ADDR and ADDR from bitops.h 2008-02-05 09:44:24 -08:00
asm-frv timerfd: fix remaining architectures 2008-02-05 14:37:15 -08:00
asm-generic remove support for un-needed _extratext section 2008-02-06 10:41:01 -08:00
asm-h8300 remove mm_{ptov,vtop}() 2008-02-06 10:41:01 -08:00
asm-ia64 Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6 2008-02-05 10:24:52 -08:00
asm-m32r Fix __const_udelay declaration and definition mismatches 2008-02-06 10:41:06 -08:00
asm-m68k cleanup after APUS removal 2008-02-06 10:41:01 -08:00
asm-m68knommu remove mm_{ptov,vtop}() 2008-02-06 10:41:01 -08:00
asm-mips add mm argument to pte/pmd/pud/pgd_free 2008-02-05 09:44:18 -08:00
asm-parisc add mm argument to pte/pmd/pud/pgd_free 2008-02-05 09:44:18 -08:00
asm-powerpc ps3: use symbolic names for video modes 2008-02-06 10:41:17 -08:00
asm-ppc add mm argument to pte/pmd/pud/pgd_free 2008-02-05 09:44:18 -08:00
asm-s390 taskstats scaled time cleanup 2008-02-06 10:41:00 -08:00
asm-sh Fix __const_udelay declaration and definition mismatches 2008-02-06 10:41:06 -08:00
asm-sparc [SPARC]: Add new timerfd syscall entries. 2008-02-06 04:12:23 -08:00
asm-sparc64 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6 2008-02-06 10:46:58 -08:00
asm-um uml: LDT mutex conversion 2008-02-05 09:44:31 -08:00
asm-v850 remove mm_{ptov,vtop}() 2008-02-06 10:41:01 -08:00
asm-x86 Merge git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86 2008-02-06 13:54:09 -08:00
asm-xtensa add mm argument to pte/pmd/pud/pgd_free 2008-02-05 09:44:18 -08:00
crypto
keys
linux [CPUFREQ] Eliminate cpufreq_userspace scaling_setspeed deadlock 2008-02-06 22:57:58 -05:00
math-emu
media include/media/: Spelling fixes 2008-02-03 17:19:47 +02:00
mtd
net 9p: add support for sticky bit 2008-02-06 19:25:06 -06:00
pcmcia pcmcia: replace kio_addr_t with unsigned int everywhere 2008-02-05 09:44:08 -08:00
rdma
rxrpc
scsi include/scsi/: Spelling fixes 2008-02-03 17:47:00 +02:00
sound [ALSA] version 1.0.16rc2 2008-01-31 17:40:18 +01:00
video atmel_lcdfb: backlight control 2008-02-06 10:41:16 -08:00
xen
Kbuild