linux-stable/drivers
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
..
acorn/char
acpi latency.c: use QoS infrastructure 2008-02-05 09:44:22 -08:00
amba
ata ata_piix.c:piix_init_one() must be __devinit 2008-02-06 07:01:56 -05:00
atm
auxdisplay
base register_cpu __devinit or __cpuinit 2008-02-06 10:41:01 -08:00
block Atari floppy: Rename disk_type to atari_disk_type 2008-02-06 10:41:10 -08:00
bluetooth Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-02-05 10:09:07 -08:00
cdrom drivers/cdrom/cdrom.c: simplify logic in cdrom_release() 2008-02-06 10:41:10 -08:00
char ip27-rtc: convert ioctl to unlocked_ioctl 2008-02-06 10:41:14 -08:00
clocksource
connector [NETNS]: Consolidate kernel netlink socket destruction. 2008-01-28 15:08:07 -08:00
cpufreq [CPUFREQ] Eliminate cpufreq_userspace scaling_setspeed deadlock 2008-02-06 22:57:58 -05:00
cpuidle pm qos infrastructure and interface 2008-02-05 09:44:22 -08:00
crypto
dca
dio dio: ARRAY_SIZE() cleanup 2008-02-05 09:44:23 -08:00
dma async_tx: replace 'int_en' with operation preparation flags 2008-02-06 10:12:18 -07:00
edac drivers/edac/: Spelling fixes 2008-02-03 17:12:34 +02:00
eisa
firewire firewire: fw-sbp2: Use sbp2 device-provided mgt orb timeout for logins 2008-01-30 22:22:29 +01:00
firmware dcdbas: add DMI-based module autloading 2008-02-06 10:41:01 -08:00
gpio gpio: handle pca953{4,5,6,7,8} too 2008-02-06 10:41:15 -08:00
hid
hwmon
i2c deprecate obsolete pca9539 driver 2008-02-05 09:44:13 -08:00
ide Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev 2008-02-06 10:47:46 -08:00
ieee1394 ieee1394: sbp2: fix bogus s/g access change 2008-02-02 13:48:16 +01:00
infiniband RDMA/nes: Add a driver for NetEffect RNICs 2008-02-04 20:20:45 -08:00
input Remove pointless casts from void pointers 2008-02-06 10:41:01 -08:00
isdn drivers/isdn/hardware/eicon/debug.c: fix uninitialized var warning 2008-02-06 10:41:12 -08:00
leds leds: add possibility to remove leds classdevs during suspend/resume 2008-02-05 09:44:23 -08:00
lguest virtio: reset function 2008-02-04 23:50:03 +11:00
macintosh ppc: fix #ifdef-s in mediabay driver (take 2) 2008-02-06 02:57:50 +01:00
mca
md md: fix an occasional deadlock in raid5 2008-02-06 10:41:19 -08:00
media scheduled OSS driver removal 2008-02-06 10:41:02 -08:00
message drivers/message/: Spelling fixes 2008-02-03 17:21:01 +02:00
mfd
misc phantom: don't grab other devices 2008-02-06 10:41:10 -08:00
mmc
mtd Claim maintainership for block2mtd and update email addresses 2008-02-06 10:41:09 -08:00
net Merge branch 'upstream-davem' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6 2008-02-06 03:52:44 -08:00
nubus nubus: kill drivers/nubus/nubus_syms.c 2008-02-05 09:44:23 -08:00
of
oprofile
parisc iommu sg merging: parisc: make iommu respect the segment size limits 2008-02-05 09:44:10 -08:00
parport parport_pc: detection for SuperIO IT87XX POST 2008-02-06 10:41:08 -08:00
pci Genericizing iova.[ch] 2008-02-06 10:41:01 -08:00
pcmcia drivers/pcmcia: add missing pci_dev_get 2008-02-05 09:44:09 -08:00
pnp PNP: disable Supermicro H8DCE motherboard resources that overlap SATA BARs 2008-02-06 10:41:20 -08:00
power apm_power: check I.intval for zero value, we use it as the divisor 2008-02-02 02:44:34 +03:00
ps3 ps3: use symbolic names for video modes 2008-02-06 10:41:17 -08:00
rapidio Merge branch 'linux-2.6' 2008-01-31 11:25:51 +11:00
rtc rtc: at91sam9 RTC support (RTT and/or RTC) 2008-02-06 10:41:14 -08:00
s390 calibrate_delay() must be __cpuinit 2008-02-06 10:41:08 -08:00
sbus
scsi scsi: megaraid: trivial drop duplicate mutex.h include 2008-02-06 11:15:41 -08:00
serial SC26XX: New serial driver for SC2681 uarts 2008-02-06 10:41:06 -08:00
sh
sn
spi spi: remove more dev->power.power_state usage 2008-02-06 10:41:11 -08:00
ssb drivers/ssb/: Spelling fixes 2008-02-03 17:30:25 +02:00
tc
telephony
uio uio: nopage 2008-02-06 10:41:07 -08:00
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/pci-2.6 2008-02-02 14:29:33 +11:00
video fb: fix warning: no return statement in function returning non-void 2008-02-06 10:41:21 -08:00
virtio virtio: add missing #include <linux/delay.h> 2008-02-06 10:41:21 -08:00
w1 w1-gpio: add GPIO w1 bus master driver 2008-02-06 10:41:15 -08:00
watchdog drivers/watchdog/: Spelling fixes 2008-02-03 17:32:52 +02:00
xen
zorro
Kconfig gpiolib: add drivers/gpio directory 2008-02-05 09:44:12 -08:00
Makefile gpiolib: add drivers/gpio directory 2008-02-05 09:44:12 -08:00