linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] DAX: enable iostat for read/write
@ 2016-10-14 17:25 Toshi Kani
  2016-10-14 17:35 ` Dan Williams
  2016-10-15  7:54 ` Dave Chinner
  0 siblings, 2 replies; 7+ messages in thread
From: Toshi Kani @ 2016-10-14 17:25 UTC (permalink / raw)
  To: akpm, dan.j.williams
  Cc: viro, ross.zwisler, linux-nvdimm, linux-fsdevel, linux-kernel,
	Toshi Kani

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>
---
 fs/dax.c |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/fs/dax.c b/fs/dax.c
index 014defd..3aaaac2 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);
+	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);
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] DAX: enable iostat for read/write
  2016-10-14 17:25 [PATCH] DAX: enable iostat for read/write Toshi Kani
@ 2016-10-14 17:35 ` Dan Williams
  2016-10-14 18:47   ` Kani, Toshimitsu
  2016-10-15  7:54 ` Dave Chinner
  1 sibling, 1 reply; 7+ messages in thread
From: Dan Williams @ 2016-10-14 17:35 UTC (permalink / raw)
  To: Toshi Kani
  Cc: Andrew Morton, Al Viro, Ross Zwisler, linux-nvdimm@lists.01.org,
	linux-fsdevel, linux-kernel

On Fri, Oct 14, 2016 at 10:25 AM, Toshi Kani <toshi.kani@hpe.com> 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>
> ---
>  fs/dax.c |   37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git a/fs/dax.c b/fs/dax.c
> index 014defd..3aaaac2 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;

Should this be a minimum of one sector since we allow unaligned
transfers through this interface?

...or is iov_iter_count() somehow guaranteed to be sector aligned here?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] DAX: enable iostat for read/write
  2016-10-14 17:35 ` Dan Williams
@ 2016-10-14 18:47   ` Kani, Toshimitsu
  0 siblings, 0 replies; 7+ messages in thread
From: Kani, Toshimitsu @ 2016-10-14 18:47 UTC (permalink / raw)
  To: dan.j.williams
  Cc: viro, ross.zwisler, linux-nvdimm@lists.01.org, linux-kernel,
	akpm, linux-fsdevel

On Fri, 2016-10-14 at 10:35 -0700, Dan Williams wrote:
> On Fri, Oct 14, 2016 at 10:25 AM, Toshi Kani <toshi.kani@hpe.com>
> 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>
> > ---
> >  fs/dax.c |   37 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 37 insertions(+)
> > 
> > diff --git a/fs/dax.c b/fs/dax.c
> > index 014defd..3aaaac2 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;
> 
> Should this be a minimum of one sector since we allow unaligned
> transfers through this interface?
> 
> ...or is iov_iter_count() somehow guaranteed to be sector aligned
> here?

You are right. I will update to set a minimum of one sector in v2. 

Thanks!
-Toshi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] DAX: enable iostat for read/write
  2016-10-14 17:25 [PATCH] DAX: enable iostat for read/write Toshi Kani
  2016-10-14 17:35 ` Dan Williams
@ 2016-10-15  7:54 ` Dave Chinner
  2016-10-17 17:40   ` Kani, Toshimitsu
  1 sibling, 1 reply; 7+ messages in thread
From: Dave Chinner @ 2016-10-15  7:54 UTC (permalink / raw)
  To: Toshi Kani
  Cc: akpm, dan.j.williams, viro, ross.zwisler, linux-nvdimm,
	linux-fsdevel, linux-kernel

On Fri, Oct 14, 2016 at 11:25:13AM -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>
> ---
>  fs/dax.c |   37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/fs/dax.c b/fs/dax.c
> index 014defd..3aaaac2 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);
> +	part_inc_in_flight(&disk->part0, rw);
> +	part_stat_unlock();
> +}

Why reimplement generic_start_io_acct() and generic_end_io_acct()?

-Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] DAX: enable iostat for read/write
  2016-10-15  7:54 ` Dave Chinner
@ 2016-10-17 17:40   ` Kani, Toshimitsu
  2016-10-17 18:55     ` Dan Williams
  0 siblings, 1 reply; 7+ messages in thread
From: Kani, Toshimitsu @ 2016-10-17 17:40 UTC (permalink / raw)
  To: david
  Cc: dan.j.williams, viro, ross.zwisler, linux-nvdimm@lists.01.org,
	linux-kernel, akpm, linux-fsdevel

On Sat, 2016-10-15 at 18:54 +1100, Dave Chinner wrote:
> On Fri, Oct 14, 2016 at 11:25:13AM -0600, Toshi Kani wrote:
 :
> > +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);
> > +	part_inc_in_flight(&disk->part0, rw);
> > +	part_stat_unlock();
> > +}
> 
> Why reimplement generic_start_io_acct() and generic_end_io_acct()?

It was modeled after __nd_iostat_start() / nd_iostart_end().  I agree
that we can use generic_start_io_acct() and generic_end_io_acct() here.

Should we also change the nd interface to use the generic version as
well?

Thanks,
-Toshi

ps.
Sorry I realized this comment after sending out v2...

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] DAX: enable iostat for read/write
  2016-10-17 17:40   ` Kani, Toshimitsu
@ 2016-10-17 18:55     ` Dan Williams
  2016-10-17 19:12       ` Kani, Toshimitsu
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Williams @ 2016-10-17 18:55 UTC (permalink / raw)
  To: Kani, Toshimitsu
  Cc: david, viro, ross.zwisler, linux-nvdimm@lists.01.org,
	linux-kernel, akpm, linux-fsdevel

On Mon, Oct 17, 2016 at 10:40 AM, Kani, Toshimitsu <toshi.kani@hpe.com> wrote:
> On Sat, 2016-10-15 at 18:54 +1100, Dave Chinner wrote:
>> On Fri, Oct 14, 2016 at 11:25:13AM -0600, Toshi Kani wrote:
>  :
>> > +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);
>> > +part_inc_in_flight(&disk->part0, rw);
>> > +part_stat_unlock();
>> > +}
>>
>> Why reimplement generic_start_io_acct() and generic_end_io_acct()?
>
> It was modeled after __nd_iostat_start() / nd_iostart_end().  I agree
> that we can use generic_start_io_acct() and generic_end_io_acct() here.
>
> Should we also change the nd interface to use the generic version as
> well?

Yes, sounds good to me.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] DAX: enable iostat for read/write
  2016-10-17 18:55     ` Dan Williams
@ 2016-10-17 19:12       ` Kani, Toshimitsu
  0 siblings, 0 replies; 7+ messages in thread
From: Kani, Toshimitsu @ 2016-10-17 19:12 UTC (permalink / raw)
  To: dan.j.williams
  Cc: viro, david, linux-nvdimm@lists.01.org, ross.zwisler, akpm,
	linux-fsdevel, linux-kernel

On Mon, 2016-10-17 at 11:55 -0700, Dan Williams wrote:
> On Mon, Oct 17, 2016 at 10:40 AM, Kani, Toshimitsu <toshi.kani@hpe.co
> m> wrote:
> > 
> > On Sat, 2016-10-15 at 18:54 +1100, Dave Chinner wrote:
> > > 
> > > On Fri, Oct 14, 2016 at 11:25:13AM -0600, Toshi Kani wrote:
> >  :
> > > 
> > > > 
> > > > +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);
> > > > +part_inc_in_flight(&disk->part0, rw);
> > > > +part_stat_unlock();
> > > > +}
> > > 
> > > Why reimplement generic_start_io_acct() and
> > > generic_end_io_acct()?
> > 
> > It was modeled after __nd_iostat_start() / nd_iostart_end().  I
> > agree that we can use generic_start_io_acct() and
> > generic_end_io_acct() here.
> > 
> > Should we also change the nd interface to use the generic version
> > as well?
> 
> Yes, sounds good to me.

Will do. Thanks!
-Toshi

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-10-17 19:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-14 17:25 [PATCH] DAX: enable iostat for read/write Toshi Kani
2016-10-14 17:35 ` Dan Williams
2016-10-14 18:47   ` Kani, Toshimitsu
2016-10-15  7:54 ` Dave Chinner
2016-10-17 17:40   ` Kani, Toshimitsu
2016-10-17 18:55     ` Dan Williams
2016-10-17 19:12       ` Kani, Toshimitsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).