Commit ffea73fc723a12fdde4c9fb3fcce5d154d1104a1
Committed by
Jens Axboe
1 parent
fd7949564c
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
block: blkcg_policy_cfq shouldn't be used if !CONFIG_CFQ_GROUP_IOSCHED
cfq may be built w/ or w/o blkcg support depending on CONFIG_CFQ_CGROUP_IOSCHED. If blkcg support is disabled, most of related code is ifdef'd out but some part is left dangling - blkcg_policy_cfq is left zero-filled and blkcg_policy_[un]register() calls are made on it. Feeding zero filled policy to blkcg_policy_register() is incorrect and triggers the following WARN_ON() if CONFIG_BLK_CGROUP && !CONFIG_CFQ_GROUP_IOSCHED. ------------[ cut here ]------------ WARNING: at block/blk-cgroup.c:867 Modules linked in: Modules linked in: CPU: 3 Not tainted 3.4.0-09547-gfb21aff #1 Process swapper/0 (pid: 1, task: 000000003ff80000, ksp: 000000003ff7f8b8) Krnl PSW : 0704100180000000 00000000003d76ca (blkcg_policy_register+0xca/0xe0) R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:0 CC:1 PM:0 EA:3 Krnl GPRS: 0000000000000000 00000000014b85ec 00000000014b85b0 0000000000000000 000000000096fb60 0000000000000000 00000000009a8e78 0000000000000048 000000000099c070 0000000000b6f000 0000000000000000 000000000099c0b8 00000000014b85b0 0000000000667580 000000003ff7fd98 000000003ff7fd70 Krnl Code: 00000000003d76be: a7280001 lhi %r2,1 00000000003d76c2: a7f4ffdf brc 15,3d7680 #00000000003d76c6: a7f40001 brc 15,3d76c8 >00000000003d76ca: a7c8ffea lhi %r12,-22 00000000003d76ce: a7f4ffce brc 15,3d766a 00000000003d76d2: a7f40001 brc 15,3d76d4 00000000003d76d6: a7c80000 lhi %r12,0 00000000003d76da: a7f4ffc2 brc 15,3d765e Call Trace: ([<0000000000b6f000>] initcall_debug+0x0/0x4) [<0000000000989e8a>] cfq_init+0x62/0xd4 [<00000000001000ba>] do_one_initcall+0x3a/0x170 [<000000000096fb60>] kernel_init+0x214/0x2bc [<0000000000623202>] kernel_thread_starter+0x6/0xc [<00000000006231fc>] kernel_thread_starter+0x0/0xc no locks held by swapper/0/1. Last Breaking-Event-Address: [<00000000003d76c6>] blkcg_policy_register+0xc6/0xe0 ---[ end trace b8ef4903fcbf9dd3 ]--- This patch fixes the problem by ensuring all blkcg support code is inside CONFIG_CFQ_GROUP_IOSCHED. * blkcg_policy_cfq declaration and blkg_to_cfqg() definition are moved inside the first CONFIG_CFQ_GROUP_IOSCHED block. __maybe_unused is dropped from blkcg_policy_cfq decl. * blkcg_deactivate_poilcy() invocation is moved inside ifdef. This also makes the activation logic match cfq_init_queue(). * All blkcg_policy_[un]register() invocations are moved inside ifdef. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com> LKML-Reference: <20120601112954.GC3535@osiris.boeblingen.de.ibm.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Showing 1 changed file with 17 additions and 12 deletions Side-by-side Diff
block/cfq-iosched.c
... | ... | @@ -17,8 +17,6 @@ |
17 | 17 | #include "blk.h" |
18 | 18 | #include "blk-cgroup.h" |
19 | 19 | |
20 | -static struct blkcg_policy blkcg_policy_cfq __maybe_unused; | |
21 | - | |
22 | 20 | /* |
23 | 21 | * tunables |
24 | 22 | */ |
... | ... | @@ -418,11 +416,6 @@ |
418 | 416 | return pd ? container_of(pd, struct cfq_group, pd) : NULL; |
419 | 417 | } |
420 | 418 | |
421 | -static inline struct cfq_group *blkg_to_cfqg(struct blkcg_gq *blkg) | |
422 | -{ | |
423 | - return pd_to_cfqg(blkg_to_pd(blkg, &blkcg_policy_cfq)); | |
424 | -} | |
425 | - | |
426 | 419 | static inline struct blkcg_gq *cfqg_to_blkg(struct cfq_group *cfqg) |
427 | 420 | { |
428 | 421 | return pd_to_blkg(&cfqg->pd); |
... | ... | @@ -572,6 +565,13 @@ |
572 | 565 | |
573 | 566 | #ifdef CONFIG_CFQ_GROUP_IOSCHED |
574 | 567 | |
568 | +static struct blkcg_policy blkcg_policy_cfq; | |
569 | + | |
570 | +static inline struct cfq_group *blkg_to_cfqg(struct blkcg_gq *blkg) | |
571 | +{ | |
572 | + return pd_to_cfqg(blkg_to_pd(blkg, &blkcg_policy_cfq)); | |
573 | +} | |
574 | + | |
575 | 575 | static inline void cfqg_get(struct cfq_group *cfqg) |
576 | 576 | { |
577 | 577 | return blkg_get(cfqg_to_blkg(cfqg)); |
578 | 578 | |
... | ... | @@ -3951,10 +3951,11 @@ |
3951 | 3951 | |
3952 | 3952 | cfq_shutdown_timer_wq(cfqd); |
3953 | 3953 | |
3954 | -#ifndef CONFIG_CFQ_GROUP_IOSCHED | |
3954 | +#ifdef CONFIG_CFQ_GROUP_IOSCHED | |
3955 | + blkcg_deactivate_policy(q, &blkcg_policy_cfq); | |
3956 | +#else | |
3955 | 3957 | kfree(cfqd->root_group); |
3956 | 3958 | #endif |
3957 | - blkcg_deactivate_policy(q, &blkcg_policy_cfq); | |
3958 | 3959 | kfree(cfqd); |
3959 | 3960 | } |
3960 | 3961 | |
3961 | 3962 | |
... | ... | @@ -4194,13 +4195,13 @@ |
4194 | 4195 | #ifdef CONFIG_CFQ_GROUP_IOSCHED |
4195 | 4196 | if (!cfq_group_idle) |
4196 | 4197 | cfq_group_idle = 1; |
4197 | -#else | |
4198 | - cfq_group_idle = 0; | |
4199 | -#endif | |
4200 | 4198 | |
4201 | 4199 | ret = blkcg_policy_register(&blkcg_policy_cfq); |
4202 | 4200 | if (ret) |
4203 | 4201 | return ret; |
4202 | +#else | |
4203 | + cfq_group_idle = 0; | |
4204 | +#endif | |
4204 | 4205 | |
4205 | 4206 | ret = -ENOMEM; |
4206 | 4207 | cfq_pool = KMEM_CACHE(cfq_queue, 0); |
4207 | 4208 | |
4208 | 4209 | |
4209 | 4210 | |
... | ... | @@ -4216,13 +4217,17 @@ |
4216 | 4217 | err_free_pool: |
4217 | 4218 | kmem_cache_destroy(cfq_pool); |
4218 | 4219 | err_pol_unreg: |
4220 | +#ifdef CONFIG_CFQ_GROUP_IOSCHED | |
4219 | 4221 | blkcg_policy_unregister(&blkcg_policy_cfq); |
4222 | +#endif | |
4220 | 4223 | return ret; |
4221 | 4224 | } |
4222 | 4225 | |
4223 | 4226 | static void __exit cfq_exit(void) |
4224 | 4227 | { |
4228 | +#ifdef CONFIG_CFQ_GROUP_IOSCHED | |
4225 | 4229 | blkcg_policy_unregister(&blkcg_policy_cfq); |
4230 | +#endif | |
4226 | 4231 | elv_unregister(&iosched_cfq); |
4227 | 4232 | kmem_cache_destroy(cfq_pool); |
4228 | 4233 | } |