Message ID | 20230518211751.3492982-6-shr@devkernel.io (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | io_uring: add napi busy polling support | expand |
Hi Stefan, kernel test robot noticed the following build errors: [auto build test ERROR on d2b7fa6174bc4260e496cbf84375c73636914641] url: https://github.com/intel-lab-lkp/linux/commits/Stefan-Roesch/net-split-off-__napi_busy_poll-from-napi_busy_poll/20230519-054117 base: d2b7fa6174bc4260e496cbf84375c73636914641 patch link: https://lore.kernel.org/r/20230518211751.3492982-6-shr%40devkernel.io patch subject: [PATCH v13 5/7] io-uring: add sqpoll support for napi busy poll config: powerpc-allnoconfig compiler: powerpc-linux-gcc (GCC) 12.1.0 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 # https://github.com/intel-lab-lkp/linux/commit/8d324fedc325505406b6ea808d5d7a7cacb321a5 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Stefan-Roesch/net-split-off-__napi_busy_poll-from-napi_busy_poll/20230519-054117 git checkout 8d324fedc325505406b6ea808d5d7a7cacb321a5 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202305190745.UK8QQ6fw-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from io_uring/sqpoll.c:18: io_uring/sqpoll.c: In function '__io_sq_thread': >> io_uring/napi.h:81:39: error: expected expression before 'do' 81 | #define io_napi_sqpoll_busy_poll(ctx) do {} while (0) | ^~ io_uring/sqpoll.c:198:32: note: in expansion of macro 'io_napi_sqpoll_busy_poll' 198 | ret += io_napi_sqpoll_busy_poll(ctx); | ^~~~~~~~~~~~~~~~~~~~~~~~ vim +/do +81 io_uring/napi.h 78 79 #define io_napi_adjust_timeout(ctx, iowq, ts) do {} while (0) 80 #define io_napi_busy_loop(ctx, iowq) do {} while (0) > 81 #define io_napi_sqpoll_busy_poll(ctx) do {} while (0) 82
On 5/18/23 6:11?PM, kernel test robot wrote: > Hi Stefan, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on d2b7fa6174bc4260e496cbf84375c73636914641] > > url: https://github.com/intel-lab-lkp/linux/commits/Stefan-Roesch/net-split-off-__napi_busy_poll-from-napi_busy_poll/20230519-054117 > base: d2b7fa6174bc4260e496cbf84375c73636914641 > patch link: https://lore.kernel.org/r/20230518211751.3492982-6-shr%40devkernel.io > patch subject: [PATCH v13 5/7] io-uring: add sqpoll support for napi busy poll > config: powerpc-allnoconfig > compiler: powerpc-linux-gcc (GCC) 12.1.0 > 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 > # https://github.com/intel-lab-lkp/linux/commit/8d324fedc325505406b6ea808d5d7a7cacb321a5 > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review Stefan-Roesch/net-split-off-__napi_busy_poll-from-napi_busy_poll/20230519-054117 > git checkout 8d324fedc325505406b6ea808d5d7a7cacb321a5 > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202305190745.UK8QQ6fw-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > In file included from io_uring/sqpoll.c:18: > io_uring/sqpoll.c: In function '__io_sq_thread': >>> io_uring/napi.h:81:39: error: expected expression before 'do' > 81 | #define io_napi_sqpoll_busy_poll(ctx) do {} while (0) > | ^~ > io_uring/sqpoll.c:198:32: note: in expansion of macro 'io_napi_sqpoll_busy_poll' > 198 | ret += io_napi_sqpoll_busy_poll(ctx); > | ^~~~~~~~~~~~~~~~~~~~~~~~ > That's my fault, didn't look closely enough. But let's fold this one into patch 3, to get proper types for !CONFIG_NET_RX_BUSY_POLL. diff --git a/io_uring/napi.h b/io_uring/napi.h index 69c1970cbecc..64d07317866b 100644 --- a/io_uring/napi.h +++ b/io_uring/napi.h @@ -60,39 +60,43 @@ static inline void io_napi_add(struct io_kiocb *req) __io_napi_add(ctx, req->file); } -#else +#else /* CONFIG_NET_RX_BUSY_POLL */ static inline void io_napi_init(struct io_ring_ctx *ctx) { } - static inline void io_napi_free(struct io_ring_ctx *ctx) { } - static inline int io_register_napi(struct io_ring_ctx *ctx, void __user *arg) { return -EOPNOTSUPP; } - static inline int io_unregister_napi(struct io_ring_ctx *ctx, void __user *arg) { return -EOPNOTSUPP; } - static inline bool io_napi(struct io_ring_ctx *ctx) { return false; } - static inline void io_napi_add(struct io_kiocb *req) { } +static inline void io_napi_adjust_timeout(struct io_ring_ctx *ctx, + struct io_wait_queue *iowq, + struct timespec64 *ts) +{ +} +static inline void io_napi_busy_loop(struct io_ring_ctx *ctx, + struct io_wait_queue *iowq) +{ +} +static inline int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx) +{ + return 0; +} -#define io_napi_adjust_timeout(ctx, iowq, ts) do {} while (0) -#define io_napi_busy_loop(ctx, iowq) do {} while (0) -#define io_napi_sqpoll_busy_poll(ctx) do {} while (0) - -#endif +#endif /* CONFIG_NET_RX_BUSY_POLL */ #endif
Hi Stefan, kernel test robot noticed the following build errors: [auto build test ERROR on d2b7fa6174bc4260e496cbf84375c73636914641] url: https://github.com/intel-lab-lkp/linux/commits/Stefan-Roesch/net-split-off-__napi_busy_poll-from-napi_busy_poll/20230519-054117 base: d2b7fa6174bc4260e496cbf84375c73636914641 patch link: https://lore.kernel.org/r/20230518211751.3492982-6-shr%40devkernel.io patch subject: [PATCH v13 5/7] io-uring: add sqpoll support for napi busy poll config: mips-pic32mzda_defconfig compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project b0fb98227c90adf2536c9ad644a74d5e92961111) 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 mips cross compiling tool for clang build # apt-get install binutils-mipsel-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/8d324fedc325505406b6ea808d5d7a7cacb321a5 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Stefan-Roesch/net-split-off-__napi_busy_poll-from-napi_busy_poll/20230519-054117 git checkout 8d324fedc325505406b6ea808d5d7a7cacb321a5 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202305191242.JLAg91z4-lkp@intel.com/ All errors (new ones prefixed by >>): >> io_uring/sqpoll.c:198:11: error: expected expression ret += io_napi_sqpoll_busy_poll(ctx); ^ io_uring/napi.h:81:39: note: expanded from macro 'io_napi_sqpoll_busy_poll' #define io_napi_sqpoll_busy_poll(ctx) do {} while (0) ^ 1 error generated. vim +198 io_uring/sqpoll.c 167 168 static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries) 169 { 170 unsigned int to_submit; 171 int ret = 0; 172 173 to_submit = io_sqring_entries(ctx); 174 /* if we're handling multiple rings, cap submit size for fairness */ 175 if (cap_entries && to_submit > IORING_SQPOLL_CAP_ENTRIES_VALUE) 176 to_submit = IORING_SQPOLL_CAP_ENTRIES_VALUE; 177 178 if (!wq_list_empty(&ctx->iopoll_list) || to_submit) { 179 const struct cred *creds = NULL; 180 181 if (ctx->sq_creds != current_cred()) 182 creds = override_creds(ctx->sq_creds); 183 184 mutex_lock(&ctx->uring_lock); 185 if (!wq_list_empty(&ctx->iopoll_list)) 186 io_do_iopoll(ctx, true); 187 188 /* 189 * Don't submit if refs are dying, good for io_uring_register(), 190 * but also it is relied upon by io_ring_exit_work() 191 */ 192 if (to_submit && likely(!percpu_ref_is_dying(&ctx->refs)) && 193 !(ctx->flags & IORING_SETUP_R_DISABLED)) 194 ret = io_submit_sqes(ctx, to_submit); 195 mutex_unlock(&ctx->uring_lock); 196 197 if (io_napi(ctx)) > 198 ret += io_napi_sqpoll_busy_poll(ctx); 199 200 if (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait)) 201 wake_up(&ctx->sqo_sq_wait); 202 if (creds) 203 revert_creds(creds); 204 } 205 206 return ret; 207 } 208
Jens Axboe <axboe@kernel.dk> writes: > On 5/18/23 6:11?PM, kernel test robot wrote: >> Hi Stefan, >> >> kernel test robot noticed the following build errors: >> >> [auto build test ERROR on d2b7fa6174bc4260e496cbf84375c73636914641] >> >> url: https://github.com/intel-lab-lkp/linux/commits/Stefan-Roesch/net-split-off-__napi_busy_poll-from-napi_busy_poll/20230519-054117 >> base: d2b7fa6174bc4260e496cbf84375c73636914641 >> patch link: https://lore.kernel.org/r/20230518211751.3492982-6-shr%40devkernel.io >> patch subject: [PATCH v13 5/7] io-uring: add sqpoll support for napi busy poll >> config: powerpc-allnoconfig >> compiler: powerpc-linux-gcc (GCC) 12.1.0 >> 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 >> # https://github.com/intel-lab-lkp/linux/commit/8d324fedc325505406b6ea808d5d7a7cacb321a5 >> git remote add linux-review https://github.com/intel-lab-lkp/linux >> git fetch --no-tags linux-review Stefan-Roesch/net-split-off-__napi_busy_poll-from-napi_busy_poll/20230519-054117 >> git checkout 8d324fedc325505406b6ea808d5d7a7cacb321a5 >> # save the config file >> mkdir build_dir && cp config build_dir/.config >> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig >> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash >> >> If you fix the issue, kindly add following tag where applicable >> | Reported-by: kernel test robot <lkp@intel.com> >> | Closes: https://lore.kernel.org/oe-kbuild-all/202305190745.UK8QQ6fw-lkp@intel.com/ >> >> All errors (new ones prefixed by >>): >> >> In file included from io_uring/sqpoll.c:18: >> io_uring/sqpoll.c: In function '__io_sq_thread': >>>> io_uring/napi.h:81:39: error: expected expression before 'do' >> 81 | #define io_napi_sqpoll_busy_poll(ctx) do {} while (0) >> | ^~ >> io_uring/sqpoll.c:198:32: note: in expansion of macro 'io_napi_sqpoll_busy_poll' >> 198 | ret += io_napi_sqpoll_busy_poll(ctx); >> | ^~~~~~~~~~~~~~~~~~~~~~~~ >> > > That's my fault, didn't look closely enough. But let's fold this one into > patch 3, to get proper types for !CONFIG_NET_RX_BUSY_POLL. > > > diff --git a/io_uring/napi.h b/io_uring/napi.h > index 69c1970cbecc..64d07317866b 100644 > --- a/io_uring/napi.h > +++ b/io_uring/napi.h > @@ -60,39 +60,43 @@ static inline void io_napi_add(struct io_kiocb *req) > __io_napi_add(ctx, req->file); > } > > -#else > +#else /* CONFIG_NET_RX_BUSY_POLL */ > > static inline void io_napi_init(struct io_ring_ctx *ctx) > { > } > - > static inline void io_napi_free(struct io_ring_ctx *ctx) > { > } > - > static inline int io_register_napi(struct io_ring_ctx *ctx, void __user *arg) > { > return -EOPNOTSUPP; > } > - > static inline int io_unregister_napi(struct io_ring_ctx *ctx, void __user *arg) > { > return -EOPNOTSUPP; > } > - > static inline bool io_napi(struct io_ring_ctx *ctx) > { > return false; > } > - > static inline void io_napi_add(struct io_kiocb *req) > { > } > +static inline void io_napi_adjust_timeout(struct io_ring_ctx *ctx, > + struct io_wait_queue *iowq, > + struct timespec64 *ts) > +{ > +} > +static inline void io_napi_busy_loop(struct io_ring_ctx *ctx, > + struct io_wait_queue *iowq) > +{ > +} > +static inline int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx) > +{ > + return 0; > +} > > -#define io_napi_adjust_timeout(ctx, iowq, ts) do {} while (0) > -#define io_napi_busy_loop(ctx, iowq) do {} while (0) > -#define io_napi_sqpoll_busy_poll(ctx) do {} while (0) > - > -#endif > +#endif /* CONFIG_NET_RX_BUSY_POLL */ > > #endif I'll make the above fix in the next version.
diff --git a/io_uring/napi.c b/io_uring/napi.c index 54d66dd3119f..9aaeea51250f 100644 --- a/io_uring/napi.c +++ b/io_uring/napi.c @@ -257,4 +257,28 @@ void __io_napi_busy_loop(struct io_ring_ctx *ctx, struct io_wait_queue *iowq) io_napi_blocking_busy_loop(ctx, iowq); } +/* + * io_napi_sqpoll_busy_poll() - busy poll loop for sqpoll + * @ctx: pointer to io-uring context structure + * + * Splice of the napi list and execute the napi busy poll loop. + */ +int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx) +{ + LIST_HEAD(napi_list); + bool is_stale = false; + + if (!READ_ONCE(ctx->napi_busy_poll_to)) + return 0; + if (list_empty_careful(&ctx->napi_list)) + return 0; + + rcu_read_lock(); + is_stale = __io_napi_do_busy_loop(ctx, NULL); + rcu_read_unlock(); + + io_napi_remove_stale(ctx, is_stale); + return 1; +} + #endif diff --git a/io_uring/napi.h b/io_uring/napi.h index 1bdf8442081f..945d3c8c201d 100644 --- a/io_uring/napi.h +++ b/io_uring/napi.h @@ -17,6 +17,7 @@ void __io_napi_add(struct io_ring_ctx *ctx, struct file *file); void __io_napi_adjust_timeout(struct io_ring_ctx *ctx, struct io_wait_queue *iowq, struct timespec64 *ts); void __io_napi_busy_loop(struct io_ring_ctx *ctx, struct io_wait_queue *iowq); +int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx); static inline bool io_napi(struct io_ring_ctx *ctx) { @@ -77,6 +78,7 @@ static inline void io_napi_add(struct io_kiocb *req) #define io_napi_adjust_timeout(ctx, iowq, ts) do {} while (0) #define io_napi_busy_loop(ctx, iowq) do {} while (0) +#define io_napi_sqpoll_busy_poll(ctx) do {} while (0) #endif diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index 9db4bc1f521a..0c8d53ef134a 100644 --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -15,6 +15,7 @@ #include <uapi/linux/io_uring.h> #include "io_uring.h" +#include "napi.h" #include "sqpoll.h" #define IORING_SQPOLL_CAP_ENTRIES_VALUE 8 @@ -193,6 +194,9 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries) ret = io_submit_sqes(ctx, to_submit); mutex_unlock(&ctx->uring_lock); + if (io_napi(ctx)) + ret += io_napi_sqpoll_busy_poll(ctx); + if (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait)) wake_up(&ctx->sqo_sq_wait); if (creds)
This adds the sqpoll support to the io-uring napi. Signed-off-by: Stefan Roesch <shr@devkernel.io> Suggested-by: Olivier Langlois <olivier@trillion01.com> --- io_uring/napi.c | 24 ++++++++++++++++++++++++ io_uring/napi.h | 2 ++ io_uring/sqpoll.c | 4 ++++ 3 files changed, 30 insertions(+)