Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1502289 > unrolled thread
| Started by | Toshi Kani <toshi.kani@hpe.com> |
|---|---|
| First post | 2016-10-17 19:30 +0200 |
| Last post | 2016-10-17 19:50 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v2] DAX: enable iostat for read/write Toshi Kani <toshi.kani@hpe.com> - 2016-10-17 19:30 +0200
Re: [PATCH v2] DAX: enable iostat for read/write Ross Zwisler <ross.zwisler@linux.intel.com> - 2016-10-17 19:40 +0200
Re: [PATCH v2] DAX: enable iostat for read/write "Kani, Toshimitsu" <toshi.kani@hpe.com> - 2016-10-17 19:50 +0200
| From | Toshi Kani <toshi.kani@hpe.com> |
|---|---|
| Date | 2016-10-17 19:30 +0200 |
| Subject | [PATCH v2] DAX: enable iostat for read/write |
| Message-ID | <stjTz-6sY-17@gated-at.bofh.it> |
DAX IO path does not support iostat, but its metadata IO path does.
Therefore, iostat shows metadata IO statistics only, which has been
confusing to users.
Add iostat support to the DAX read/write path.
Note, iostat still does not support the DAX mmap path as it allows
user applications to access directly.
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
---
v2:
- Set a minimum of one sector (Dan Williams)
---
fs/dax.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/fs/dax.c b/fs/dax.c
index 014defd..43e5e7a 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -144,6 +144,34 @@ static sector_t to_sector(const struct buffer_head *bh,
return sector;
}
+static void dax_iostat_start(struct gendisk *disk, struct iov_iter *iter,
+ unsigned long *start)
+{
+ int rw = iov_iter_rw(iter);
+ int sec = iov_iter_count(iter) >> 9;
+ int cpu = part_stat_lock();
+
+ *start = jiffies;
+ part_round_stats(cpu, &disk->part0);
+ part_stat_inc(cpu, &disk->part0, ios[rw]);
+ part_stat_add(cpu, &disk->part0, sectors[rw], ((!sec) ? 1 : sec));
+ part_inc_in_flight(&disk->part0, rw);
+ part_stat_unlock();
+}
+
+static void dax_iostat_end(struct gendisk *disk, struct iov_iter *iter,
+ unsigned long start)
+{
+ unsigned long duration = jiffies - start;
+ int rw = iov_iter_rw(iter);
+ int cpu = part_stat_lock();
+
+ part_stat_add(cpu, &disk->part0, ticks[rw], duration);
+ part_round_stats(cpu, &disk->part0);
+ part_dec_in_flight(&disk->part0, rw);
+ part_stat_unlock();
+}
+
static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
loff_t start, loff_t end, get_block_t get_block,
struct buffer_head *bh)
@@ -265,9 +293,12 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
ssize_t retval = -EINVAL;
loff_t pos = iocb->ki_pos;
loff_t end = pos + iov_iter_count(iter);
+ struct gendisk *disk;
+ unsigned long start = 0;
memset(&bh, 0, sizeof(bh));
bh.b_bdev = inode->i_sb->s_bdev;
+ disk = bh.b_bdev->bd_disk;
if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
inode_lock(inode);
@@ -276,8 +307,14 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
if (!(flags & DIO_SKIP_DIO_COUNT))
inode_dio_begin(inode);
+ if (blk_queue_io_stat(disk->queue))
+ dax_iostat_start(disk, iter, &start);
+
retval = dax_io(inode, iter, pos, end, get_block, &bh);
+ if (start)
+ dax_iostat_end(disk, iter, start);
+
if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
inode_unlock(inode);
[toc] | [next] | [standalone]
| From | Ross Zwisler <ross.zwisler@linux.intel.com> |
|---|---|
| Date | 2016-10-17 19:40 +0200 |
| Message-ID | <stk3f-6wD-19@gated-at.bofh.it> |
| In reply to | #1502289 |
On Mon, Oct 17, 2016 at 11:18:58AM -0600, Toshi Kani wrote:
> DAX IO path does not support iostat, but its metadata IO path does.
> Therefore, iostat shows metadata IO statistics only, which has been
> confusing to users.
>
> Add iostat support to the DAX read/write path.
>
> Note, iostat still does not support the DAX mmap path as it allows
> user applications to access directly.
>
> Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> ---
> v2:
> - Set a minimum of one sector (Dan Williams)
What about Dave's feedback that this code just reimplements
generic_start_io_acct() and generic_end_io_acct()?
> ---
> fs/dax.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/fs/dax.c b/fs/dax.c
> index 014defd..43e5e7a 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -144,6 +144,34 @@ static sector_t to_sector(const struct buffer_head *bh,
> return sector;
> }
>
> +static void dax_iostat_start(struct gendisk *disk, struct iov_iter *iter,
> + unsigned long *start)
> +{
> + int rw = iov_iter_rw(iter);
> + int sec = iov_iter_count(iter) >> 9;
> + int cpu = part_stat_lock();
> +
> + *start = jiffies;
> + part_round_stats(cpu, &disk->part0);
> + part_stat_inc(cpu, &disk->part0, ios[rw]);
> + part_stat_add(cpu, &disk->part0, sectors[rw], ((!sec) ? 1 : sec));
> + part_inc_in_flight(&disk->part0, rw);
> + part_stat_unlock();
> +}
> +
> +static void dax_iostat_end(struct gendisk *disk, struct iov_iter *iter,
> + unsigned long start)
> +{
> + unsigned long duration = jiffies - start;
> + int rw = iov_iter_rw(iter);
> + int cpu = part_stat_lock();
> +
> + part_stat_add(cpu, &disk->part0, ticks[rw], duration);
> + part_round_stats(cpu, &disk->part0);
> + part_dec_in_flight(&disk->part0, rw);
> + part_stat_unlock();
> +}
> +
> static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
> loff_t start, loff_t end, get_block_t get_block,
> struct buffer_head *bh)
> @@ -265,9 +293,12 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
> ssize_t retval = -EINVAL;
> loff_t pos = iocb->ki_pos;
> loff_t end = pos + iov_iter_count(iter);
> + struct gendisk *disk;
> + unsigned long start = 0;
>
> memset(&bh, 0, sizeof(bh));
> bh.b_bdev = inode->i_sb->s_bdev;
> + disk = bh.b_bdev->bd_disk;
>
> if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
> inode_lock(inode);
> @@ -276,8 +307,14 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
> if (!(flags & DIO_SKIP_DIO_COUNT))
> inode_dio_begin(inode);
>
> + if (blk_queue_io_stat(disk->queue))
> + dax_iostat_start(disk, iter, &start);
> +
> retval = dax_io(inode, iter, pos, end, get_block, &bh);
>
> + if (start)
> + dax_iostat_end(disk, iter, start);
> +
> if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
> inode_unlock(inode);
>
[toc] | [prev] | [next] | [standalone]
| From | "Kani, Toshimitsu" <toshi.kani@hpe.com> |
|---|---|
| Date | 2016-10-17 19:50 +0200 |
| Message-ID | <stkcW-6Af-31@gated-at.bofh.it> |
| In reply to | #1502305 |
On Mon, 2016-10-17 at 11:29 -0600, Ross Zwisler wrote: > On Mon, Oct 17, 2016 at 11:18:58AM -0600, Toshi Kani wrote: > > > > DAX IO path does not support iostat, but its metadata IO path does. > > Therefore, iostat shows metadata IO statistics only, which has been > > confusing to users. > > > > Add iostat support to the DAX read/write path. > > > > Note, iostat still does not support the DAX mmap path as it allows > > user applications to access directly. > > > > Signed-off-by: Toshi Kani <toshi.kani@hpe.com> > > Cc: Andrew Morton <akpm@linux-foundation.org> > > Cc: Alexander Viro <viro@zeniv.linux.org.uk> > > Cc: Dan Williams <dan.j.williams@intel.com> > > Cc: Ross Zwisler <ross.zwisler@linux.intel.com> > > --- > > v2: > > - Set a minimum of one sector (Dan Williams) > > What about Dave's feedback that this code just reimplements > generic_start_io_acct() and generic_end_io_acct()? My bad. There was some issue in my email box and I just realized it. Please disregard this version... Thanks, -Toshi
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web