2016-08-23 22:04:10

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH v2 0/9] re-enable DAX PMD support

DAX PMDs have been disabled since Jan Kara introduced DAX radix tree based
locking. This series allows DAX PMDs to participate in the DAX radix tree
based locking scheme so that they can be re-enabled.

Changes since v1:
- PMD entry locking is now done based on the starting offset of the PMD
entry, rather than on the radix tree slot which was unreliable. (Jan)
- Fixed the one issue I could find with hole punch. As far as I can tell
hole punch now works correctly for both PMD and PTE DAX entries, 4k zero
pages and huge zero pages.
- Fixed the way that ext2 returns the size of holes in ext2_get_block().
(Jan)
- Made the 'wait_table' global variable static in respnse to a sparse
warning.
- Fixed some more inconsitent usage between the names 'ret' and 'entry'
for radix tree entry variables.

Ross Zwisler (9):
ext4: allow DAX writeback for hole punch
ext2: tell DAX the size of allocation holes
ext4: tell DAX the size of allocation holes
dax: remove buffer_size_valid()
dax: make 'wait_table' global variable static
dax: consistent variable naming for DAX entries
dax: coordinate locking for offsets in PMD range
dax: re-enable DAX PMD support
dax: remove "depends on BROKEN" from FS_DAX_PMD

fs/Kconfig | 1 -
fs/dax.c | 297 +++++++++++++++++++++++++++++-----------------------
fs/ext2/inode.c | 3 +
fs/ext4/inode.c | 7 +-
include/linux/dax.h | 29 ++++-
mm/filemap.c | 6 +-
6 files changed, 201 insertions(+), 142 deletions(-)

--
2.9.0


2016-08-23 22:04:12

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

When DAX calls ext2_get_block() and the file offset points to a hole we
currently don't set bh_result->b_size. When we re-enable PMD faults DAX
will need bh_result->b_size to tell it the size of the hole so it can
decide whether to fault in a 4 KiB zero page or a 2 MiB zero page.

Signed-off-by: Ross Zwisler <[email protected]>
---
fs/ext2/inode.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index d5c7d09..dd55d74 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -773,6 +773,9 @@ int ext2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_
if (ret > 0) {
bh_result->b_size = (ret << inode->i_blkbits);
ret = 0;
+ } else if (ret == 0) {
+ /* hole case, need to fill in bh_result->b_size */
+ bh_result->b_size = 1 << inode->i_blkbits;
}
return ret;

--
2.9.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

2016-08-25 07:57:28

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

Hi Ross,

can you take at my (fully working, but not fully cleaned up) version
of the iomap based DAX code here:

http://git.infradead.org/users/hch/vfs.git/shortlog/refs/heads/iomap-dax

By using iomap we don't even have the size hole problem and totally
get out of the reverse-engineer what buffer_heads are trying to tell
us business. It also gets rid of the other warts of the DAX path
due to pretending to be like direct I/O, so this might be a better
way forward also for ext2/4.

2016-08-25 19:25:31

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Thu, Aug 25, 2016 at 12:57:28AM -0700, Christoph Hellwig wrote:
> Hi Ross,
>
> can you take at my (fully working, but not fully cleaned up) version
> of the iomap based DAX code here:
>
> http://git.infradead.org/users/hch/vfs.git/shortlog/refs/heads/iomap-dax
>
> By using iomap we don't even have the size hole problem and totally
> get out of the reverse-engineer what buffer_heads are trying to tell
> us business. It also gets rid of the other warts of the DAX path
> due to pretending to be like direct I/O, so this might be a better
> way forward also for ext2/4.

Sure, I'll take a look.

2016-08-26 21:29:34

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Thu, Aug 25, 2016 at 12:57:28AM -0700, Christoph Hellwig wrote:
> Hi Ross,
>
> can you take at my (fully working, but not fully cleaned up) version
> of the iomap based DAX code here:
>
> http://git.infradead.org/users/hch/vfs.git/shortlog/refs/heads/iomap-dax
>
> By using iomap we don't even have the size hole problem and totally
> get out of the reverse-engineer what buffer_heads are trying to tell
> us business. It also gets rid of the other warts of the DAX path
> due to pretending to be like direct I/O, so this might be a better
> way forward also for ext2/4.

In general I agree that the usage of struct iomap seems more straightforward
than the old way of using struct buffer_head + get_block_t. I really don't
think we want to have two competing DAX I/O and fault paths, though, which I
assume everyone else agrees with as well.

These changes don't remove the things in XFS needed by the old I/O and fault
paths (e.g. xfs_get_blocks_direct() is still there an unchanged). Is the
correct way forward to get buy-in from ext2/ext4 so that they also move to
supporting an iomap based I/O path (xfs_file_iomap_begin(),
xfs_iomap_write_direct(), etc?). That would allow us to have parallel I/O and
fault paths for a while, then remove the old buffer_head based versions when
the three supported filesystems have moved to iomap.

If ext2 and ext4 don't choose to move to iomap, though, I don't think we want
to have a separate I/O & fault path for iomap/XFS. That seems too painful,
and the old buffer_head version should continue to work, ugly as it may be.

Assuming we can get buy-in from ext4/ext2, I can work on a PMD version of the
iomap based fault path that is equivalent to the buffer_head based one I sent
out in my series, and we can all eventually move to that.

A few comments/questions on the implementation:

1) In your mail above you say "It also gets rid of the other warts of the DAX
path due to pretending to be like direct I/O". I assume by this you mean
the code in dax_do_io() around DIO_LOCKING, inode_dio_begin(), etc?
Perhaps there are other things as well in XFS, but this is what I see in
the DAX code. If so, yep, this seems like a win. I don't understand how
DIO_LOCKING is relevant to the DAX I/O path, as we never mix buffered and
direct access.

The comment in dax_do_io() for the inode_dio_begin() call says that it
prevents the I/O from races with truncate. Am I correct that we now get
this protection via the xfs_rw_ilock()/xfs_rw_iunlock() calls in
xfs_file_dax_write()?

2) Just a nit, I noticed that you used "~(PAGE_SIZE - 1)" in several places in
iomap_dax_actor() and iomap_dax_fault() instead of PAGE_MASK. Was this
intentional?

3) It's kind of weird having iomap_dax_fault() in fs/dax.c but having
iomap_dax_actor() and iomap_dax_rw() in fs/iomap.c? I'm guessing the
latter is placed where it is because it uses iomap_apply(), which is local
to fs/iomap.c? Anyway, it would be nice if we could keep them together, if
possible.

4) In iomap_dax_actor() you do this check:

WARN_ON_ONCE(iomap->type != IOMAP_MAPPED);

If we hit this we should bail with -EIO, yea? Otherwise we could write to
unmapped space or something horrible.

5) In iomap_dax_fault, I think the "I/O beyond the end of the file" check
might have been broken. Take for example an I/O to the second page of a
file, where the file has size one page. So:

vmf->pgoff = 1
i_size_read(inode) = 4096

Here's the old code in dax_fault():

