io_uring/io-wq.c:401:6-25: WARNING: atomic_dec_and_test variation before object free at line 408.

From: kernel test robot
Date: Sun Sep 15 2024 - 04:47:46 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 0babf683783ddca06551537c6781e413cfe8d27b
commit: ed29b0b4fd835b058ddd151c49d021e28d631ee6 io_uring: move to separate directory
date: 2 years, 2 months ago
config: i386-randconfig-052-20240915 (https://download.01.org/0day-ci/archive/20240915/202409151605.9zKulYo3-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409151605.9zKulYo3-lkp@xxxxxxxxx/

cocci warnings: (new ones prefixed by >>)
>> io_uring/io-wq.c:401:6-25: WARNING: atomic_dec_and_test variation before object free at line 408.

vim +401 io_uring/io-wq.c

685fe7feedb967 fs/io-wq.c Jens Axboe 2021-03-08 392
958234d5ec9321 fs/io-wq.c Jens Axboe 2021-02-17 393 static void io_wqe_dec_running(struct io_worker *worker)
c5def4ab849494 fs/io-wq.c Jens Axboe 2019-11-07 394 {
958234d5ec9321 fs/io-wq.c Jens Axboe 2021-02-17 395 struct io_wqe_acct *acct = io_wqe_get_acct(worker);
958234d5ec9321 fs/io-wq.c Jens Axboe 2021-02-17 396 struct io_wqe *wqe = worker->wqe;
c5def4ab849494 fs/io-wq.c Jens Axboe 2019-11-07 397
685fe7feedb967 fs/io-wq.c Jens Axboe 2021-03-08 398 if (!(worker->flags & IO_WORKER_F_UP))
685fe7feedb967 fs/io-wq.c Jens Axboe 2021-03-08 399 return;
685fe7feedb967 fs/io-wq.c Jens Axboe 2021-03-08 400
42abc95f05bff5 fs/io-wq.c Hao Xu 2022-02-06 @401 if (!atomic_dec_and_test(&acct->nr_running))
42abc95f05bff5 fs/io-wq.c Hao Xu 2022-02-06 402 return;
e13fb1fe1483f6 fs/io-wq.c Hao Xu 2022-02-06 403 if (!io_acct_run_queue(acct))
42abc95f05bff5 fs/io-wq.c Hao Xu 2022-02-06 404 return;
42abc95f05bff5 fs/io-wq.c Hao Xu 2022-02-06 405
685fe7feedb967 fs/io-wq.c Jens Axboe 2021-03-08 406 atomic_inc(&acct->nr_running);
685fe7feedb967 fs/io-wq.c Jens Axboe 2021-03-08 407 atomic_inc(&wqe->wq->worker_refs);
3146cba99aa284 fs/io-wq.c Jens Axboe 2021-09-01 @408 io_queue_worker_create(worker, acct, create_worker_cb);
c5def4ab849494 fs/io-wq.c Jens Axboe 2019-11-07 409 }
c5def4ab849494 fs/io-wq.c Jens Axboe 2019-11-07 410

:::::: The code at line 401 was first introduced by commit
:::::: 42abc95f05bff5180ac40c7ba5726b73c1d5e2f4 io-wq: decouple work_list protection from the big wqe->lock

:::::: TO: Hao Xu <haoxu@xxxxxxxxxxxxxxxxx>
:::::: CC: Jens Axboe <axboe@xxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki