Re: fs/io_uring.c:6920:12: warning: stack frame size of 1040 bytes in function 'io_submit_sqes'

From: Pavel Begunkov
Date: Tue Mar 23 2021 - 08:56:09 EST


On 23/03/2021 11:31, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 84196390620ac0e5070ae36af84c137c6216a7dc
> commit: e5d1bc0a91f16959aa279aa3ee9fdc246d4bb382 io_uring: defer flushing cached reqs
> date: 6 weeks ago
> config: powerpc64-randconfig-r023-20210323 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 14696baaf4c43fe53f738bc292bbe169eed93d5d)
> 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 powerpc64 cross compiling tool for clang build
> # apt-get install binutils-powerpc64-linux-gnu
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5d1bc0a91f16959aa279aa3ee9fdc246d4bb382
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout e5d1bc0a91f16959aa279aa3ee9fdc246d4bb382
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All warnings (new ones prefixed by >>):
>
>>> fs/io_uring.c:6920:12: warning: stack frame size of 1040 bytes in function 'io_submit_sqes' [-Wframe-larger-than=]
> static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
> ^
> 1 warning generated. b

I don't know, for up-to-date code all submission functions are under
128 bytes for me, including io_submit_sqes with everything heavily
inlined into it. I believe it's just a strange config keeping
everything on stack for some reason (too under optimised?).


>
>
> vim +/io_submit_sqes +6920 fs/io_uring.c
>
> 0553b8bda8709c Pavel Begunkov 2020-04-08 6919
> 0f2122045b9462 Jens Axboe 2020-09-13 @6920 static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6921 {
> 863e05604a6fb4 Pavel Begunkov 2020-10-27 6922 struct io_submit_link link;
> 9e645e1105ca60 Jens Axboe 2019-05-10 6923 int i, submitted = 0;
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6924
> c4a2ed72c9a615 Jens Axboe 2019-11-21 6925 /* if we have a backlog and couldn't flush it all, return BUSY */
> ad3eb2c89fb24d Jens Axboe 2019-12-18 6926 if (test_bit(0, &ctx->sq_check_overflow)) {
> 6c503150ae33ee Pavel Begunkov 2021-01-04 6927 if (!__io_cqring_overflow_flush(ctx, false, NULL, NULL))
> 1d7bb1d50fb4dc Jens Axboe 2019-11-06 6928 return -EBUSY;
> ad3eb2c89fb24d Jens Axboe 2019-12-18 6929 }
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6930
> ee7d46d9db19de Pavel Begunkov 2019-12-30 6931 /* make sure SQ entry isn't read before tail */
> ee7d46d9db19de Pavel Begunkov 2019-12-30 6932 nr = min3(nr, ctx->sq_entries, io_sqring_entries(ctx));
> 9ef4f124894b7b Pavel Begunkov 2019-12-30 6933
> 2b85edfc0c90ef Pavel Begunkov 2019-12-28 6934 if (!percpu_ref_tryget_many(&ctx->refs, nr))
> 2b85edfc0c90ef Pavel Begunkov 2019-12-28 6935 return -EAGAIN;
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6936
> d8a6df10aac9f2 Jens Axboe 2020-10-15 6937 percpu_counter_add(&current->io_uring->inflight, nr);
> faf7b51c06973f Jens Axboe 2020-10-07 6938 refcount_add(nr, &current->usage);
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6939
> ba88ff112bdfde Pavel Begunkov 2021-02-10 6940 io_submit_state_start(&ctx->submit_state, nr);
> 863e05604a6fb4 Pavel Begunkov 2020-10-27 6941 link.head = NULL;
> b14cca0c84c760 Pavel Begunkov 2020-01-17 6942
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6943 for (i = 0; i < nr; i++) {
> 3529d8c2b353e6 Jens Axboe 2019-12-19 6944 const struct io_uring_sqe *sqe;
> 196be95cd55720 Pavel Begunkov 2019-11-07 6945 struct io_kiocb *req;
> 1cb1edb2f5ba8a Pavel Begunkov 2020-02-06 6946 int err;
> fb5ccc98782f65 Pavel Begunkov 2019-10-25 6947
> b1e50e549b1372 Pavel Begunkov 2020-04-08 6948 sqe = io_get_sqe(ctx);
> b1e50e549b1372 Pavel Begunkov 2020-04-08 6949 if (unlikely(!sqe)) {
> b1e50e549b1372 Pavel Begunkov 2020-04-08 6950 io_consume_sqe(ctx);
> b1e50e549b1372 Pavel Begunkov 2020-04-08 6951 break;
> b1e50e549b1372 Pavel Begunkov 2020-04-08 6952 }
> 258b29a93bfe74 Pavel Begunkov 2021-02-10 6953 req = io_alloc_req(ctx);
> 196be95cd55720 Pavel Begunkov 2019-11-07 6954 if (unlikely(!req)) {
> 196be95cd55720 Pavel Begunkov 2019-11-07 6955 if (!submitted)
> 196be95cd55720 Pavel Begunkov 2019-11-07 6956 submitted = -EAGAIN;
> fb5ccc98782f65 Pavel Begunkov 2019-10-25 6957 break;
> 196be95cd55720 Pavel Begunkov 2019-11-07 6958 }
> 709b302faddfac Pavel Begunkov 2020-04-08 6959 io_consume_sqe(ctx);
> d3656344fea033 Jens Axboe 2019-12-18 6960 /* will complete beyond this point, count as submitted */
> d3656344fea033 Jens Axboe 2019-12-18 6961 submitted++;
> d3656344fea033 Jens Axboe 2019-12-18 6962
> 258b29a93bfe74 Pavel Begunkov 2021-02-10 6963 err = io_init_req(ctx, req, sqe);
> ef4ff581102a91 Pavel Begunkov 2020-04-12 6964 if (unlikely(err)) {
> 1cb1edb2f5ba8a Pavel Begunkov 2020-02-06 6965 fail_req:
> e1e16097e265da Jens Axboe 2020-06-22 6966 io_put_req(req);
> e1e16097e265da Jens Axboe 2020-06-22 6967 io_req_complete(req, err);
> fb5ccc98782f65 Pavel Begunkov 2019-10-25 6968 break;
> 196be95cd55720 Pavel Begunkov 2019-11-07 6969 }
> fb5ccc98782f65 Pavel Begunkov 2019-10-25 6970
> 354420f705ccd0 Jens Axboe 2020-01-08 6971 trace_io_uring_submit_sqe(ctx, req->opcode, req->user_data,
> 2d7e935809b7f7 Pavel Begunkov 2021-01-19 6972 true, ctx->flags & IORING_SETUP_SQPOLL);
> c5eef2b9449ba2 Pavel Begunkov 2021-02-10 6973 err = io_submit_sqe(req, sqe, &link);
> 1d4240cc9e7bb1 Pavel Begunkov 2020-04-12 6974 if (err)
> 1d4240cc9e7bb1 Pavel Begunkov 2020-04-12 6975 goto fail_req;
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6976 }
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6977
> 9466f43741bc08 Pavel Begunkov 2020-01-25 6978 if (unlikely(submitted != nr)) {
> 9466f43741bc08 Pavel Begunkov 2020-01-25 6979 int ref_used = (submitted == -EAGAIN) ? 0 : submitted;
> d8a6df10aac9f2 Jens Axboe 2020-10-15 6980 struct io_uring_task *tctx = current->io_uring;
> d8a6df10aac9f2 Jens Axboe 2020-10-15 6981 int unused = nr - ref_used;
> 9466f43741bc08 Pavel Begunkov 2020-01-25 6982
> d8a6df10aac9f2 Jens Axboe 2020-10-15 6983 percpu_ref_put_many(&ctx->refs, unused);
> d8a6df10aac9f2 Jens Axboe 2020-10-15 6984 percpu_counter_sub(&tctx->inflight, unused);
> d8a6df10aac9f2 Jens Axboe 2020-10-15 6985 put_task_struct_many(current, unused);
> 9466f43741bc08 Pavel Begunkov 2020-01-25 6986 }
> 863e05604a6fb4 Pavel Begunkov 2020-10-27 6987 if (link.head)
> c5eef2b9449ba2 Pavel Begunkov 2021-02-10 6988 io_queue_link_head(link.head);
> ba88ff112bdfde Pavel Begunkov 2021-02-10 6989 io_submit_state_end(&ctx->submit_state, ctx);
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6990
> ae9428ca61271b Pavel Begunkov 2019-11-06 6991 /* Commit SQ ring head once we've consumed and submitted all SQEs */
> ae9428ca61271b Pavel Begunkov 2019-11-06 6992 io_commit_sqring(ctx);
> ae9428ca61271b Pavel Begunkov 2019-11-06 6993
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6994 return submitted;
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6995 }
> 6c271ce2f1d572 Jens Axboe 2019-01-10 6996
>
> :::::: The code at line 6920 was first introduced by commit
> :::::: 0f2122045b946241a9e549c2a76cea54fa58a7ff io_uring: don't rely on weak ->files references
>
> :::::: TO: Jens Axboe <axboe@xxxxxxxxx>
> :::::: CC: Jens Axboe <axboe@xxxxxxxxx>
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
>

--
Pavel Begunkov