size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;
if (vmf->pgoff >= size)
return VM_FAULT_SIGBUS;

size = (4096 + 4096 - 1) >> PAGE_SHIFT = 1
vmf->pgoff is 1 and size is 1, so we return SIGBUS

Here's the new code:

if (pos >= i_size_read(inode) + PAGE_SIZE - 1)
return VM_FAULT_SIGBUS;

pos = vmf->pgoff << PAGE_SHIFT = 4096
i_size_read(inode) + PAGE_SIZE - 1 = 8193
so, 'pos' isn't >= where we calculate the end of the file to be, so we do I/O

Basically the old check did the "+ PAGE_SIZE - 1" so that the >> PAGE_SHIFT
was sure to round up to the next full page. You don't need this with your
current logic, so I think the test should just be:

if (pos >= i_size_read(inode))
return VM_FAULT_SIGBUS;

Right?

6) Regarding the "we don't even have the size hole problem" comment in your
mail, the current PMD logic requires us to know the size of the hole. This
is important so that we can fault in a huge zero page if we have a 2 MiB
hole. It's fine if that 2 MiB page then gets fragmented into 4k DAX
allocations when we start to do writes, but the path the other way doesn't
work. If we don't know the size of holes then we can't fault in a 2 MiB
zero page, so we'll use 4k zero pages to satisfy reads. This means that if
later we want to fault in a 2MiB DAX allocation, we don't have a single
entry that we can use to lock the entire 2MiB range while we clean the
radix tree an unmap the range from all the user processes. With the
current PMD logic this will mean that if someone does a 4k read that faults
in a 4k zero page, we will only use 4k faults for that range and won't use
PMDs.

The current XFS code in the v4.8 tree tells me the size of the hole, and I
think we need to keep this functionality.

2016-08-29 00:42:34

by Dave Chinner

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Fri, Aug 26, 2016 at 03:29:34PM -0600, Ross Zwisler wrote:
> On Thu, Aug 25, 2016 at 12:57:28AM -0700, Christoph Hellwig wrote:
> > Hi Ross,
> >
> > can you take at my (fully working, but not fully cleaned up) version
> > of the iomap based DAX code here:
> >
> > http://git.infradead.org/users/hch/vfs.git/shortlog/refs/heads/iomap-dax
> >
> > By using iomap we don't even have the size hole problem and totally
> > get out of the reverse-engineer what buffer_heads are trying to tell
> > us business. It also gets rid of the other warts of the DAX path
> > due to pretending to be like direct I/O, so this might be a better
> > way forward also for ext2/4.
>
> In general I agree that the usage of struct iomap seems more straightforward
> than the old way of using struct buffer_head + get_block_t. I really don't
> think we want to have two competing DAX I/O and fault paths, though, which I
> assume everyone else agrees with as well.

We'll be moving XFS this way, regardless of whether the generic DAX
code goes that way or not. iomap is a much cleaner, more efficient
interface than get_blocks via bufferheads. We are slowly removing
bufferheads from XFS so anything that uses them or depends on them
that Xfs requires is going to have an iomap-based variant written
for it.

Christoph is doing the hard yards to make iomap a VFS level
interface because that's a) the most efficient way to implement it,
and b) it's the right place for IO path extent mapping abstractions.
So there will be a iomap path for DAX, just like there will be a
iomap path for direct IO, regardless of what other filesystems
implement. i.e. other filesystems can move to the more efficient
iomap infrastructure if they want, but we can't force them to do so.

As such, the generic DAX path can either remain as it is, or we can
move to iomap and use wrappers for converting get_block() +
bufferehead to iomaps on non-iomap filesystems. (i.e. similar to
the existing iomap_to_bh() for allowing iomap lookups to be used to
replace bufferheads returned by get_block().)

I'd much prefer we move DAX to iomaps before there is wider uptake
of it in other filesystems - I've been saying we should use iomaps
for DAX right from the start. Now we have the iomap infrastructure
in place we should jump straight to it. If we have to drag ext4
kicking and screaming into the 1990s to get there then so be it - it
won't be the first time...

> These changes don't remove the things in XFS needed by the old I/O and fault
> paths (e.g. xfs_get_blocks_direct() is still there an unchanged). Is the

Yes, they'll remain until their functionality has been replaced by
iomap functions. e.g. xfs_get_blocks_direct() can't be removed
until the direct IO path has an iomap interface.

....

> 6) Regarding the "we don't even have the size hole problem" comment in your
> mail, the current PMD logic requires us to know the size of the hole. This
....
> The current XFS code in the v4.8 tree tells me the size of the hole, and I
> think we need to keep this functionality.

IOMAP_HOLE extents. It's a requirement of the iomap infrastructure
that the filesystem reports hole extents in full for the range being
mapped.

Cheers,

Dave.

--
Dave Chinner
[email protected]

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

2016-08-29 07:41:16

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Fri, Aug 26, 2016 at 03:29:34PM -0600, Ross Zwisler wrote:
> These changes don't remove the things in XFS needed by the old I/O and fault
> paths (e.g. xfs_get_blocks_direct() is still there an unchanged). Is the
> correct way forward to get buy-in from ext2/ext4 so that they also move to
> supporting an iomap based I/O path (xfs_file_iomap_begin(),
> xfs_iomap_write_direct(), etc?). That would allow us to have parallel I/O and
> fault paths for a while, then remove the old buffer_head based versions when
> the three supported filesystems have moved to iomap.
>
> If ext2 and ext4 don't choose to move to iomap, though, I don't think we want
> to have a separate I/O & fault path for iomap/XFS. That seems too painful,
> and the old buffer_head version should continue to work, ugly as it may be.

We're going to move forward killing buffer_heads in XFS. I think ext4
would dramatically benefit from this a well, as would ext2 (although I
think all that DAX work in ext2 is a horrible idea to start with).

If I don't get buy-in for the iomap DAX work in the dax code we'll just
have to keep it separate. That buffer_head mess just isn't maintainable
the long run.

> 1) In your mail above you say "It also gets rid of the other warts of the DAX
> path due to pretending to be like direct I/O". I assume by this you mean
> the code in dax_do_io() around DIO_LOCKING, inode_dio_begin(), etc?

Yes.

> Perhaps there are other things as well in XFS, but this is what I see in
> the DAX code. If so, yep, this seems like a win. I don't understand how
> DIO_LOCKING is relevant to the DAX I/O path, as we never mix buffered and
> direct access.

It's related to doing stupid copy and paste from direct I/O in the DAX
code.

> The comment in dax_do_io() for the inode_dio_begin() call says that it
> prevents the I/O from races with truncate. Am I correct that we now get
> this protection via the xfs_rw_ilock()/xfs_rw_iunlock() calls in
> xfs_file_dax_write()?

Yes, XFS always has a lock over reads that serializes with truncate.
Currenrly it's the XFS i_iolock, but I'll remove that soon and use the
VFS i_rwsem instead. For ext2/4 we could go straight to i_rwsem in
shared mode.

