* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-04-08 3:34 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-04-08 3:34 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 3191c9e4e7c581bfe0a40ee198ffcbd5c3dea53e
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 20 hours ago
:::::: commit date: 3 years, 1 month ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250408/202504081102.ziLuPC5Y-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202504081102.ziLuPC5Y-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-04-17 22:31 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-04-17 22:31 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: c61927b921388695af91d0e58b8709040ed6cb17
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 19 hours ago
:::::: commit date: 3 years, 1 month ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250418/202504180632.A7DdIQdn-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202504180632.A7DdIQdn-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-04-25 11:55 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-04-25 11:55 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 08111f03f1ec65598372cfe9bf64f366d575671e
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 29 hours ago
:::::: commit date: 3 years, 2 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250425/202504251907.byTlI08E-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202504251907.byTlI08E-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-04-29 3:17 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-04-29 3:17 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 7bd21c560a6f5df598200cc367cad1a683cef8ef
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 71 minutes ago
:::::: commit date: 3 years, 2 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250429/202504291112.fWe6OzOY-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202504291112.fWe6OzOY-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-04-30 17:20 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-04-30 17:20 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: a48a35466505c8a52da57596944bd0b4485e825f
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 29 hours ago
:::::: commit date: 3 years, 2 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250501/202505010106.5NSerg6E-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202505010106.5NSerg6E-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-05-05 21:27 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-05-05 21:27 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: a48a35466505c8a52da57596944bd0b4485e825f
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 7 days ago
:::::: commit date: 3 years, 2 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250506/202505060722.BJvXgwm2-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202505060722.BJvXgwm2-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-05-28 13:41 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-05-28 13:41 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 5ae76523ccf96ec8b8d73d541e305bf15b6b697e
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 2 days ago
:::::: commit date: 3 years, 3 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250528/202505282114.vFYiO5KQ-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202505282114.vFYiO5KQ-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-06-05 3:27 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-06-05 3:27 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: f86f8706481a23ecd781d2d13c3815a7fb4cc312
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 2 days ago
:::::: commit date: 3 years, 3 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250605/202506051154.5ALhnBzP-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202506051154.5ALhnBzP-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2192
ae1188963611119 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae1188963611119 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec8 Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333f Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae1188963611119 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7e Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba91505 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153ca Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2203
ae1188963611119 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae1188963611119 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d2 Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153ca Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153ca Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5ed Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153ca Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2211
e43473b7f223ec8 Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e490956 Tejun Heo 2015-08-18 2213
b9147dd1bae2b15 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2215
c9589f03e490956 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153ca Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1d Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2221
73f0d49a9637a7e Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7e Tejun Heo 2013-05-14 2223
c79892c5576163b Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5a Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df5 Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df5 Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e2 Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5a Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba91505 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5a Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5a Tejun Heo 2013-05-14 2233
9e660acffcd1b5a Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163b Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df5 Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b15 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163b Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163b Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5a Tejun Heo 2013-05-14 2241 break;
c79892c5576163b Shaohua Li 2017-03-27 2242 }
de701c74a34005e Vivek Goyal 2011-03-07 2243
9e660acffcd1b5a Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec8 Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11e Vivek Goyal 2011-03-22 2246
04521db04e9a11e Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11e Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11e Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11e Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11e Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11e Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11e Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11e Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11e Vivek Goyal 2011-03-22 2255 *
04521db04e9a11e Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11e Vivek Goyal 2011-03-22 2257 */
0f3457f60edc573 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5a Tejun Heo 2013-05-14 2259
9e660acffcd1b5a Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5a Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5a Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5a Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5a Tejun Heo 2013-05-14 2264 */
c5cc2070b45333f Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5a Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5a Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5a Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153ca Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2271
9e660acffcd1b5a Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7ac Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede246 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a60248 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a60248 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a60248 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7e Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2279
3f0abd806651df5 Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2281
b9147dd1bae2b15 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333f Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2285
7f52f98c2a83339 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a83339 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a83339 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a83339 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a83339 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a83339 Tejun Heo 2013-05-14 2291 */
0e9f4164ba91505 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b048481781 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a83339 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2296
bc16a4f933bc5ed Tejun Heo 2011-10-19 2297 out:
111be883981748a Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2299
b9147dd1bae2b15 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b15 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd72 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153ca Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153ca Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5ed Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-06-07 9:37 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-06-07 9:37 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 31245821cb3d54a27ff007515f57af84d6842846
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 7 hours ago
:::::: commit date: 3 years, 3 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250607/202506071711.nmLl67SN-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202506071711.nmLl67SN-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-06-15 1:03 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-06-15 1:03 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 7b14992c5fc2361904e3c2f345fe502cf7961adb
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 4 days ago
:::::: commit date: 3 years, 3 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250615/202506150922.Sv0hlBx2-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202506150922.Sv0hlBx2-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-06-17 21:44 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-06-17 21:44 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 7b14992c5fc2361904e3c2f345fe502cf7961adb
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 7 days ago
:::::: commit date: 3 years, 3 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250618/202506180528.XBq73b1G-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202506180528.XBq73b1G-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-06-25 23:25 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-06-25 23:25 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 2095c984bc19c926a057ed0e96b9f795b4c504b4
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 6 days ago
:::::: commit date: 3 years, 4 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250626/202506260745.pkFhz9m2-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202506260745.pkFhz9m2-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2192
ae1188963611119 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae1188963611119 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec8 Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333f Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae1188963611119 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7e Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba91505 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153ca Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2203
ae1188963611119 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae1188963611119 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d2 Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153ca Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153ca Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5ed Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153ca Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2211
e43473b7f223ec8 Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e490956 Tejun Heo 2015-08-18 2213
b9147dd1bae2b15 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2215
c9589f03e490956 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153ca Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1d Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2221
73f0d49a9637a7e Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7e Tejun Heo 2013-05-14 2223
c79892c5576163b Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5a Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df5 Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df5 Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e2 Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5a Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba91505 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5a Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5a Tejun Heo 2013-05-14 2233
9e660acffcd1b5a Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163b Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df5 Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b15 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163b Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163b Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5a Tejun Heo 2013-05-14 2241 break;
c79892c5576163b Shaohua Li 2017-03-27 2242 }
de701c74a34005e Vivek Goyal 2011-03-07 2243
9e660acffcd1b5a Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec8 Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11e Vivek Goyal 2011-03-22 2246
04521db04e9a11e Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11e Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11e Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11e Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11e Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11e Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11e Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11e Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11e Vivek Goyal 2011-03-22 2255 *
04521db04e9a11e Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11e Vivek Goyal 2011-03-22 2257 */
0f3457f60edc573 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5a Tejun Heo 2013-05-14 2259
9e660acffcd1b5a Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5a Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5a Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5a Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5a Tejun Heo 2013-05-14 2264 */
c5cc2070b45333f Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5a Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5a Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5a Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153ca Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2271
9e660acffcd1b5a Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7ac Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede246 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a60248 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a60248 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a60248 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7e Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2279
3f0abd806651df5 Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2281
b9147dd1bae2b15 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333f Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2285
7f52f98c2a83339 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a83339 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a83339 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a83339 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a83339 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a83339 Tejun Heo 2013-05-14 2291 */
0e9f4164ba91505 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b048481781 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a83339 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2296
bc16a4f933bc5ed Tejun Heo 2011-10-19 2297 out:
111be883981748a Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2299
b9147dd1bae2b15 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b15 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd72 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153ca Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153ca Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5ed Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-07-02 22:21 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-07-02 22:21 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: d96cd567c8d8d584405abe92c2576bf58202fa6e
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 19 hours ago
:::::: commit date: 3 years, 4 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250703/202507030630.vbiciLpo-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202507030630.vbiciLpo-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-07-04 12:38 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-07-04 12:38 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 44dfa3e24fdde8e95b4815dc4d365cb20755a5e4
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 5 hours ago
:::::: commit date: 3 years, 4 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250704/202507042042.b6uSHoZy-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202507042042.b6uSHoZy-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-07-07 7:14 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-07-07 7:14 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: e6b6811414fe4cfc995369e8bda32fc1b4ee1d51
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 2 days ago
:::::: commit date: 3 years, 4 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250707/202507071430.FLaGv5Ar-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202507071430.FLaGv5Ar-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2192
ae1188963611119 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae1188963611119 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec8 Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333f Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae1188963611119 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7e Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba91505 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153ca Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2203
ae1188963611119 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae1188963611119 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d2 Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153ca Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153ca Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5ed Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153ca Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2211
e43473b7f223ec8 Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e490956 Tejun Heo 2015-08-18 2213
b9147dd1bae2b15 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2215
c9589f03e490956 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153ca Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1d Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2221
73f0d49a9637a7e Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7e Tejun Heo 2013-05-14 2223
c79892c5576163b Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5a Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df5 Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df5 Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e2 Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5a Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba91505 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5a Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5a Tejun Heo 2013-05-14 2233
9e660acffcd1b5a Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163b Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df5 Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b15 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163b Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163b Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5a Tejun Heo 2013-05-14 2241 break;
c79892c5576163b Shaohua Li 2017-03-27 2242 }
de701c74a34005e Vivek Goyal 2011-03-07 2243
9e660acffcd1b5a Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec8 Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11e Vivek Goyal 2011-03-22 2246
04521db04e9a11e Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11e Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11e Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11e Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11e Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11e Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11e Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11e Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11e Vivek Goyal 2011-03-22 2255 *
04521db04e9a11e Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11e Vivek Goyal 2011-03-22 2257 */
0f3457f60edc573 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5a Tejun Heo 2013-05-14 2259
9e660acffcd1b5a Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5a Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5a Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5a Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5a Tejun Heo 2013-05-14 2264 */
c5cc2070b45333f Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5a Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5a Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5a Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153ca Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2271
9e660acffcd1b5a Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7ac Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede246 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a60248 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a60248 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a60248 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7e Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2279
3f0abd806651df5 Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2281
b9147dd1bae2b15 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333f Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2285
7f52f98c2a83339 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a83339 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a83339 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a83339 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a83339 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a83339 Tejun Heo 2013-05-14 2291 */
0e9f4164ba91505 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b048481781 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a83339 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2296
bc16a4f933bc5ed Tejun Heo 2011-10-19 2297 out:
111be883981748a Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2299
b9147dd1bae2b15 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b15 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd72 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153ca Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153ca Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5ed Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-07-15 15:51 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-07-15 15:51 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: eabd480503b5c662a59778c9fa8c1a8f611d724e
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 7 hours ago
:::::: commit date: 3 years, 4 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250715/202507152319.7qVm9PxC-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202507152319.7qVm9PxC-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2192
ae1188963611119 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae1188963611119 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec8 Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333f Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae1188963611119 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7e Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba91505 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153ca Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2203
ae1188963611119 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae1188963611119 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d2 Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153ca Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153ca Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5ed Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153ca Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2211
e43473b7f223ec8 Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e490956 Tejun Heo 2015-08-18 2213
b9147dd1bae2b15 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2215
c9589f03e490956 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153ca Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1d Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2221
73f0d49a9637a7e Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7e Tejun Heo 2013-05-14 2223
c79892c5576163b Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5a Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df5 Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df5 Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e2 Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5a Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba91505 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5a Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5a Tejun Heo 2013-05-14 2233
9e660acffcd1b5a Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163b Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df5 Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b15 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163b Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163b Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5a Tejun Heo 2013-05-14 2241 break;
c79892c5576163b Shaohua Li 2017-03-27 2242 }
de701c74a34005e Vivek Goyal 2011-03-07 2243
9e660acffcd1b5a Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec8 Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11e Vivek Goyal 2011-03-22 2246
04521db04e9a11e Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11e Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11e Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11e Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11e Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11e Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11e Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11e Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11e Vivek Goyal 2011-03-22 2255 *
04521db04e9a11e Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11e Vivek Goyal 2011-03-22 2257 */
0f3457f60edc573 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5a Tejun Heo 2013-05-14 2259
9e660acffcd1b5a Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5a Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5a Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5a Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5a Tejun Heo 2013-05-14 2264 */
c5cc2070b45333f Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5a Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5a Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5a Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153ca Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2271
9e660acffcd1b5a Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7ac Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede246 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a60248 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a60248 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a60248 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7e Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2279
3f0abd806651df5 Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2281
b9147dd1bae2b15 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333f Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2285
7f52f98c2a83339 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a83339 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a83339 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a83339 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a83339 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a83339 Tejun Heo 2013-05-14 2291 */
0e9f4164ba91505 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b048481781 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a83339 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2296
bc16a4f933bc5ed Tejun Heo 2011-10-19 2297 out:
111be883981748a Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2299
b9147dd1bae2b15 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b15 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd72 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153ca Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153ca Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5ed Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-07-23 16:02 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-07-23 16:02 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: ec206d272f0e39511777d67fe7995c8b6fd1681b
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 5 days ago
:::::: commit date: 3 years, 5 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250723/202507232322.OAvtlnwI-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202507232322.OAvtlnwI-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-07-29 13:28 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-07-29 13:28 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 859de5033e15abefcf19935429e6478be97d889a
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 12 hours ago
:::::: commit date: 3 years, 5 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250729/202507292155.4p73oKoA-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202507292155.4p73oKoA-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-07-30 14:00 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-07-30 14:00 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 859de5033e15abefcf19935429e6478be97d889a
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 2 days ago
:::::: commit date: 3 years, 5 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250730/202507302147.RO0OTrGc-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202507302147.RO0OTrGc-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-08-07 20:06 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-08-07 20:06 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 748957057cef2d3b3e35d749c9a1ade66e2b5e73
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 12 hours ago
:::::: commit date: 3 years, 5 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250808/202508080301.GtRv5K2M-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202508080301.GtRv5K2M-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-08-08 10:45 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-08-08 10:45 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 748957057cef2d3b3e35d749c9a1ade66e2b5e73
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 26 hours ago
:::::: commit date: 3 years, 5 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250808/202508081823.ngj9xPnJ-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202508081823.ngj9xPnJ-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-08-16 7:33 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-08-16 7:33 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: bb7bded3da5e82ce40450cdb7a128c41403bf330
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 6 hours ago
:::::: commit date: 3 years, 5 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250816/202508161508.2wQiyacf-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202508161508.2wQiyacf-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-08-24 6:09 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-08-24 6:09 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 7ca8f70fcd371eeaeba54893cc754f3e18714fae
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 3 days ago
:::::: commit date: 3 years, 6 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250824/202508241455.Hw9lAo3X-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202508241455.Hw9lAo3X-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-09-01 5:00 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-09-01 5:00 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 7dd09dff93e7ad921baf5cec4b58301d9aebb79a
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 2 days ago
:::::: commit date: 3 years, 6 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250901/202509011252.w8sb7vl5-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202509011252.w8sb7vl5-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2192
ae1188963611119 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae1188963611119 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec8 Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333f Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae1188963611119 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7e Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba91505 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153ca Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2203
ae1188963611119 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae1188963611119 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d2 Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153ca Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153ca Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5ed Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153ca Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2211
e43473b7f223ec8 Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e490956 Tejun Heo 2015-08-18 2213
b9147dd1bae2b15 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2215
c9589f03e490956 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153ca Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1d Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff2 Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e8 Shaohua Li 2017-03-27 2221
73f0d49a9637a7e Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7e Tejun Heo 2013-05-14 2223
c79892c5576163b Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5a Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df5 Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df5 Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e2 Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5a Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba91505 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5a Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5a Tejun Heo 2013-05-14 2233
9e660acffcd1b5a Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163b Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df5 Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b15 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163b Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163b Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5a Tejun Heo 2013-05-14 2241 break;
c79892c5576163b Shaohua Li 2017-03-27 2242 }
de701c74a34005e Vivek Goyal 2011-03-07 2243
9e660acffcd1b5a Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec8 Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11e Vivek Goyal 2011-03-22 2246
04521db04e9a11e Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11e Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11e Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11e Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11e Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11e Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11e Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11e Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11e Vivek Goyal 2011-03-22 2255 *
04521db04e9a11e Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11e Vivek Goyal 2011-03-22 2257 */
0f3457f60edc573 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5a Tejun Heo 2013-05-14 2259
9e660acffcd1b5a Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5a Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5a Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5a Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5a Tejun Heo 2013-05-14 2264 */
c5cc2070b45333f Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5a Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5a Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5a Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153ca Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2271
9e660acffcd1b5a Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7ac Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede246 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a60248 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a60248 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a60248 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7e Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2279
3f0abd806651df5 Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df5 Shaohua Li 2017-03-27 2281
b9147dd1bae2b15 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333f Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5ed Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2285
7f52f98c2a83339 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a83339 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a83339 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a83339 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a83339 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a83339 Tejun Heo 2013-05-14 2291 */
0e9f4164ba91505 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b048481781 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a83339 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec8 Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2296
bc16a4f933bc5ed Tejun Heo 2011-10-19 2297 out:
111be883981748a Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b15 Shaohua Li 2017-03-27 2299
b9147dd1bae2b15 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b15 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd72 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b15 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153ca Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153ca Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5ed Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec8 Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec8 Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-09-01 12:23 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-09-01 12:23 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 73bffb6a755d7ec519eefa4c67c236ed58888905
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 5 hours ago
:::::: commit date: 3 years, 6 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250901/202509012020.P1RhMhQr-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202509012020.P1RhMhQr-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
* [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212
@ 2025-09-02 12:42 kernel test robot
0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2025-09-02 12:42 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Julia Lawall
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: kernel@openeuler.org
TO: Yang Yingliang <yangyingliang@huawei.com>
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 54968bf23106d2ac31ede8dca013a7fadeb3dd75
commit: e1c15e207d153cafb3f3aa1cbc8000134fae1d40 [1568/1568] blk-throttle: Set BIO_THROTTLED when bio has been throttled
:::::: branch date: 24 hours ago
:::::: commit date: 3 years, 6 months ago
config: x86_64-randconfig-102-20250408 (https://download.01.org/0day-ci/archive/20250902/202509022019.GVHWqrP5-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202509022019.GVHWqrP5-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> block/blk-throttle.c:2306:1-7: preceding lock on line 2212
vim +2306 block/blk-throttle.c
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2192
ae118896361111 Tejun Heo 2015-08-18 2193 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
ae118896361111 Tejun Heo 2015-08-18 2194 struct bio *bio)
e43473b7f223ec Vivek Goyal 2010-09-15 2195 {
c5cc2070b45333 Tejun Heo 2013-05-14 2196 struct throtl_qnode *qn = NULL;
ae118896361111 Tejun Heo 2015-08-18 2197 struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg);
73f0d49a9637a7 Tejun Heo 2013-05-14 2198 struct throtl_service_queue *sq;
0e9f4164ba9150 Tejun Heo 2013-05-14 2199 bool rw = bio_data_dir(bio);
bc16a4f933bc5e Tejun Heo 2011-10-19 2200 bool throttled = false;
e1c15e207d153c Laibin Qiu 2022-03-08 2201 bool locked = true;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2202 struct throtl_data *td = tg->td;
e43473b7f223ec Vivek Goyal 2010-09-15 2203
ae118896361111 Tejun Heo 2015-08-18 2204 WARN_ON_ONCE(!rcu_read_lock_held());
ae118896361111 Tejun Heo 2015-08-18 2205
2a0f61e6ecd08d Tejun Heo 2013-05-14 2206 /* see throtl_charge_bio() */
e1c15e207d153c Laibin Qiu 2022-03-08 2207 if (bio_flagged(bio, BIO_THROTTLED) || !tg->has_rules[rw]) {
e1c15e207d153c Laibin Qiu 2022-03-08 2208 locked = false;
bc16a4f933bc5e Tejun Heo 2011-10-19 2209 goto out;
e1c15e207d153c Laibin Qiu 2022-03-08 2210 }
e43473b7f223ec Vivek Goyal 2010-09-15 2211
e43473b7f223ec Vivek Goyal 2010-09-15 @2212 spin_lock_irq(q->queue_lock);
c9589f03e49095 Tejun Heo 2015-08-18 2213
b9147dd1bae2b1 Shaohua Li 2017-03-27 2214 throtl_update_latency_buckets(td);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2215
c9589f03e49095 Tejun Heo 2015-08-18 2216 if (unlikely(blk_queue_bypass(q)))
e1c15e207d153c Laibin Qiu 2022-03-08 2217 goto out;
f469a7b4d5b1d1 Vivek Goyal 2011-05-19 2218
2bc19cd5fdb5ff Jens Axboe 2017-04-20 2219 blk_throtl_assoc_bio(tg, bio);
9e234eeafbe17e Shaohua Li 2017-03-27 2220 blk_throtl_update_idletime(tg);
9e234eeafbe17e Shaohua Li 2017-03-27 2221
73f0d49a9637a7 Tejun Heo 2013-05-14 2222 sq = &tg->service_queue;
73f0d49a9637a7 Tejun Heo 2013-05-14 2223
c79892c5576163 Shaohua Li 2017-03-27 2224 again:
9e660acffcd1b5 Tejun Heo 2013-05-14 2225 while (true) {
3f0abd806651df Shaohua Li 2017-03-27 2226 if (tg->last_low_overflow_time[rw] == 0)
3f0abd806651df Shaohua Li 2017-03-27 2227 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2228 throtl_downgrade_check(tg);
fa6fb5aab85f3e Shaohua Li 2017-03-27 2229 throtl_upgrade_check(tg);
9e660acffcd1b5 Tejun Heo 2013-05-14 2230 /* throtl is FIFO - if bios are already queued, should queue */
0e9f4164ba9150 Tejun Heo 2013-05-14 2231 if (sq->nr_queued[rw])
9e660acffcd1b5 Tejun Heo 2013-05-14 2232 break;
9e660acffcd1b5 Tejun Heo 2013-05-14 2233
9e660acffcd1b5 Tejun Heo 2013-05-14 2234 /* if above limits, break to queue */
c79892c5576163 Shaohua Li 2017-03-27 2235 if (!tg_may_dispatch(tg, bio, NULL)) {
3f0abd806651df Shaohua Li 2017-03-27 2236 tg->last_low_overflow_time[rw] = jiffies;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2237 if (throtl_can_upgrade(td, tg)) {
b9147dd1bae2b1 Shaohua Li 2017-03-27 2238 throtl_upgrade_state(td);
c79892c5576163 Shaohua Li 2017-03-27 2239 goto again;
c79892c5576163 Shaohua Li 2017-03-27 2240 }
9e660acffcd1b5 Tejun Heo 2013-05-14 2241 break;
c79892c5576163 Shaohua Li 2017-03-27 2242 }
de701c74a34005 Vivek Goyal 2011-03-07 2243
9e660acffcd1b5 Tejun Heo 2013-05-14 2244 /* within limits, let's charge and dispatch directly */
e43473b7f223ec Vivek Goyal 2010-09-15 2245 throtl_charge_bio(tg, bio);
04521db04e9a11 Vivek Goyal 2011-03-22 2246
04521db04e9a11 Vivek Goyal 2011-03-22 2247 /*
04521db04e9a11 Vivek Goyal 2011-03-22 2248 * We need to trim slice even when bios are not being queued
04521db04e9a11 Vivek Goyal 2011-03-22 2249 * otherwise it might happen that a bio is not queued for
04521db04e9a11 Vivek Goyal 2011-03-22 2250 * a long time and slice keeps on extending and trim is not
04521db04e9a11 Vivek Goyal 2011-03-22 2251 * called for a long time. Now if limits are reduced suddenly
04521db04e9a11 Vivek Goyal 2011-03-22 2252 * we take into account all the IO dispatched so far at new
04521db04e9a11 Vivek Goyal 2011-03-22 2253 * low rate and * newly queued IO gets a really long dispatch
04521db04e9a11 Vivek Goyal 2011-03-22 2254 * time.
04521db04e9a11 Vivek Goyal 2011-03-22 2255 *
04521db04e9a11 Vivek Goyal 2011-03-22 2256 * So keep on trimming slice even if bio is not queued.
04521db04e9a11 Vivek Goyal 2011-03-22 2257 */
0f3457f60edc57 Tejun Heo 2013-05-14 2258 throtl_trim_slice(tg, rw);
9e660acffcd1b5 Tejun Heo 2013-05-14 2259
9e660acffcd1b5 Tejun Heo 2013-05-14 2260 /*
9e660acffcd1b5 Tejun Heo 2013-05-14 2261 * @bio passed through this layer without being throttled.
9e660acffcd1b5 Tejun Heo 2013-05-14 2262 * Climb up the ladder. If we''re already at the top, it
9e660acffcd1b5 Tejun Heo 2013-05-14 2263 * can be executed directly.
9e660acffcd1b5 Tejun Heo 2013-05-14 2264 */
c5cc2070b45333 Tejun Heo 2013-05-14 2265 qn = &tg->qnode_on_parent[rw];
9e660acffcd1b5 Tejun Heo 2013-05-14 2266 sq = sq->parent_sq;
9e660acffcd1b5 Tejun Heo 2013-05-14 2267 tg = sq_to_tg(sq);
9e660acffcd1b5 Tejun Heo 2013-05-14 2268 if (!tg)
e1c15e207d153c Laibin Qiu 2022-03-08 2269 goto out;
e43473b7f223ec Vivek Goyal 2010-09-15 2270 }
e43473b7f223ec Vivek Goyal 2010-09-15 2271
9e660acffcd1b5 Tejun Heo 2013-05-14 2272 /* out-of-limit, queue to @tg */
fda6f272c77a7a Tejun Heo 2013-05-14 2273 throtl_log(sq, "[%c] bio. bdisp=%llu sz=%u bps=%llu iodisp=%u iops=%u queued=%d/%d",
8e89d13f4ede24 Vivek Goyal 2010-09-15 2274 rw == READ ? 'R' : 'W',
9f626e372a6024 Shaohua Li 2017-03-27 2275 tg->bytes_disp[rw], bio->bi_iter.bi_size,
9f626e372a6024 Shaohua Li 2017-03-27 2276 tg_bps_limit(tg, rw),
9f626e372a6024 Shaohua Li 2017-03-27 2277 tg->io_disp[rw], tg_iops_limit(tg, rw),
73f0d49a9637a7 Tejun Heo 2013-05-14 2278 sq->nr_queued[READ], sq->nr_queued[WRITE]);
e43473b7f223ec Vivek Goyal 2010-09-15 2279
3f0abd806651df Shaohua Li 2017-03-27 2280 tg->last_low_overflow_time[rw] = jiffies;
3f0abd806651df Shaohua Li 2017-03-27 2281
b9147dd1bae2b1 Shaohua Li 2017-03-27 2282 td->nr_queued[rw]++;
c5cc2070b45333 Tejun Heo 2013-05-14 2283 throtl_add_bio_tg(bio, qn, tg);
bc16a4f933bc5e Tejun Heo 2011-10-19 2284 throttled = true;
e43473b7f223ec Vivek Goyal 2010-09-15 2285
7f52f98c2a8333 Tejun Heo 2013-05-14 2286 /*
7f52f98c2a8333 Tejun Heo 2013-05-14 2287 * Update @tg's dispatch time and force schedule dispatch if @tg
7f52f98c2a8333 Tejun Heo 2013-05-14 2288 * was empty before @bio. The forced scheduling isn't likely to
7f52f98c2a8333 Tejun Heo 2013-05-14 2289 * cause undue delay as @bio is likely to be dispatched directly if
7f52f98c2a8333 Tejun Heo 2013-05-14 2290 * its @tg's disptime is not in the future.
7f52f98c2a8333 Tejun Heo 2013-05-14 2291 */
0e9f4164ba9150 Tejun Heo 2013-05-14 2292 if (tg->flags & THROTL_TG_WAS_EMPTY) {
77216b04848178 Tejun Heo 2013-05-14 2293 tg_update_disptime(tg);
7f52f98c2a8333 Tejun Heo 2013-05-14 2294 throtl_schedule_next_dispatch(tg->service_queue.parent_sq, true);
e43473b7f223ec Vivek Goyal 2010-09-15 2295 }
e43473b7f223ec Vivek Goyal 2010-09-15 2296
bc16a4f933bc5e Tejun Heo 2011-10-19 2297 out:
111be883981748 Shaohua Li 2017-12-20 2298 bio_set_flag(bio, BIO_THROTTLED);
b9147dd1bae2b1 Shaohua Li 2017-03-27 2299
b9147dd1bae2b1 Shaohua Li 2017-03-27 2300 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
b9147dd1bae2b1 Shaohua Li 2017-03-27 2301 if (throttled || !td->track_bio_latency)
5238dcf4136fd7 Omar Sandoval 2018-05-09 2302 bio->bi_issue.value |= BIO_ISSUE_THROTL_SKIP_LATENCY;
b9147dd1bae2b1 Shaohua Li 2017-03-27 2303 #endif
e1c15e207d153c Laibin Qiu 2022-03-08 2304 if (locked)
e1c15e207d153c Laibin Qiu 2022-03-08 2305 spin_unlock_irq(q->queue_lock);
bc16a4f933bc5e Tejun Heo 2011-10-19 @2306 return throttled;
e43473b7f223ec Vivek Goyal 2010-09-15 2307 }
e43473b7f223ec Vivek Goyal 2010-09-15 2308
:::::: The code at line 2306 was first introduced by commit
:::::: bc16a4f933bc5ed50826b20561e4c3515061998b block: reorganize throtl_get_tg() and blk_throtl_bio()
:::::: TO: Tejun Heo <tj@kernel.org>
:::::: CC: Jens Axboe <axboe@kernel.dk>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2025-09-02 12:45 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-08 3:34 [openeuler:openEuler-1.0-LTS 1568/1568] block/blk-throttle.c:2306:1-7: preceding lock on line 2212 kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2025-04-17 22:31 kernel test robot
2025-04-25 11:55 kernel test robot
2025-04-29 3:17 kernel test robot
2025-04-30 17:20 kernel test robot
2025-05-05 21:27 kernel test robot
2025-05-28 13:41 kernel test robot
2025-06-05 3:27 kernel test robot
2025-06-07 9:37 kernel test robot
2025-06-15 1:03 kernel test robot
2025-06-17 21:44 kernel test robot
2025-06-25 23:25 kernel test robot
2025-07-02 22:21 kernel test robot
2025-07-04 12:38 kernel test robot
2025-07-07 7:14 kernel test robot
2025-07-15 15:51 kernel test robot
2025-07-23 16:02 kernel test robot
2025-07-29 13:28 kernel test robot
2025-07-30 14:00 kernel test robot
2025-08-07 20:06 kernel test robot
2025-08-08 10:45 kernel test robot
2025-08-16 7:33 kernel test robot
2025-08-24 6:09 kernel test robot
2025-09-01 5:00 kernel test robot
2025-09-01 12:23 kernel test robot
2025-09-02 12:42 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.