diff mbox series

[4/5] io_uring: support nonblock try for splicing from pipe to pipe

Message ID 20220607080619.513187-5-hao.xu@linux.dev (mailing list archive)
State New
Headers show
Series support nonblock submission for splice pipe to pipe | expand

Commit Message

Hao Xu June 7, 2022, 8:06 a.m. UTC
From: Hao Xu <howeyxu@tencent.com>

splice() in io_uring is running in a slow way since it fully depends on
io workers. While splicing from pipe to pipe is a simpler case compared
with file to pipe and pipe to file. Let's make it support nonblock
first. This way we get a fast path for splicing fom pipe to pipe.

Signed-off-by: Hao Xu <howeyxu@tencent.com>
---
 io_uring/splice.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

Comments

kernel test robot June 7, 2022, 9:38 p.m. UTC | #1
Hi Hao,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on d8271bf021438f468dab3cd84fe5279b5bbcead8]

url:    https://github.com/intel-lab-lkp/linux/commits/Hao-Xu/support-nonblock-submission-for-splice-pipe-to-pipe/20220607-161605
base:   d8271bf021438f468dab3cd84fe5279b5bbcead8
config: mips-buildonly-randconfig-r001-20220607 (https://download.01.org/0day-ci/archive/20220608/202206080550.7nXmrsiv-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project b92436efcb7813fc481b30f2593a4907568d917a)
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-mips-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/96683840c3f19b77a536a259094d24e0cd93ebc0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Hao-Xu/support-nonblock-submission-for-splice-pipe-to-pipe/20220607-161605
        git checkout 96683840c3f19b77a536a259094d24e0cd93ebc0
        # 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 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> io_uring/splice.c:91:6: warning: no previous prototype for function 'io_splice_support_nowait' [-Wmissing-prototypes]
   bool io_splice_support_nowait(struct file *in, struct file *out)
        ^
   io_uring/splice.c:91:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   bool io_splice_support_nowait(struct file *in, struct file *out)
   ^
   static 
   1 warning generated.


vim +/io_splice_support_nowait +91 io_uring/splice.c

    90	
  > 91	bool io_splice_support_nowait(struct file *in, struct file *out)
    92	{
    93		if (get_pipe_info(in, true) && get_pipe_info(out, true))
    94			return true;
    95	
    96		return false;
    97	}
    98
kernel test robot June 8, 2022, 2:18 p.m. UTC | #2
Hi Hao,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on d8271bf021438f468dab3cd84fe5279b5bbcead8]

url:    https://github.com/intel-lab-lkp/linux/commits/Hao-Xu/support-nonblock-submission-for-splice-pipe-to-pipe/20220607-161605
base:   d8271bf021438f468dab3cd84fe5279b5bbcead8
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20220608/202206082229.xoMAgqIw-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-1) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/96683840c3f19b77a536a259094d24e0cd93ebc0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Hao-Xu/support-nonblock-submission-for-splice-pipe-to-pipe/20220607-161605
        git checkout 96683840c3f19b77a536a259094d24e0cd93ebc0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> io_uring/splice.c:91:6: warning: no previous prototype for 'io_splice_support_nowait' [-Wmissing-prototypes]
      91 | bool io_splice_support_nowait(struct file *in, struct file *out)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~


vim +/io_splice_support_nowait +91 io_uring/splice.c

    90	
  > 91	bool io_splice_support_nowait(struct file *in, struct file *out)
    92	{
    93		if (get_pipe_info(in, true) && get_pipe_info(out, true))
    94			return true;
    95	
    96		return false;
    97	}
    98
kernel test robot June 9, 2022, 2:24 a.m. UTC | #3
Hi Hao,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on d8271bf021438f468dab3cd84fe5279b5bbcead8]

url:    https://github.com/intel-lab-lkp/linux/commits/Hao-Xu/support-nonblock-submission-for-splice-pipe-to-pipe/20220607-161605
base:   d8271bf021438f468dab3cd84fe5279b5bbcead8
config: i386-randconfig-s001 (https://download.01.org/0day-ci/archive/20220609/202206090959.CEWN5SEB-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-1) 11.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-26-gb3cf30ba-dirty
        # https://github.com/intel-lab-lkp/linux/commit/96683840c3f19b77a536a259094d24e0cd93ebc0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Hao-Xu/support-nonblock-submission-for-splice-pipe-to-pipe/20220607-161605
        git checkout 96683840c3f19b77a536a259094d24e0cd93ebc0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> io_uring/splice.c:91:6: sparse: sparse: symbol 'io_splice_support_nowait' was not declared. Should it be static?
diff mbox series

Patch

diff --git a/io_uring/splice.c b/io_uring/splice.c
index b2cd1044c3ee..650c70e3dde1 100644
--- a/io_uring/splice.c
+++ b/io_uring/splice.c
@@ -88,6 +88,14 @@  int io_splice_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 	return __io_splice_prep(req, sqe);
 }
 
+bool io_splice_support_nowait(struct file *in, struct file *out)
+{
+	if (get_pipe_info(in, true) && get_pipe_info(out, true))
+		return true;
+
+	return false;
+}
+
 int io_splice(struct io_kiocb *req, unsigned int issue_flags)
 {
 	struct io_splice *sp = io_kiocb_to_cmd(req);
@@ -100,9 +108,6 @@  int io_splice(struct io_kiocb *req, unsigned int issue_flags)
 	if (unlikely(!sp->len))
 		goto done;
 
-	if (issue_flags & IO_URING_F_NONBLOCK)
-		return -EAGAIN;
-
 	if (sp->flags & SPLICE_F_FD_IN_FIXED)
 		in = io_file_get_fixed(req, sp->splice_fd_in, issue_flags);
 	else
@@ -112,6 +117,16 @@  int io_splice(struct io_kiocb *req, unsigned int issue_flags)
 		goto done;
 	}
 
+	if (issue_flags & IO_URING_F_NONBLOCK) {
+		if (io_splice_support_nowait(in, out)) {
+			flags |= SPLICE_F_NONBLOCK;
+		} else {
+			if (!(sp->flags & SPLICE_F_FD_IN_FIXED))
+				io_put_file(in);
+			return -EAGAIN;
+		}
+	}
+
 	poff_in = (sp->off_in == -1) ? NULL : &sp->off_in;
 	poff_out = (sp->off_out == -1) ? NULL : &sp->off_out;
 
@@ -119,6 +134,9 @@  int io_splice(struct io_kiocb *req, unsigned int issue_flags)
 
 	if (!(sp->flags & SPLICE_F_FD_IN_FIXED))
 		io_put_file(in);
+	if (ret == -EAGAIN)
+		return ret;
+
 done:
 	if (ret != sp->len)
 		req_set_fail(req);