> 2) Just a nit, I noticed that you used "~(PAGE_SIZE - 1)" in several places in
> iomap_dax_actor() and iomap_dax_fault() instead of PAGE_MASK. Was this
> intentional?

Mostly because that's how I think. I'm fine using PAGE_MASK, though.

> 3) It's kind of weird having iomap_dax_fault() in fs/dax.c but having
> iomap_dax_actor() and iomap_dax_rw() in fs/iomap.c? I'm guessing the
> latter is placed where it is because it uses iomap_apply(), which is local
> to fs/iomap.c? Anyway, it would be nice if we could keep them together, if
> possible.

It's still work in progress and could use a few cleanups.

>
> 4) In iomap_dax_actor() you do this check:
>
> WARN_ON_ONCE(iomap->type != IOMAP_MAPPED);
>
> If we hit this we should bail with -EIO, yea? Otherwise we could write to
> unmapped space or something horrible.

Fine with me.

> 5) In iomap_dax_fault, I think the "I/O beyond the end of the file" check
> might have been broken. Take for example an I/O to the second page of a
> file, where the file has size one page. So:

sure, I can fix this up.

> 6) Regarding the "we don't even have the size hole problem" comment in your
> mail, the current PMD logic requires us to know the size of the hole.

And a big part of the iomap interface is proper reporting of holes.

2016-08-29 12:57:41

by Theodore Y. Ts'o

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Mon, Aug 29, 2016 at 12:41:16AM -0700, Christoph Hellwig wrote:
>
> We're going to move forward killing buffer_heads in XFS. I think ext4
> would dramatically benefit from this a well, as would ext2 (although I
> think all that DAX work in ext2 is a horrible idea to start with).

It's been on my todo list. The only reason why I haven't done it yet
is because I knew you were working on a solution, and I didn't want to
do things one way for buffered I/O, and a different way for Direct
I/O, and disentangling the DIO code and the different assumptions of
how different file systems interact with the DIO code is a *mess*.

It may have gotten better more recently, but a few years ago I took a
look at it and backed slowly away.....

- Ted

2016-08-30 07:21:29

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Mon, Aug 29, 2016 at 08:57:41AM -0400, Theodore Ts'o wrote:
> It's been on my todo list. The only reason why I haven't done it yet
> is because I knew you were working on a solution, and I didn't want to
> do things one way for buffered I/O, and a different way for Direct
> I/O, and disentangling the DIO code and the different assumptions of
> how different file systems interact with the DIO code is a *mess*.

It is. I have an almost working iomap direct I/O implementation, which
simplifies a lot of this. Partially because it expects sane locking
(a shared lock should be held over read, fortunately we now have i_rwsem
for that) and allows less opt-in/out behavior, and partially just
because we have so much better infrastructure now (iomap, bio chaining,
iov_iters, ...).

The iomap version is still work in progress, but I'm about to post
a cut down version for block devices which reduces I/O latency by
20%.

2016-08-30 23:01:50

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH v2 0/9] re-enable DAX PMD support

On Tue, Aug 23, 2016 at 04:04:10PM -0600, Ross Zwisler wrote:
> DAX PMDs have been disabled since Jan Kara introduced DAX radix tree based
> locking. This series allows DAX PMDs to participate in the DAX radix tree
> based locking scheme so that they can be re-enabled.
>
> Changes since v1:
> - PMD entry locking is now done based on the starting offset of the PMD
> entry, rather than on the radix tree slot which was unreliable. (Jan)
> - Fixed the one issue I could find with hole punch. As far as I can tell
> hole punch now works correctly for both PMD and PTE DAX entries, 4k zero
> pages and huge zero pages.
> - Fixed the way that ext2 returns the size of holes in ext2_get_block().
> (Jan)
> - Made the 'wait_table' global variable static in respnse to a sparse
> warning.
> - Fixed some more inconsitent usage between the names 'ret' and 'entry'
> for radix tree entry variables.
>
> Ross Zwisler (9):
> ext4: allow DAX writeback for hole punch
> ext2: tell DAX the size of allocation holes
> ext4: tell DAX the size of allocation holes
> dax: remove buffer_size_valid()
> dax: make 'wait_table' global variable static
> dax: consistent variable naming for DAX entries
> dax: coordinate locking for offsets in PMD range
> dax: re-enable DAX PMD support
> dax: remove "depends on BROKEN" from FS_DAX_PMD
>
> fs/Kconfig | 1 -
> fs/dax.c | 297 +++++++++++++++++++++++++++++-----------------------
> fs/ext2/inode.c | 3 +
> fs/ext4/inode.c | 7 +-
> include/linux/dax.h | 29 ++++-
> mm/filemap.c | 6 +-
> 6 files changed, 201 insertions(+), 142 deletions(-)
>
> --
> 2.9.0

Ping on this series? Any objections or comments?

2016-08-31 20:20:48

by Kani, Toshimitsu

[permalink] [raw]
Subject: Re: [PATCH v2 0/9] re-enable DAX PMD support

On Tue, 2016-08-30 at 17:01 -0600, Ross Zwisler wrote:
> On Tue, Aug 23, 2016 at 04:04:10PM -0600, Ross Zwisler wrote:
> >
> > DAX PMDs have been disabled since Jan Kara introduced DAX radix
> > tree based locking.  This series allows DAX PMDs to participate in
> > the DAX radix tree based locking scheme so that they can be re-
> > enabled.
> >
> > Changes since v1:
> >  - PMD entry locking is now done based on the starting offset of
> > the PMD entry, rather than on the radix tree slot which was
> > unreliable. (Jan)
> >  - Fixed the one issue I could find with hole punch.  As far as I
> > can tell hole punch now works correctly for both PMD and PTE DAX
> > entries, 4k zero pages and huge zero pages.
> >  - Fixed the way that ext2 returns the size of holes in
> > ext2_get_block(). (Jan)
> >  - Made the 'wait_table' global variable static in respnse to a
> > sparse warning.
> >  - Fixed some more inconsitent usage between the names 'ret' and
> > 'entry' for radix tree entry variables.
> >
> > Ross Zwisler (9):
> >   ext4: allow DAX writeback for hole punch
> >   ext2: tell DAX the size of allocation holes
> >   ext4: tell DAX the size of allocation holes
> >   dax: remove buffer_size_valid()
> >   dax: make 'wait_table' global variable static
> >   dax: consistent variable naming for DAX entries
> >   dax: coordinate locking for offsets in PMD range
> >   dax: re-enable DAX PMD support
> >   dax: remove "depends on BROKEN" from FS_DAX_PMD
> >
> >  fs/Kconfig          |   1 -
> >  fs/dax.c            | 297 +++++++++++++++++++++++++++++-----------
> > ------------
> >  fs/ext2/inode.c     |   3 +
> >  fs/ext4/inode.c     |   7 +-
> >  include/linux/dax.h |  29 ++++-
> >  mm/filemap.c        |   6 +-
> >  6 files changed, 201 insertions(+), 142 deletions(-)
> >
> > -- 
> > 2.9.0
>
> Ping on this series?  Any objections or comments?

