• 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
cpufreq.c 49.6 KB