Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1208319 > unrolled thread

[PATCH v10 0/6] block: loop: improve loop with AIO

Started byMing Lei <ming.lei@canonical.com>
First post2015-08-17 04:40 +0200
Last post2015-08-19 11:50 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v10 0/6] block: loop: improve loop with AIO Ming Lei <ming.lei@canonical.com> - 2015-08-17 04:40 +0200
    [PATCH v10 5/6] block: loop: introduce ioctl command of LOOP_SET_DIRECT_IO Ming Lei <ming.lei@canonical.com> - 2015-08-17 04:40 +0200
    Re: [PATCH v10 0/6] block: loop: improve loop with AIO Christoph Hellwig <hch@infradead.org> - 2015-08-17 21:20 +0200
      Re: [PATCH v10 0/6] block: loop: improve loop with AIO Ming Lei <ming.lei@canonical.com> - 2015-08-19 11:50 +0200

#1208319 — [PATCH v10 0/6] block: loop: improve loop with AIO

FromMing Lei <ming.lei@canonical.com>
Date2015-08-17 04:40 +0200
Subject[PATCH v10 0/6] block: loop: improve loop with AIO
Message-ID<pYiv8-2ga-3@gated-at.bofh.it>
Hi Guys,

There are about 3 advantages to use direct I/O and AIO on
read/write loop's backing file:

1) double cache can be avoided, then memory usage gets
decreased a lot

2) not like user space direct I/O, there isn't cost of
pinning pages

3) avoid context switch for obtaining good throughput
- in buffered file read, random I/O throughput is often obtained
only if they are submitted concurrently from lots of tasks; but for
sequential I/O, most of times they can be hit from page cache, so
concurrent submissions often introduce unnecessary context switch
and can't improve throughput much. There was such discussion[1]
to use non-blocking I/O to improve the problem for application.
- with direct I/O and AIO, concurrent submissions can be
avoided and random read throughput can't be affected meantime

So this patchset trys to improve loop via AIO, and about 45% memory
usage can be decreased, see detailed data in commit log of patch6,
also IO throughput gets a bit improved too.

Following losetup changes for supporting loop dio/aio:
        - losetup git tree:
                http://kernel.ubuntu.com/git/ming/util-linux.git/log/?h=loop-dio-v7
        - how to set direct io
                losetup --direct-io 1 /dev/loopN
        - how to clear direct io
                losetup --direct-io 0 /dev/loopN
        - how to show if direct io is used for accessing backing file
                losetup -l

V10:
        - only 4/6 and 6/6 updated
        - don't switch to direct I/O runtime as required by Christoph Hellwig
        - move check of ->transfer into loop settup from I/O path
        - check aligment using backing device's logical block size instead of
          min I/O size
        - run tests against 4.2-rc6-next-20150814
        - run xfstests over loop/ext4 with direct I/O, and passed

V9:
        - only 4/6 and 5/6 updated
        - update __loop_update_dio()
        - serialize direct I/O with buffered I/O for avoiding
        possible race

V8:
        - only 4/6 and 5/6 updated
        - support direct io when backing device's sector size is
          512, 1024, 2048 and 4096(only 512-byte sector was supported
          in V7)
V7:
        - only 4/6 and 5/6 updated
        - update direct io after lo->offset is changed(4/6)
        - fix updating LO_FLAGS_DIRECT_IO in __loop_update_dio()(4/6)
        - introduce ioctl cmd of LOOP_SET_DIRECT_IO(5/6) for case of
          'mount -o loop'

V6:
        - only patch 4 and patch 5 get updated
        - check lo->lo_offset to decide if direct IO can be supported(4/5)
        - introduce one flag for userspace(losetup) to keep updated
        if using direct I/O to access backing file(4/5)
        - implement patches for util-linux(losetup) so that losetup can
        enable direct I/O feature:(4/5)

           http://kernel.ubuntu.com/git/ming/util-linux.git/log/?h=losetup-dio

        - remove the direct IO control interface from sysfs(4/5)
        - handle partial read in case of direct read (5/5)
        - add more comments for direct IO (5/5)
V5:
        - don't introduce IOCB_DONT_DIRTY_PAGE and bypass dirtying
        for ITER_KVEC and ITER_BVEC direct IO(read), as required by
        Christoph