Hi Ross,

I am seeing a major performance loss in fio mmap test with this patch-
set applied.  This happens with or without my patches [1] applied on
top of yours.  Without my patches, dax_pmd_fault() falls back to the
pte handler since an mmap'ed address is not 2MB-aligned.

I have attached three test results.
 o rc4.log - 4.8.0-rc4 (base)
 o non-pmd.log - 4.8.0-rc4 + your patchset (fall back to pte)
 o pmd.log - 4.8.0-rc4 + your patchset + my patchset (use pmd maps)

My test steps are as follows.

mkfs.ext4 -O bigalloc -C 2M /dev/pmem0
mount -o dax /dev/pmem0 /mnt/pmem0
numactl --preferred block:pmem0 --cpunodebind block:pmem0 fio test.fio

"test.fio"
---
[global]
bs=4k
size=2G
directory=/mnt/pmem0
ioengine=mmap
[randrw]
rw=randrw
---

Can you please take a look?
Thanks,
-Toshi

[1] https://lkml.org/lkml/2016/8/29/560





Attachments:
non-pmd.log (2.25 kB)
non-pmd.log
pmd.log (2.25 kB)
pmd.log
rc4.log (2.28 kB)
rc4.log
Download all attachments

2016-08-31 21:36:07

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH v2 0/9] re-enable DAX PMD support

On Wed, Aug 31, 2016 at 08:20:48PM +0000, Kani, Toshimitsu wrote:
> On Tue, 2016-08-30 at 17:01 -0600, Ross Zwisler wrote:
> > On Tue, Aug 23, 2016 at 04:04:10PM -0600, Ross Zwisler wrote:
> > >
> > > DAX PMDs have been disabled since Jan Kara introduced DAX radix
> > > tree based locking.??This series allows DAX PMDs to participate in
> > > the DAX radix tree based locking scheme so that they can be re-
> > > enabled.
> > >
> > > Changes since v1:
> > > ?- PMD entry locking is now done based on the starting offset of
> > > the PMD entry, rather than on the radix tree slot which was
> > > unreliable. (Jan)
> > > ?- Fixed the one issue I could find with hole punch.??As far as I
> > > can tell hole punch now works correctly for both PMD and PTE DAX
> > > entries, 4k zero pages and huge zero pages.
> > > ?- Fixed the way that ext2 returns the size of holes in
> > > ext2_get_block(). (Jan)
> > > ?- Made the 'wait_table' global variable static in respnse to a
> > > sparse warning.
> > > ?- Fixed some more inconsitent usage between the names 'ret' and
> > > 'entry' for radix tree entry variables.
> > >
> > > Ross Zwisler (9):
> > > ? ext4: allow DAX writeback for hole punch
> > > ? ext2: tell DAX the size of allocation holes
> > > ? ext4: tell DAX the size of allocation holes
> > > ? dax: remove buffer_size_valid()
> > > ? dax: make 'wait_table' global variable static
> > > ? dax: consistent variable naming for DAX entries
> > > ? dax: coordinate locking for offsets in PMD range
> > > ? dax: re-enable DAX PMD support
> > > ? dax: remove "depends on BROKEN" from FS_DAX_PMD
> > >
> > > ?fs/Kconfig??????????|???1 -
> > > ?fs/dax.c????????????| 297 +++++++++++++++++++++++++++++-----------
> > > ------------
> > > ?fs/ext2/inode.c?????|???3 +
> > > ?fs/ext4/inode.c?????|???7 +-
> > > ?include/linux/dax.h |??29 ++++-
> > > ?mm/filemap.c????????|???6 +-
> > > ?6 files changed, 201 insertions(+), 142 deletions(-)
> > >
> > > --?
> > > 2.9.0
> >
> > Ping on this series???Any objections or comments?
>
> Hi Ross,
>
> I am seeing a major performance loss in fio mmap test with this patch-
> set applied. ?This happens with or without my patches [1] applied on
> top of yours. ?Without my patches,?dax_pmd_fault() falls back to the
> pte handler since an mmap'ed address is not 2MB-aligned.
>
> I have attached three test results.
> ?o rc4.log - 4.8.0-rc4 (base)
> ?o non-pmd.log - 4.8.0-rc4 + your patchset (fall back to pte)
> ?o pmd.log - 4.8.0-rc4 + your patchset + my patchset (use pmd maps)
>
> My test steps are as follows.
>
> mkfs.ext4 -O bigalloc -C 2M /dev/pmem0
> mount -o dax /dev/pmem0 /mnt/pmem0
> numactl --preferred block:pmem0 --cpunodebind block:pmem0 fio test.fio
>
> "test.fio"
> ---
> [global]
> bs=4k
> size=2G
> directory=/mnt/pmem0
> ioengine=mmap
> [randrw]
> rw=randrw
> ---
>
> Can you please take a look?

Yep, thanks for the report.

2016-08-31 22:08:59

by Toshi Kani

[permalink] [raw]
Subject: Re: [PATCH v2 0/9] re-enable DAX PMD support

On Wed, 2016-08-31 at 15:36 -0600, Ross Zwisler wrote:
> On Wed, Aug 31, 2016 at 08:20:48PM +0000, Kani, Toshimitsu wrote:
> >
> > On Tue, 2016-08-30 at 17:01 -0600, Ross Zwisler wrote:
> > >
> > > On Tue, Aug 23, 2016 at 04:04:10PM -0600, Ross Zwisler wrote:
 :
> > >
> > > Ping on this series?  Any objections or comments?
> >
> > Hi Ross,
> >
> > I am seeing a major performance loss in fio mmap test with this
> > patch-set applied.  This happens with or without my patches [1]
> > applied on top of yours.  Without my patches, dax_pmd_fault() falls
> > back to the pte handler since an mmap'ed address is not 2MB-
> > aligned.
> >
> > I have attached three test results.
> >  o rc4.log - 4.8.0-rc4 (base)
> >  o non-pmd.log - 4.8.0-rc4 + your patchset (fall back to pte)
> >  o pmd.log - 4.8.0-rc4 + your patchset + my patchset (use pmd maps)
> >
> > My test steps are as follows.
> >
> > mkfs.ext4 -O bigalloc -C 2M /dev/pmem0
> > mount -o dax /dev/pmem0 /mnt/pmem0
> > numactl --preferred block:pmem0 --cpunodebind block:pmem0 fio
> > test.fio
> >
> > "test.fio"
> > ---
> > [global]
> > bs=4k
> > size=2G
> > directory=/mnt/pmem0
> > ioengine=mmap
> > [randrw]
> > rw=randrw
> > ---
> >
> > Can you please take a look?
>
> Yep, thanks for the report.

I have some more observations.  It seems this issue is related with pmd
mappings after all.  fio creates "randrw.0.0" file.  In my setup, an
initial test run creates pmd mappings and hits this issue.  Subsequent
test runs (i.e. randrw.0.0 exists), without my patches, fall back to
pte mappings and do not hit this issue.  With my patches applied,
subsequent runs still create pmd mappings and hit this issue.

