From 3c9e49908b882631f3737022e707ffddf0b7c230 Mon Sep 17 00:00:00 2001 From: Minsung Kim Date: Wed, 25 Jun 2014 19:44:50 +0900 Subject: [PATCH] cpufreq: fix sleeping in atomic context when realloc freq_table for all_time_in_state Commit 40cf2f8 (cpufreq: Persist cpufreq time in state data across hotplug) causes the following call trace to be spit on boot: BUG: sleeping function called from invalid context at mm/slub.c:936 in_atomic(): 1, irqs_disabled(): 0, pid: 1, name: swapper/0 CPU: 6 PID: 1 Comm: swapper/0 Not tainted 3.10.9-20140624.172707-eng-gd6c0f69-dirty #50 Backtrace: [] (dump_backtrace+0x0/0x10c) from [] (show_stack+0x18/0x1c) r6:ffff1788 r5:c0c020c0 r4:e609c000 r3:00000000 [] (show_stack+0x0/0x1c) from [] (dump_stack+0x20/0x28) [] (dump_stack+0x0/0x28) from [] (__might_sleep+0x104/0x120) [] (__might_sleep+0x0/0x120) from [] (__kmalloc_track_caller+0x144/0x274) r6:00000000 r5:e609c000 r4:e6802140 [] (__kmalloc_track_caller+0x0/0x274) from [] (krealloc+0x58/0xb0) [] (krealloc+0x0/0xb0) from [] (cpufreq_allstats_create+0x120/0x204) r8:e4c4ff00 r7:c0d266b8 r6:0013d620 r5:e4c4e600 r4:00000001 r3:e535d6d0 [] (cpufreq_allstats_create+0x0/0x204) from [] (cpufreq_stat_notifier_policy+0xb8/0xd0) [] (cpufreq_stat_notifier_policy+0x0/0xd0) from [] (notifier_call_chain+0x4c/0x8c) r5:00000000 r4:fffffffe [] (notifier_call_chain+0x0/0x8c) from [] (__blocking_notifier_call_chain+0x50/0x68) r8:c0cd4d00 r7:00000002 r6:e609dd7c r5:ffffffff r4:c0d25a4c r3:ffffffff [] (__blocking_notifier_call_chain+0x0/0x68) from [] (blocking_notifier_call_chain+0x20/0x28) r7:c0e24f30 r6:00000000 r5:e53e1e00 r4:e609dd7c [] (blocking_notifier_call_chain+0x0/0x28) from [] (__cpufreq_set_policy+0xc0/0x1d0) [] (__cpufreq_set_policy+0x0/0x1d0) from [] (cpufreq_add_dev_interface+0x20c/0x270) r7:00000008 r6:00000000 r5:e53e1e00 r4:e53e1e58 [] (cpufreq_add_dev_interface+0x0/0x270) from [] (cpufreq_add_dev+0x33c/0x420) [] (cpufreq_add_dev+0x0/0x420) from [] (subsys_interface_register+0x80/0xbc) [] (subsys_interface_register+0x0/0xbc) from [] (cpufreq_register_driver+0x8c/0x194) Change-Id: If77a656d0ea60a8fc4083283d104509fa6c07f8f Signed-off-by: Minsung Kim --- drivers/cpufreq/cpufreq_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 3f5e279ff9d8..7a2bcac3ad7f 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -424,7 +424,7 @@ static void add_all_freq_table(unsigned int freq) unsigned int size; size = sizeof(unsigned int) * (all_freq_table->table_size + 1); all_freq_table->freq_table = krealloc(all_freq_table->freq_table, - size, GFP_KERNEL); + size, GFP_ATOMIC); if (IS_ERR(all_freq_table->freq_table)) { pr_warn("Could not reallocate memory for freq_table\n"); all_freq_table->freq_table = NULL; -- 2.34.1