V4:
        - add detailed commit log for 'use kthread_work'
        - allow userspace(sysfs, losetup) to decide if dio/aio is
        used as suggested by Christoph and Dave Chinner
        - only use dio if the backing block device's min io size
        is 512 as pointed by Dave Chinner & Christoph
V3:
        - based on Al's iov_iter work and Christoph's kiocb changes
        - use kthread_work
        - introduce IOCB_DONT_DIRTY_PAGE flag
        - set QUEUE_FLAG_NOMERGES for loop's request queue
V2:
        - remove 'extra' parameter to aio_kernel_alloc()
        - try to avoid memory allcation inside queue req callback
        - introduce 'use_mq' sysfs file for enabling kernel aio or disabling it
V1:
        - link:
                http://marc.info/?t=140803157700004&r=1&w=2
        - improve failure path in aio_kernel_submit()

 drivers/block/loop.c      | 275 ++++++++++++++++++++++++++++++++++++++++++++++++-------------
 drivers/block/loop.h      |  13 +--
 fs/direct-io.c            |   9 +-
 include/uapi/linux/loop.h |   2 +
 4 files changed, 234 insertions(+), 65 deletions(-)

Thanks,
Ming

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1208320 — [PATCH v10 5/6] block: loop: introduce ioctl command of LOOP_SET_DIRECT_IO

FromMing Lei <ming.lei@canonical.com>
Date2015-08-17 04:40 +0200
Subject[PATCH v10 5/6] block: loop: introduce ioctl command of LOOP_SET_DIRECT_IO
Message-ID<pYiv8-2ga-17@gated-at.bofh.it>
In reply to#1208319
If loop block is mounted via 'mount -o loop', it isn't easy
to pass file descriptor opened as O_DIRECT, so this patch
introduces a new command to support direct IO for this case.

Cc: linux-api@vger.kernel.org
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/block/loop.c      | 19 +++++++++++++++++++
 include/uapi/linux/loop.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 06cad7e..75db3b9 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1228,6 +1228,20 @@ static int loop_set_capacity(struct loop_device *lo, struct block_device *bdev)
 	return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit);
 }
 
+static int loop_set_dio(struct loop_device *lo, unsigned long arg)
+{
+	int error = -ENXIO;
+	if (lo->lo_state != Lo_bound)
+		goto out;
+
+	__loop_update_dio(lo, !!arg);
+	if (lo->use_dio == !!arg)
+		return 0;
+	error = -EINVAL;
+ out:
+	return error;
+}
+
 static int lo_ioctl(struct block_device *bdev, fmode_t mode,
 	unsigned int cmd, unsigned long arg)
 {
@@ -1271,6 +1285,11 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
 		if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
 			err = loop_set_capacity(lo, bdev);
 		break;
+	case LOOP_SET_DIRECT_IO:
+		err = -EPERM;
+		if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
+			err = loop_set_dio(lo, arg);
+		break;
 	default:
 		err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
 	}
diff --git a/include/uapi/linux/loop.h b/include/uapi/linux/loop.h
index 949851c..c8125ec 100644
--- a/include/uapi/linux/loop.h
+++ b/include/uapi/linux/loop.h
@@ -87,6 +87,7 @@ struct loop_info64 {
 #define LOOP_GET_STATUS64	0x4C05
 #define LOOP_CHANGE_FD		0x4C06
 #define LOOP_SET_CAPACITY	0x4C07
+#define LOOP_SET_DIRECT_IO	0x4C08
 
 /* /dev/loop-control interface */
 #define LOOP_CTL_ADD		0x4C80
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1208800

FromChristoph Hellwig <hch@infradead.org>
Date2015-08-17 21:20 +0200
Message-ID<pYy6R-83E-1@gated-at.bofh.it>
In reply to#1208319
Thanks Ming,

this series looks fine to me:

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1209750

FromMing Lei <ming.lei@canonical.com>
Date2015-08-19 11:50 +0200
Message-ID<pZ8am-28S-27@gated-at.bofh.it>
In reply to#1208800
On Tue, Aug 18, 2015 at 3:19 AM, Christoph Hellwig <hch@infradead.org> wrote:
> Thanks Ming,
>
> this series looks fine to me:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks Christoph for reviewing.

Jens, is there any chance to merge this patchset into v4.3?

Thanks,

> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web