Thanks,
-Toshi  






_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

2016-09-01 16:21:39

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH v2 0/9] re-enable DAX PMD support

On Wed, Aug 31, 2016 at 10:08:59PM +0000, Kani, Toshimitsu wrote:
> On Wed, 2016-08-31 at 15:36 -0600, Ross Zwisler wrote:
> > On Wed, Aug 31, 2016 at 08:20:48PM +0000, Kani, Toshimitsu wrote:
> > >
> > > On Tue, 2016-08-30 at 17:01 -0600, Ross Zwisler wrote:
> > > >
> > > > On Tue, Aug 23, 2016 at 04:04:10PM -0600, Ross Zwisler wrote:
> ?:
> > > >
> > > > Ping on this series???Any objections or comments?
> > >
> > > Hi Ross,
> > >
> > > I am seeing a major performance loss in fio mmap test with this
> > > patch-set applied. ?This happens with or without my patches [1]
> > > applied on top of yours. ?Without my patches,?dax_pmd_fault() falls
> > > back to the pte handler since an mmap'ed address is not 2MB-
> > > aligned.
> > >
> > > I have attached three test results.
> > > ?o rc4.log - 4.8.0-rc4 (base)
> > > ?o non-pmd.log - 4.8.0-rc4 + your patchset (fall back to pte)
> > > ?o pmd.log - 4.8.0-rc4 + your patchset + my patchset (use pmd maps)
> > >
> > > My test steps are as follows.
> > >
> > > mkfs.ext4 -O bigalloc -C 2M /dev/pmem0
> > > mount -o dax /dev/pmem0 /mnt/pmem0
> > > numactl --preferred block:pmem0 --cpunodebind block:pmem0 fio
> > > test.fio
> > >
> > > "test.fio"
> > > ---
> > > [global]
> > > bs=4k
> > > size=2G
> > > directory=/mnt/pmem0
> > > ioengine=mmap
> > > [randrw]
> > > rw=randrw
> > > ---
> > >
> > > Can you please take a look?
> >
> > Yep, thanks for the report.
>
> I have some more observations. ?It seems this issue is related with pmd
> mappings after all. ?fio creates "randrw.0.0" file. ?In my setup, an
> initial test run creates pmd mappings and hits this issue. ?Subsequent
> test runs (i.e. randrw.0.0 exists), without my patches, fall back to
> pte mappings and do not hit this issue. ?With my patches applied,
> subsequent runs still create pmd mappings and hit this issue.

I've been able to reproduce this on my test setup, and I agree that it appears
to be related to the PMD mappings. Here's my performance with 4k mappings,
either before my set or without your patches:

READ: io=1022.7MB, aggrb=590299KB/s, minb=590299KB/s, maxb=590299KB/s, mint=1774msec, maxt=1774msec
WRITE: io=1025.4MB, aggrb=591860KB/s, minb=591860KB/s, maxb=591860KB/s, mint=1774msec, maxt=1774msec

And with 2 MiB pages:

READ: io=1022.7MB, aggrb=17931KB/s, minb=17931KB/s, maxb=17931KB/s, mint=58401msec, maxt=58401msec
WRITE: io=1025.4MB, aggrb=17978KB/s, minb=17978KB/s, maxb=17978KB/s, mint=58401msec, maxt=58401msec

Dan is seeing something similar with his device DAX code with 2MiB pages, so
our best guess right now is that it must be in the PMD MM code, since that's
really the only thing that the fs/dax and device/dax implementations share.

Interestingly, I'm getting the opposite results when testing in my VM. Here's
the performance with 4k pages:

READ: io=1022.7MB, aggrb=251728KB/s, minb=251728KB/s, maxb=251728KB/s, mint=4160msec, maxt=4160msec
WRITE: io=1025.4MB, aggrb=252394KB/s, minb=252394KB/s, maxb=252394KB/s, mint=4160msec, maxt=4160msec

And with 2MiB pages:

READ: io=1022.7MB, aggrb=902751KB/s, minb=902751KB/s, maxb=902751KB/s, mint=1160msec, maxt=1160msec
WRITE: io=1025.4MB, aggrb=905137KB/s, minb=905137KB/s, maxb=905137KB/s, mint=1160msec, maxt=1160msec

This is a totally different system, so the halved 4k performance in the VM
isn't comparable to my bare metal system, but it's interesting that the use of
PMDs over tripled the performance in my VM. Hmm...

We'll keep digging into this. Thanks again for the report. :)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

2016-09-09 16:48:08

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Mon, Aug 29, 2016 at 08:57:41AM -0400, Theodore Ts'o wrote:
> On Mon, Aug 29, 2016 at 12:41:16AM -0700, Christoph Hellwig wrote:
> >
> > We're going to move forward killing buffer_heads in XFS. I think ext4
> > would dramatically benefit from this a well, as would ext2 (although I
> > think all that DAX work in ext2 is a horrible idea to start with).
>
> It's been on my todo list. The only reason why I haven't done it yet
> is because I knew you were working on a solution, and I didn't want to
> do things one way for buffered I/O, and a different way for Direct
> I/O, and disentangling the DIO code and the different assumptions of
> how different file systems interact with the DIO code is a *mess*.
>
> It may have gotten better more recently, but a few years ago I took a
> look at it and backed slowly away.....

Ted, what do you think of the idea of moving to struct iomap in ext2?

If ext2 stays with the current struct buffer_head + get_block_t interface,
then it looks like DAX basically has three options:

1) Support two I/O paths and two versions of each of the fault paths (PTE,
PMD, etc). One of each of these would be based on struct iomap and would be
used by xfs and potentially ext4, and the other would be based on struct
buffer_head + get_block_t and would be used by ext2.

2) Only have a single struct iomap based I/O path and fault path, and add
shim/support code so that ext2 can use it, leaving the rest of ext2 to be
struct buffer_head + get_block_t based.

3) Only have a single struct buffer_head + get_block_t based DAX I/O and fault
path, and have XFS and potentially ext4 do the translation from their native
struct iomap interface.

It seems ideal for ext2 to switch along with everyone else, if getting rid of
struct buffer_head is a global goal. If not, I guess barring technical issues
#2 above seems cleanest - move DAX to the new structure, and provide backwards
compatibility to ext2. Thoughts?

2016-09-09 20:35:01

by Matthew Wilcox

[permalink] [raw]
Subject: RE: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

I feel like we're not only building on shifting sands, but we haven't decided whether we're building a Pyramid or a Sphinx.

I thought after Storage Summit, we had broad agreement that we were moving to a primary DAX API that was not BH (nor indeed iomap) based. We would still have DAX helpers for block based filesystems (because duplicating all that code between filesystems is pointless), but I now know of three filesystems which are not block based that are interested in using DAX. Jared Hulbert's AXFS is a nice public example.

I posted a prototype of this here:

https://groups.google.com/d/msg/linux.kernel/xFFHVCQM7Go/ZQeDVYTnFgAJ

