detecting a pmem device

55 views
Skip to first unread message

Sayeed hyder

unread,
Jan 18, 2018, 2:26:22 PM1/18/18
to pmem
Hello,

I was wondering whether there is any way to detect a device (e.g. /dev/any) file system DAX enabled or not. 


thanks,
sh

Jeff Moyer

unread,
Jan 18, 2018, 2:58:37 PM1/18/18
to Sayeed hyder, pmem
It sounds like you're asking if there's a way to determine if a
particular device is persistent memory. Because you mention "/dev/",
I'm also going to guess you only care about making this determination on
Linux.

As an administrator, you can get a list of persistent memory devices
using ndctl. As a (C) programmer, you can also get at this list via
libndctl.

In order to provide any further guidance, you'll have tell us exactly
what you're trying to achieve.

Cheers,
Jeff

Sayeed hyder

unread,
Jan 18, 2018, 3:31:08 PM1/18/18
to pmem
Thanks Jeff.

Yes, you are right. My assumption is that a device is mounted as filesystem DAX enabled

sudo mount -o dax /dev/pmem0 /mnt/mem

given the device path (/mnt/mem or /dev/pmem0), is it possible to detect whether it is DAX enabled or not (from C/C++ program)?

and yes, it is for Linux.

I am trying to detect the following from a C/C++ program 

Jeff Moyer

unread,
Jan 18, 2018, 3:37:49 PM1/18/18
to Sayeed hyder, pmem
Sayeed hyder <csay...@gmail.com> writes:

> Thanks Jeff.
>
> Yes, you are right. My assumption is that a device is mounted as filesystem
> DAX enabled
>
> sudo mount -o dax /dev/pmem0 /mnt/mem
>
>
> given the device path (/mnt/mem or /dev/pmem0), is it possible to detect
> whether it is DAX enabled or not (from C/C++ program)?
>
> and yes, it is for Linux.
>
> I am trying to detect the following from a C/C++ program

OK, that's slightly different from the question I thought you were
asking. I would use PMDK's "pmem_is_pmem()" library function to
determine whether a file on a given file system supports the persistent
memory programming model:
http://pmem.io/pmdk/manpages/linux/master/libpmem/pmem_is_pmem.3

Be sure to read the CAVEATS section of that page.

Cheers,
Jeff

Andy Rudoff

unread,
Jan 18, 2018, 3:38:07 PM1/18/18
to pmem
Yes, you can detect DAX as you say, but be careful what you decide based on that.  That's why Jeff was asking for more detail on what you're deciding.  Detecting DAX will tell you that the file system is capable of setting up mapped files that do not use the page cache.  But that alone doesn't tell you if it is safe to flush stores from user space (using instructions like CLWB instead of calling msync).  The more recent addition of the MAP_SYNC flag tells you that -- if the system allows you to do the mmap with MAP_SYNC, then the user space flushing is safe.

So if you're planning on deciding something else based on whether DAX is there, you should be careful not to read too much into the existence of the "dax" mount option.

-andy
Reply all
Reply to author
Forward
0 new messages