Dan Williams <
dan.j.w...@gmail.com> writes:
> It's simply broken for an application to make assumptions about
> latency due to a "dax" flag.
Or any other flag. The OS doesn't, and *can't* guarantee anything about
access latency. But, we're probably focusing too much on the minutiae.
If I've understood the problem correctly, Steve wants a way to determine
that:
a) the file is stored on pmem
b) the kernel is involved with as little of the data path as possible
a) can be satisfied by looking at the device info in stat, and
correlating that with the device node name (is it pmemX or daxY).
b) is trickier. If you're only interested in loads/reads, then the dax
mount option may well be the best source of this info today (though I
hope that changes in the future). If you *also* need to perform stores
safely, then MAP_SYNC would be required, but that may incur extra
latency at page fault time. Without more information on how data is
made persistent, it's of course very difficult to be prescriptive, here.
My recommendation is to call mmap with the MAP_SYNC|MAP_SHARED_VALIDATE
flags. That's the safest and easiest way to get the answers you are
looking for, Steve.
> Here are a couple scenarios that would break this assumption, I'm sure
> there are more:
>
> * EXT4 and XFS have different responses to the dax mount option when
> the underlying device fails the kernel's dax support checks. EXT4
> fails to mount, XFS falls back to page cache with a warning in the
> log. The mount option is unreliable for detecting DAX.
In the xfs case, the dax mount option will not show up in /proc/mounts
if the fallback is triggered. Still, don't rely on this.
> * The filesystem may need to do a significant amount of work to map a
> block into the file. There are no guarantees that the block allocation
> work and metadata operations complete with latency within the same
> order of magnitude of a mapped access. The dax attribute is a not a
> QOS guarantee.
And those pages can become unmapped, as well. Again, the OS doesn't and
can't guarantee access latencies, for *so* many reasons.
Cheers,
Jeff