It is, of course, woefully out of date, but some of the principles in it are still good (and I'm working to split it into digestible chunks).

The essence:

1. VFS or VM calls filesystem (eg ->fault())
2. Filesystem calls DAX (eg dax_fault())
3. DAX looks in radix tree, finds no information.
4. DAX calls (NEW!) mapping->a_ops->populate_pfns
5a. Filesystem (if not block based) does its own thing to find out the PFNs corresponding to the requested range, then inserts them into the radix tree (possible helper in DAX code)
5b. Filesystem (if block based) looks up its internal data structure (eg extent tree) and
? ?calls dax_create_pfns() (see giant patch from yesterday, only instead of
? ?passing a get_block_t, the filesystem has already filled in a bh which
? ?describes the entire extent that this access happens to land in).
6b. DAX takes care of calling bdev_direct_access() from?dax_create_pfns().

Now, notice that there's no interaction with the rest of the filesystem here. We can swap out BHs and iomaps relatively trivially; there's no call for making grand changes, like converting ext2 over to iomap. The BH or iomap is only used for communicating the extent from the filesystem to DAX.

Do we have agreement that this is the right way to go?

-----Original Message-----
From: Ross Zwisler [mailto:[email protected]]
Sent: Friday, September 9, 2016 12:48 PM
To: Theodore Ts'o <[email protected]>; Christoph Hellwig <[email protected]>; Ross Zwisler <[email protected]>; [email protected]; Andrew Morton <[email protected]>; [email protected]; Matthew Wilcox <[email protected]>; Dave Chinner <[email protected]>; [email protected]; Andreas Dilger <[email protected]>; Alexander Viro <[email protected]>; Jan Kara <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Mon, Aug 29, 2016 at 08:57:41AM -0400, Theodore Ts'o wrote:
> On Mon, Aug 29, 2016 at 12:41:16AM -0700, Christoph Hellwig wrote:
> >
> > We're going to move forward killing buffer_heads in XFS. I think ext4
> > would dramatically benefit from this a well, as would ext2 (although I
> > think all that DAX work in ext2 is a horrible idea to start with).
>
> It's been on my todo list. The only reason why I haven't done it yet
> is because I knew you were working on a solution, and I didn't want to
> do things one way for buffered I/O, and a different way for Direct
> I/O, and disentangling the DIO code and the different assumptions of
> how different file systems interact with the DIO code is a *mess*.
>
> It may have gotten better more recently, but a few years ago I took a
> look at it and backed slowly away.....

Ted, what do you think of the idea of moving to struct iomap in ext2?

If ext2 stays with the current struct buffer_head + get_block_t interface,
then it looks like DAX basically has three options:

1) Support two I/O paths and two versions of each of the fault paths (PTE,
PMD, etc). One of each of these would be based on struct iomap and would be
used by xfs and potentially ext4, and the other would be based on struct
buffer_head + get_block_t and would be used by ext2.

2) Only have a single struct iomap based I/O path and fault path, and add
shim/support code so that ext2 can use it, leaving the rest of ext2 to be
struct buffer_head + get_block_t based.

3) Only have a single struct buffer_head + get_block_t based DAX I/O and fault
path, and have XFS and potentially ext4 do the translation from their native
struct iomap interface.

It seems ideal for ext2 to switch along with everyone else, if getting rid of
struct buffer_head is a global goal. If not, I guess barring technical issues
#2 above seems cleanest - move DAX to the new structure, and provide backwards
compatibility to ext2. Thoughts?

2016-09-09 22:34:43

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

/me grumbles about top-posting...

On Fri, Sep 9, 2016 at 1:35 PM, Matthew Wilcox <[email protected]> wrote:
> I feel like we're not only building on shifting sands, but we haven't decided whether we're building a Pyramid or a Sphinx.
>
> I thought after Storage Summit, we had broad agreement that we were moving to a primary DAX API that was not BH (nor indeed iomap) based. We would still have DAX helpers for block based filesystems (because duplicating all that code between filesystems is pointless), but I now know of three filesystems which are not block based that are interested in using DAX. Jared Hulbert's AXFS is a nice public example.
>
> I posted a prototype of this here:
>
> https://groups.google.com/d/msg/linux.kernel/xFFHVCQM7Go/ZQeDVYTnFgAJ
>
> It is, of course, woefully out of date, but some of the principles in it are still good (and I'm working to split it into digestible chunks).
>
> The essence:
>
> 1. VFS or VM calls filesystem (eg ->fault())
> 2. Filesystem calls DAX (eg dax_fault())
> 3. DAX looks in radix tree, finds no information.
> 4. DAX calls (NEW!) mapping->a_ops->populate_pfns
> 5a. Filesystem (if not block based) does its own thing to find out the PFNs corresponding to the requested range, then inserts them into the radix tree (possible helper in DAX code)
> 5b. Filesystem (if block based) looks up its internal data structure (eg extent tree) and
> calls dax_create_pfns() (see giant patch from yesterday, only instead of
> passing a get_block_t, the filesystem has already filled in a bh which
> describes the entire extent that this access happens to land in).
> 6b. DAX takes care of calling bdev_direct_access() from dax_create_pfns().
>
> Now, notice that there's no interaction with the rest of the filesystem here. We can swap out BHs and iomaps relatively trivially; there's no call for making grand changes, like converting ext2 over to iomap. The BH or iomap is only used for communicating the extent from the filesystem to DAX.
>
> Do we have agreement that this is the right way to go?

My $0.02...

So the current dax implementation is still struggling to get right
(pmd faulting, dirty entry cleaning, etc) and this seems like a
rewrite that sets us up for future features without addressing the
current bugs and todo items. In comparison the iomap conversion work
seems incremental and conserving of current development momentum.

I agree with you that continuing to touch ext2 is not a good idea, but
I'm not yet convinced that now is the time to go do dax-2.0 when we
haven't finished shipping dax-1.0.

2016-09-10 07:30:12

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

The mail is basically unparsable (hint: you can use a sane mailer even
with exchange servers :)).

Either way we need to get rid of buffer_heads, and another aop that
is entirely caller specific is unaceptable. That being said your idea
doesn't sounds unreasonable, but will require a bit more work and has
no real short-term need.

So let's revisit the idea once you have patches to post and move forward
with the more urgent needs for now.

2016-09-10 07:31:51

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Fri, Sep 09, 2016 at 03:34:43PM -0700, Dan Williams wrote:
> I agree with you that continuing to touch ext2 is not a good idea, but
> I'm not yet convinced that now is the time to go do dax-2.0 when we
> haven't finished shipping dax-1.0.

I've mentioned this before, but I'd like to repeat it. With all the
work reqwuired in the file system I would prefer to drop DAX support
in ext2 (and if people really cry for it reinstate the trivial old xip
support).

2016-09-10 07:33:18

by Matthew Wilcox

[permalink] [raw]
Subject: RE: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

From: Christoph Hellwig [mailto:[email protected]]
> The mail is basically unparsable (hint: you can use a sane mailer even with
> exchange servers :)).

