[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <dc06f6d0-b7d1-c6cf-bb3a-569af600e9e5@intel.com>
Date: Fri, 5 Nov 2021 14:42:05 +0800
From: kernel test robot <yujie.liu@...el.com>
To: Jens Axboe <axboe@...nel.dk>
CC: <llvm@...ts.linux.dev>, <kbuild-all@...ts.01.org>,
"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>
Subject: Re: fs/io_uring.c:10086:24: warning: Value stored to 'sqe' during its
initialization is never read [clang-analyzer-deadcode.DeadStores]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d4439a1189f93d0ac1eaf0197db8e6b3e197d5c7
commit: f75d118349be055d47407b4ba4ceb98e6437e472 io_uring: harder fdinfo sq/cq ring iterating
date: 7 days ago
config: arm-randconfig-c002-20211031 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 82ed106567063ea269c6d5669278b733e173a42f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f75d118349be055d47407b4ba4ceb98e6437e472
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout f75d118349be055d47407b4ba4ceb98e6437e472
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
clang-analyzer warnings: (new ones prefixed by >>)
>> fs/io_uring.c:10086:24: warning: Value stored to 'sqe' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct io_uring_sqe *sqe = &ctx->sq_sqes[sq_idx];
^~~ ~~~~~~~~~~~~~~~~~~~~~
vim +/sqe +10086 fs/io_uring.c
87ce955b24c994 Jens Axboe 2020-01-30 10051
c072481ded14bc Pavel Begunkov 2021-10-04 10052 static __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx,
c072481ded14bc Pavel Begunkov 2021-10-04 10053 struct seq_file *m)
87ce955b24c994 Jens Axboe 2020-01-30 10054 {
dbbe9c642411c3 Joseph Qi 2020-09-29 10055 struct io_sq_data *sq = NULL;
83f84356bc8f2d Hao Xu 2021-09-13 10056 struct io_overflow_cqe *ocqe;
83f84356bc8f2d Hao Xu 2021-09-13 10057 struct io_rings *r = ctx->rings;
83f84356bc8f2d Hao Xu 2021-09-13 10058 unsigned int sq_mask = ctx->sq_entries - 1, cq_mask = ctx->cq_entries - 1;
83f84356bc8f2d Hao Xu 2021-09-13 10059 unsigned int sq_head = READ_ONCE(r->sq.head);
83f84356bc8f2d Hao Xu 2021-09-13 10060 unsigned int sq_tail = READ_ONCE(r->sq.tail);
83f84356bc8f2d Hao Xu 2021-09-13 10061 unsigned int cq_head = READ_ONCE(r->cq.head);
83f84356bc8f2d Hao Xu 2021-09-13 10062 unsigned int cq_tail = READ_ONCE(r->cq.tail);
f75d118349be05 Jens Axboe 2021-10-29 10063 unsigned int sq_entries, cq_entries;
fad8e0de4426a7 Jens Axboe 2020-09-28 10064 bool has_lock;
83f84356bc8f2d Hao Xu 2021-09-13 10065 unsigned int i;
83f84356bc8f2d Hao Xu 2021-09-13 10066
83f84356bc8f2d Hao Xu 2021-09-13 10067 /*
83f84356bc8f2d Hao Xu 2021-09-13 10068 * we may get imprecise sqe and cqe info if uring is actively running
83f84356bc8f2d Hao Xu 2021-09-13 10069 * since we get cached_sq_head and cached_cq_tail without uring_lock
83f84356bc8f2d Hao Xu 2021-09-13 10070 * and sq_tail and cq_head are changed by userspace. But it's ok since
83f84356bc8f2d Hao Xu 2021-09-13 10071 * we usually use these info when it is stuck.
83f84356bc8f2d Hao Xu 2021-09-13 10072 */
f75d118349be05 Jens Axboe 2021-10-29 10073 seq_printf(m, "SqMask:\t\t0x%x\n", sq_mask);
f75d118349be05 Jens Axboe 2021-10-29 10074 seq_printf(m, "SqHead:\t%u\n", sq_head);
f75d118349be05 Jens Axboe 2021-10-29 10075 seq_printf(m, "SqTail:\t%u\n", sq_tail);
f75d118349be05 Jens Axboe 2021-10-29 10076 seq_printf(m, "CachedSqHead:\t%u\n", ctx->cached_sq_head);
f75d118349be05 Jens Axboe 2021-10-29 10077 seq_printf(m, "CqMask:\t0x%x\n", cq_mask);
f75d118349be05 Jens Axboe 2021-10-29 10078 seq_printf(m, "CqHead:\t%u\n", cq_head);
f75d118349be05 Jens Axboe 2021-10-29 10079 seq_printf(m, "CqTail:\t%u\n", cq_tail);
f75d118349be05 Jens Axboe 2021-10-29 10080 seq_printf(m, "CachedCqTail:\t%u\n", ctx->cached_cq_tail);
f75d118349be05 Jens Axboe 2021-10-29 10081 seq_printf(m, "SQEs:\t%u\n", sq_tail - ctx->cached_sq_head);
f75d118349be05 Jens Axboe 2021-10-29 10082 sq_entries = min(sq_tail - sq_head, ctx->sq_entries);
f75d118349be05 Jens Axboe 2021-10-29 10083 for (i = 0; i < sq_entries; i++) {
f75d118349be05 Jens Axboe 2021-10-29 10084 unsigned int entry = i + sq_head;
f75d118349be05 Jens Axboe 2021-10-29 10085 unsigned int sq_idx = READ_ONCE(ctx->sq_array[entry & sq_mask]);
83f84356bc8f2d Hao Xu 2021-09-13 @10086 struct io_uring_sqe *sqe = &ctx->sq_sqes[sq_idx];
83f84356bc8f2d Hao Xu 2021-09-13 10087
f75d118349be05 Jens Axboe 2021-10-29 10088 if (sq_idx > sq_mask)
f75d118349be05 Jens Axboe 2021-10-29 10089 continue;
f75d118349be05 Jens Axboe 2021-10-29 10090 sqe = &ctx->sq_sqes[sq_idx];
83f84356bc8f2d Hao Xu 2021-09-13 10091 seq_printf(m, "%5u: opcode:%d, fd:%d, flags:%x, user_data:%llu\n",
f75d118349be05 Jens Axboe 2021-10-29 10092 sq_idx, sqe->opcode, sqe->fd, sqe->flags,
f75d118349be05 Jens Axboe 2021-10-29 10093 sqe->user_data);
83f84356bc8f2d Hao Xu 2021-09-13 10094 }
f75d118349be05 Jens Axboe 2021-10-29 10095 seq_printf(m, "CQEs:\t%u\n", cq_tail - cq_head);
f75d118349be05 Jens Axboe 2021-10-29 10096 cq_entries = min(cq_tail - cq_head, ctx->cq_entries);
f75d118349be05 Jens Axboe 2021-10-29 10097 for (i = 0; i < cq_entries; i++) {
f75d118349be05 Jens Axboe 2021-10-29 10098 unsigned int entry = i + cq_head;
f75d118349be05 Jens Axboe 2021-10-29 10099 struct io_uring_cqe *cqe = &r->cqes[entry & cq_mask];
83f84356bc8f2d Hao Xu 2021-09-13 10100
83f84356bc8f2d Hao Xu 2021-09-13 10101 seq_printf(m, "%5u: user_data:%llu, res:%d, flag:%x\n",
f75d118349be05 Jens Axboe 2021-10-29 10102 entry & cq_mask, cqe->user_data, cqe->res,
f75d118349be05 Jens Axboe 2021-10-29 10103 cqe->flags);
83f84356bc8f2d Hao Xu 2021-09-13 10104 }
87ce955b24c994 Jens Axboe 2020-01-30 10105
fad8e0de4426a7 Jens Axboe 2020-09-28 10106 /*
fad8e0de4426a7 Jens Axboe 2020-09-28 10107 * Avoid ABBA deadlock between the seq lock and the io_uring mutex,
fad8e0de4426a7 Jens Axboe 2020-09-28 10108 * since fdinfo case grabs it in the opposite direction of normal use
fad8e0de4426a7 Jens Axboe 2020-09-28 10109 * cases. If we fail to get the lock, we just don't iterate any
fad8e0de4426a7 Jens Axboe 2020-09-28 10110 * structures that could be going away outside the io_uring mutex.
fad8e0de4426a7 Jens Axboe 2020-09-28 10111 */
fad8e0de4426a7 Jens Axboe 2020-09-28 10112 has_lock = mutex_trylock(&ctx->uring_lock);
fad8e0de4426a7 Jens Axboe 2020-09-28 10113
5f3f26f98ae484 Jens Axboe 2021-02-25 10114 if (has_lock && (ctx->flags & IORING_SETUP_SQPOLL)) {
dbbe9c642411c3 Joseph Qi 2020-09-29 10115 sq = ctx->sq_data;
5f3f26f98ae484 Jens Axboe 2021-02-25 10116 if (!sq->thread)
5f3f26f98ae484 Jens Axboe 2021-02-25 10117 sq = NULL;
5f3f26f98ae484 Jens Axboe 2021-02-25 10118 }
dbbe9c642411c3 Joseph Qi 2020-09-29 10119
dbbe9c642411c3 Joseph Qi 2020-09-29 10120 seq_printf(m, "SqThread:\t%d\n", sq ? task_pid_nr(sq->thread) : -1);
dbbe9c642411c3 Joseph Qi 2020-09-29 10121 seq_printf(m, "SqThreadCpu:\t%d\n", sq ? task_cpu(sq->thread) : -1);
87ce955b24c994 Jens Axboe 2020-01-30 10122 seq_printf(m, "UserFiles:\t%u\n", ctx->nr_user_files);
fad8e0de4426a7 Jens Axboe 2020-09-28 10123 for (i = 0; has_lock && i < ctx->nr_user_files; i++) {
7b29f92da377c3 Jens Axboe 2021-03-12 10124 struct file *f = io_file_from_index(ctx, i);
87ce955b24c994 Jens Axboe 2020-01-30 10125
87ce955b24c994 Jens Axboe 2020-01-30 10126 if (f)
87ce955b24c994 Jens Axboe 2020-01-30 10127 seq_printf(m, "%5u: %s\n", i, file_dentry(f)->d_iname);
87ce955b24c994 Jens Axboe 2020-01-30 10128 else
87ce955b24c994 Jens Axboe 2020-01-30 10129 seq_printf(m, "%5u: <none>\n", i);
87ce955b24c994 Jens Axboe 2020-01-30 10130 }
87ce955b24c994 Jens Axboe 2020-01-30 10131 seq_printf(m, "UserBufs:\t%u\n", ctx->nr_user_bufs);
fad8e0de4426a7 Jens Axboe 2020-09-28 10132 for (i = 0; has_lock && i < ctx->nr_user_bufs; i++) {
41edf1a5ec967b Pavel Begunkov 2021-04-25 10133 struct io_mapped_ubuf *buf = ctx->user_bufs[i];
4751f53d74a688 Pavel Begunkov 2021-04-01 10134 unsigned int len = buf->ubuf_end - buf->ubuf;
87ce955b24c994 Jens Axboe 2020-01-30 10135
4751f53d74a688 Pavel Begunkov 2021-04-01 10136 seq_printf(m, "%5u: 0x%llx/%u\n", i, buf->ubuf, len);
87ce955b24c994 Jens Axboe 2020-01-30 10137 }
61cf93700fe635 Matthew Wilcox (Oracle 2021-03-08 10138) if (has_lock && !xa_empty(&ctx->personalities)) {
61cf93700fe635 Matthew Wilcox (Oracle 2021-03-08 10139) unsigned long index;
61cf93700fe635 Matthew Wilcox (Oracle 2021-03-08 10140) const struct cred *cred;
61cf93700fe635 Matthew Wilcox (Oracle 2021-03-08 10141)
87ce955b24c994 Jens Axboe 2020-01-30 10142 seq_printf(m, "Personalities:\n");
61cf93700fe635 Matthew Wilcox (Oracle 2021-03-08 10143) xa_for_each(&ctx->personalities, index, cred)
61cf93700fe635 Matthew Wilcox (Oracle 2021-03-08 10144) io_uring_show_cred(m, index, cred);
87ce955b24c994 Jens Axboe 2020-01-30 10145 }
83f84356bc8f2d Hao Xu 2021-09-13 10146 if (has_lock)
83f84356bc8f2d Hao Xu 2021-09-13 10147 mutex_unlock(&ctx->uring_lock);
83f84356bc8f2d Hao Xu 2021-09-13 10148
83f84356bc8f2d Hao Xu 2021-09-13 10149 seq_puts(m, "PollList:\n");
79ebeaee8a21a0 Jens Axboe 2021-08-10 10150 spin_lock(&ctx->completion_lock);
d7718a9d25a614 Jens Axboe 2020-02-14 10151 for (i = 0; i < (1U << ctx->cancel_hash_bits); i++) {
d7718a9d25a614 Jens Axboe 2020-02-14 10152 struct hlist_head *list = &ctx->cancel_hash[i];
d7718a9d25a614 Jens Axboe 2020-02-14 10153 struct io_kiocb *req;
d7718a9d25a614 Jens Axboe 2020-02-14 10154
d7718a9d25a614 Jens Axboe 2020-02-14 10155 hlist_for_each_entry(req, list, hash_node)
d7718a9d25a614 Jens Axboe 2020-02-14 10156 seq_printf(m, " op=%d, task_works=%d\n", req->opcode,
d7718a9d25a614 Jens Axboe 2020-02-14 10157 req->task->task_works != NULL);
d7718a9d25a614 Jens Axboe 2020-02-14 10158 }
83f84356bc8f2d Hao Xu 2021-09-13 10159
83f84356bc8f2d Hao Xu 2021-09-13 10160 seq_puts(m, "CqOverflowList:\n");
83f84356bc8f2d Hao Xu 2021-09-13 10161 list_for_each_entry(ocqe, &ctx->cq_overflow_list, list) {
83f84356bc8f2d Hao Xu 2021-09-13 10162 struct io_uring_cqe *cqe = &ocqe->cqe;
83f84356bc8f2d Hao Xu 2021-09-13 10163
83f84356bc8f2d Hao Xu 2021-09-13 10164 seq_printf(m, " user_data=%llu, res=%d, flags=%x\n",
83f84356bc8f2d Hao Xu 2021-09-13 10165 cqe->user_data, cqe->res, cqe->flags);
83f84356bc8f2d Hao Xu 2021-09-13 10166
83f84356bc8f2d Hao Xu 2021-09-13 10167 }
83f84356bc8f2d Hao Xu 2021-09-13 10168
79ebeaee8a21a0 Jens Axboe 2021-08-10 10169 spin_unlock(&ctx->completion_lock);
87ce955b24c994 Jens Axboe 2020-01-30 10170 }
87ce955b24c994 Jens Axboe 2020-01-30 10171
:::::: The code at line 10086 was first introduced by commit
:::::: 83f84356bc8f2dda9d0c9c7edb94decf71a36d26 io_uring: add more uring info to fdinfo for debug
:::::: TO: Hao Xu <haoxu@...ux.alibaba.com>
:::::: CC: Jens Axboe <axboe@...nel.dk>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (35328 bytes)
Powered by blists - more mailing lists