Skip to content

Commit

Permalink
cgroup: Disable IRQs while holding css_set_lock
Browse files Browse the repository at this point in the history
While testing the deadline scheduler + cgroup setup I hit this
warning.

[  132.612935] ------------[ cut here ]------------
[  132.612951] WARNING: CPU: 5 PID: 0 at kernel/softirq.c:150 __local_bh_enable_ip+0x6b/0x80
[  132.612952] Modules linked in: (a ton of modules...)
[  132.612981] CPU: 5 PID: 0 Comm: swapper/5 Not tainted 4.7.0-rc2 AOSP-JF-MM#2
[  132.612981] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.8.2-20150714_191134- 04/01/2014
[  132.612982]  0000000000000086 45c8bb5effdd088b ffff88013fd43da0 ffffffff813d229e
[  132.612984]  0000000000000000 0000000000000000 ffff88013fd43de0 ffffffff810a652b
[  132.612985]  00000096811387b5 0000000000000200 ffff8800bab29d80 ffff880034c54c00
[  132.612986] Call Trace:
[  132.612987]  <IRQ>  [<ffffffff813d229e>] dump_stack+0x63/0x85
[  132.612994]  [<ffffffff810a652b>] __warn+0xcb/0xf0
[  132.612997]  [<ffffffff810e76a0>] ? push_dl_task.part.32+0x170/0x170
[  132.612999]  [<ffffffff810a665d>] warn_slowpath_null+0x1d/0x20
[  132.613000]  [<ffffffff810aba5b>] __local_bh_enable_ip+0x6b/0x80
[  132.613008]  [<ffffffff817d6c8a>] _raw_write_unlock_bh+0x1a/0x20
[  132.613010]  [<ffffffff817d6c9e>] _raw_spin_unlock_bh+0xe/0x10
[  132.613015]  [<ffffffff811388ac>] put_css_set+0x5c/0x60
[  132.613016]  [<ffffffff8113dc7f>] cgroup_free+0x7f/0xa0
[  132.613017]  [<ffffffff810a3912>] __put_task_struct+0x42/0x140
[  132.613018]  [<ffffffff810e776a>] dl_task_timer+0xca/0x250
[  132.613027]  [<ffffffff810e76a0>] ? push_dl_task.part.32+0x170/0x170
[  132.613030]  [<ffffffff8111371e>] __hrtimer_run_queues+0xee/0x270
[  132.613031]  [<ffffffff81113ec8>] hrtimer_interrupt+0xa8/0x190
[  132.613034]  [<ffffffff81051a58>] local_apic_timer_interrupt+0x38/0x60
[  132.613035]  [<ffffffff817d9b0d>] smp_apic_timer_interrupt+0x3d/0x50
[  132.613037]  [<ffffffff817d7c5c>] apic_timer_interrupt+0x8c/0xa0
[  132.613038]  <EOI>  [<ffffffff81063466>] ? native_safe_halt+0x6/0x10
[  132.613043]  [<ffffffff81037a4e>] default_idle+0x1e/0xd0
[  132.613044]  [<ffffffff810381cf>] arch_cpu_idle+0xf/0x20
[  132.613046]  [<ffffffff810e8fda>] default_idle_call+0x2a/0x40
[  132.613047]  [<ffffffff810e92d7>] cpu_startup_entry+0x2e7/0x340
[  132.613048]  [<ffffffff81050235>] start_secondary+0x155/0x190
[  132.613049] ---[ end trace f91934d162ce9977 ]---

The warn is the spin_(lock|unlock)_bh(&css_set_lock) in the interrupt
context. Converting the spin_lock_bh to spin_lock_irq(save) to avoid
this problem - and other problems of sharing a spinlock with an
interrupt.

Cc: Tejun Heo <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Juri Lelli <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: [email protected]
Cc: [email protected] # 4.5+
Cc: [email protected]
Reviewed-by: Rik van Riel <[email protected]>
Reviewed-by: "Luis Claudio R. Goncalves" <[email protected]>
Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
Acked-by: Zefan Li <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
Signed-off-by: Chatur27 <[email protected]>
Signed-off-by: Marco Zanin <[email protected]>
  • Loading branch information
Daniel Bristot de Oliveira authored and B--B committed Apr 15, 2022
1 parent 9fddb4f commit 1ae607b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1616,10 +1616,10 @@ static int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node,
if (!buf)
return -ENOMEM;

spin_lock_bh(&css_set_lock);
spin_lock_irq(&css_set_lock);
ns_cgroup = current_cgns_cgroup_from_root(kf_cgroot);
len = kernfs_path_from_node(kf_node, ns_cgroup->kn, buf, PATH_MAX);
spin_unlock_bh(&css_set_lock);
spin_unlock_irq(&css_set_lock);

if (len >= PATH_MAX)
len = -ERANGE;
Expand Down Expand Up @@ -2235,11 +2235,11 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
struct cgroup *cgrp;

mutex_lock(&cgroup_mutex);
spin_lock_bh(&css_set_lock);
spin_lock_irq(&css_set_lock);

cgrp = cset_cgroup_from_root(ns->root_cset, root);

spin_unlock_bh(&css_set_lock);
spin_unlock_irq(&css_set_lock);
mutex_unlock(&cgroup_mutex);

nsdentry = kernfs_node_dentry(cgrp->kn, dentry->d_sb);
Expand Down Expand Up @@ -2312,11 +2312,11 @@ int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen,
int ret;

mutex_lock(&cgroup_mutex);
spin_lock_bh(&css_set_lock);
spin_lock_irq(&css_set_lock);

ret = cgroup_path_ns_locked(cgrp, buf, buflen, ns);

spin_unlock_bh(&css_set_lock);
spin_unlock_irq(&css_set_lock);
mutex_unlock(&cgroup_mutex);

return ret;
Expand Down

0 comments on commit 1ae607b

Please sign in to comment.