That rather depends on how the Exchange servers are configured ... this isn't the
appropriate place to discuss IT issues though.

> Either way we need to get rid of buffer_heads, and another aop that is entirely
> caller specific is unaceptable. That being said your idea doesn't sounds
> unreasonable, but will require a bit more work and has no real short-term
> need.

So your proposal is to remove buffer_heads from ext2?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href
ilto:"[email protected]"> [email protected] </a>

2016-09-10 07:42:28

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Sat, Sep 10, 2016 at 07:33:18AM +0000, Matthew Wilcox wrote:
> > caller specific is unaceptable. That being said your idea doesn't sounds
> > unreasonable, but will require a bit more work and has no real short-term
> > need.
>
> So your proposal is to remove buffer_heads from ext2?

No, the proposal is to remove buffer_heads from XFS first, then GFS2
and then maybe others like ext4. I'd like to remove buffer_heads from
the DAX path for ext2 and ext4 entitrely for sure (and direct I/O next).

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

2016-09-10 07:50:09

by Matthew Wilcox

[permalink] [raw]
Subject: RE: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

From: Christoph Hellwig [mailto:[email protected]]
> On Fri, Sep 09, 2016 at 03:34:43PM -0700, Dan Williams wrote:
> > I agree with you that continuing to touch ext2 is not a good idea, but
> > I'm not yet convinced that now is the time to go do dax-2.0 when we
> > haven't finished shipping dax-1.0.
>
> I've mentioned this before, but I'd like to repeat it. With all the work reqwuired
> in the file system I would prefer to drop DAX support in ext2 (and if people
> really cry for it reinstate the trivial old xip support).

That allegedly trivial old xip support was horrendously broken. And, er, it used an aop
which you seem implacably opposed to in your earlier email. And that was truly a
disgusting one from a layering point of view. Let me remind you:

-???????int?(*get_xip_mem)(struct?address_space?*,?pgoff_t,?int,
-???????????????????????????????????????????????void?**,?unsigned?long?*);

That void ** was an 'out' parameter to store a kernel address for the memory. The
unsigned long * was also an 'out' parameter to store the PFN for the memory. The
'int' was actually a Boolean for whether to create or not, but you'd actually have to
go look at the implementation to find that out; the documentation never said it. A
real dog's breakfast of an API.

2016-09-10 07:52:53

by Matthew Wilcox

[permalink] [raw]
Subject: RE: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

From: Christoph Hellwig [mailto:[email protected]]
> On Sat, Sep 10, 2016 at 07:33:18AM +0000, Matthew Wilcox wrote:
> > > caller specific is unaceptable. That being said your idea doesn't
> > > sounds unreasonable, but will require a bit more work and has no
> > > real short-term need.
> >
> > So your proposal is to remove buffer_heads from ext2?
>
> No, the proposal is to remove buffer_heads from XFS first, then GFS2 and then
> maybe others like ext4. I'd like to remove buffer_heads from the DAX path for
> ext2 and ext4 entitrely for sure (and direct I/O next).

That's ... what I propose. The only use of buffer_head in my proposal is to
communicate a single extent from the filesystem to the DAX core, and that
can equally well use an iomap. Ross seems to think that converting the current
DAX code over to using iomap requires converting all of ext2 away from
buffer_head; are you saying he's wrong?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href
ilto:"[email protected]"> [email protected] </a>

2016-09-10 08:15:06

by Matthew Wilcox

[permalink] [raw]
Subject: RE: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

From: Dan Williams [mailto:[email protected]]
> /me grumbles about top-posting...

Let's see if this does any better .. there's lots of new features, but I don't see a 'wrap lines at 80 columns' option. Unfortunately.

> On Fri, Sep 9, 2016 at 1:35 PM, Matthew Wilcox <[email protected]>
> wrote:
> > I thought after Storage Summit, we had broad agreement that we were
> > moving to a primary DAX API that was not BH (nor indeed iomap) based. We
> > would still have DAX helpers for block based filesystems (because duplicating
> > all that code between filesystems is pointless), but I now know of three
> > filesystems which are not block based that are interested in using DAX. Jared
> > Hulbert's AXFS is a nice public example.
> >
> > I posted a prototype of this here:
> >
> >
> https://groups.google.com/d/msg/linux.kernel/xFFHVCQM7Go/ZQeDVYTnFgAJ
> >
> > It is, of course, woefully out of date, but some of the principles in it are still
> good (and I'm working to split it into digestible chunks).
> >
> > The essence:
> >
> > 1. VFS or VM calls filesystem (eg ->fault()) 2. Filesystem calls DAX
> > (eg dax_fault()) 3. DAX looks in radix tree, finds no information.
> > 4. DAX calls (NEW!) mapping->a_ops->populate_pfns 5a. Filesystem (if
> > not block based) does its own thing to find out the PFNs corresponding
> > to the requested range, then inserts them into the radix tree (possible helper
> in DAX code) 5b. Filesystem (if block based) looks up its internal data structure
> (eg extent tree) and
> > calls dax_create_pfns() (see giant patch from yesterday, only instead of
> > passing a get_block_t, the filesystem has already filled in a bh which
> > describes the entire extent that this access happens to land in).
> > 6b. DAX takes care of calling bdev_direct_access() from dax_create_pfns().
> >
> > Now, notice that there's no interaction with the rest of the filesystem here.
> We can swap out BHs and iomaps relatively trivially; there's no call for making
> grand changes, like converting ext2 over to iomap. The BH or iomap is only
> used for communicating the extent from the filesystem to DAX.
> >
> > Do we have agreement that this is the right way to go?
>
> My $0.02...
>
> So the current dax implementation is still struggling to get right (pmd faulting,
> dirty entry cleaning, etc) and this seems like a rewrite that sets us up for future
> features without addressing the current bugs and todo items. In comparison
> the iomap conversion work seems incremental and conserving of current
> development momentum.

I believe your assessment is incorrect. If converting the current DAX code to
use iomap forces converting ext2, then it's time to get rid of all the half-measures
currently in place. You left off one todo item that this does get us a step closer to
fixing -- support for DMA to mmaped DAX files. I think it also puts us in a better
position to fix the 2MB support, locking, and dirtiness tracking. Oh, and it does
fix the multivolume support (because the sectors in the radix tree could be
interpreted as being from the wrong volume).

> I agree with you that continuing to touch ext2 is not a good idea, but I'm not
> yet convinced that now is the time to go do dax-2.0 when we haven't finished
> shipping dax-1.0.

dax-1.0 died long ago ... I think we're up to at least DAX version 4 by now.

2016-09-10 14:56:43

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Sat, Sep 10, 2016 at 1:15 AM, Matthew Wilcox <[email protected]> wrote:
> From: Dan Williams [mailto:[email protected]]
>> /me grumbles about top-posting...
>
> Let's see if this does any better .. there's lots of new features, but I don't see a 'wrap lines at 80 columns' option. Unfortunately.

Much appreciated.

[..]
>> So the current dax implementation is still struggling to get right (pmd faulting,
>> dirty entry cleaning, etc) and this seems like a rewrite that sets us up for future
>> features without addressing the current bugs and todo items. In comparison
>> the iomap conversion work seems incremental and conserving of current
>> development momentum.
>
> I believe your assessment is incorrect. If converting the current DAX code to
> use iomap forces converting ext2, then it's time to get rid of all the half-measures
> currently in place. You left off one todo item that this does get us a step closer to
> fixing -- support for DMA to mmaped DAX files.

I didn't leave that off, DMA is solved with devm_memremap_pages().
Now, DMA without the ~1.6% capacity tax for the memmap array is
interesting, but that's a new feature.

> I think it also puts us in a better
> position to fix the 2MB support, locking, and dirtiness tracking. Oh, and it does
> fix the multivolume support (because the sectors in the radix tree could be
> interpreted as being from the wrong volume).
>
>> I agree with you that continuing to touch ext2 is not a good idea, but I'm not
>> yet convinced that now is the time to go do dax-2.0 when we haven't finished
>> shipping dax-1.0.
>
> dax-1.0 died long ago ... I think we're up to at least DAX version 4 by now.

My point is that I want to address the current slate of problems
before solving new questions like "how do we support non-block based
filesystems?". We just happened to land DAX in the middle of the
in-progress buffer_head removal effort, so DAX should not stand in the
way of where filesystems were already going. I'm arguing to complete
all the false starts and half measures that are presently in DAX and
then look to incrementally evolve the interfaces to something new
without regressing any of it.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

2016-09-10 15:55:17

by Matthew Wilcox

[permalink] [raw]
Subject: RE: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

From: Christoph Hellwig [mailto:[email protected]]
> Either way we need to get rid of buffer_heads, and another aop that is entirely
> caller specific is unaceptable.

I finally figured out what you actually meant by this. You mean that instead of having an aop->populate_pfn, you want to define a populate_pfn_t callback and pass it in.

Something like this:

int ext2_populate_pfn(struct address_space *mapping, pgoff_t pgoff)
{
struct iomap iomap;
...
return dax_populate_pfn(mapping, pgoff, &iomap);
}

int ext2_dax_fault(vma, vmf)
{
...
ret = dax_fault(vma, vmf, ext2_populate_pfn);
...
}

I don't have a problem with that. I'll work up something along those lines next week.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href
ilto:"[email protected]"> [email protected] </a>

2016-09-10 17:49:10

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Sat, Sep 10, 2016 at 12:31:51AM -0700, Christoph Hellwig wrote:
> I've mentioned this before, but I'd like to repeat it. With all the
> work reqwuired in the file system I would prefer to drop DAX support
> in ext2 (and if people really cry for it reinstate the trivial old xip
> support).

Why is so much work required to support the new DAX interfaces in
ext2? Is that unique to ext2, or is adding DAX support just going to
be painful for all file systems? Hopefully it's not the latter,
right?

- Ted

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

2016-09-11 00:42:09

by Matthew Wilcox

[permalink] [raw]
Subject: RE: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

From: Theodore Ts'o [mailto:[email protected]]
> On Sat, Sep 10, 2016 at 12:31:51AM -0700, Christoph Hellwig wrote:
> > I've mentioned this before, but I'd like to repeat it. With all the
> > work reqwuired in the file system I would prefer to drop DAX support
> > in ext2 (and if people really cry for it reinstate the trivial old xip
> > support).
>
> Why is so much work required to support the new DAX interfaces in
> ext2? Is that unique to ext2, or is adding DAX support just going to
> be painful for all file systems? Hopefully it's not the latter,
> right?

It's always been my goal to make supporting DAX as easy as possible
for the filesystem. Hence the sharing of the DIO locking, and the (it
turned out) premature reliance on helper functions. It's more complex
than I wanted it to be right now, and I hope we get to simplify it again.

2016-09-11 12:47:41

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Sat, Sep 10, 2016 at 07:52:53AM +0000, Matthew Wilcox wrote:
> DAX code over to using iomap requires converting all of ext2 away from
> buffer_head; are you saying he's wrong?

Not sure if he's really saying that, but it's wrong for sure. Just
to prove that I came up with a working ext2 iomap DAX implementation
in a few hours today. I'll take a stab at ext4 and the block device
as well and will post the updated series early next week - I'll need
to take care of a few high priority todo list items first.

2016-09-11 22:57:40

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Sun, Sep 11, 2016 at 05:47:41AM -0700, Christoph Hellwig wrote:
> On Sat, Sep 10, 2016 at 07:52:53AM +0000, Matthew Wilcox wrote:
> > DAX code over to using iomap requires converting all of ext2 away from
> > buffer_head; are you saying he's wrong?
>
> Not sure if he's really saying that, but it's wrong for sure. Just
> to prove that I came up with a working ext2 iomap DAX implementation
> in a few hours today. I'll take a stab at ext4 and the block device
> as well and will post the updated series early next week - I'll need
> to take care of a few high priority todo list items first.

Yay! Sorry if I was unclear, I wasn't trying to say that we had to change all
of ext2 over to using struct iomap. If we can (and apparently we can) just
switch over the DAX interfaces, that's good enough to me. I understand that
this will mean that we may have overlapping DAX paths for a while (an iomap
version and a buffer_head version). I just wanted to figure out whether this
overlap would need to be permanent - sounds like not, which is ideal.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

2016-09-15 20:09:28

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] ext2: tell DAX the size of allocation holes

On Tue, Aug 23, 2016 at 04:04:12PM -0600, Ross Zwisler wrote:
> When DAX calls ext2_get_block() and the file offset points to a hole we
> currently don't set bh_result->b_size. When we re-enable PMD faults DAX
> will need bh_result->b_size to tell it the size of the hole so it can
> decide whether to fault in a 4 KiB zero page or a 2 MiB zero page.
>
> Signed-off-by: Ross Zwisler <[email protected]>
> ---
> fs/ext2/inode.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index d5c7d09..dd55d74 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -773,6 +773,9 @@ int ext2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_
> if (ret > 0) {
> bh_result->b_size = (ret << inode->i_blkbits);
> ret = 0;
> + } else if (ret == 0) {
> + /* hole case, need to fill in bh_result->b_size */
> + bh_result->b_size = 1 << inode->i_blkbits;
> }
> return ret;
>
> --
> 2.9.0
>

Jan, is it possible for ext2 to return 2 MiB of contiguous space to us via
ext2_get_block()?

I ask because we have all the infrastructure in place for ext2 to handle PMD
faults (ext2_dax_pmd_fault(), etc.), but I don't think in my testing I've ever
seen this actually happen.

ext2 can obviously return multiple blocks from ext2_get_block(), but can it
actually satisfy a whole PMD's worth (512 contiguous blocks)? If so, what
steps do I need to take to get this to work in my testing?

If it can't happen, we should probably rip out ext2_dax_pmd_fault() so that we
don't have to keep falling back to PTEs via the PMD path.

Thanks,
- Ross

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>