---
name: "memkind_pmem"
section: "3"
platform: "linux"
package: "libmemkind-dev"
version: "1.14.0-2"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/memkind_pmem"
---

# memkind\_pmem(3)

file-backed memory memkind operations. Note: This is EXPERIMENTAL API. The functionality and the header file itself can be changed (including non-backward compatible changes) or removed.

## NAME

memkind\_pmem - file-backed memory memkind operations.\
 **Note:** This is EXPERIMENTAL API. The functionality and the header file itself can be changed (including non-backward compatible changes) or removed.

## SYNOPSIS

**int memkind\_pmem\_create(struct memkind** *\*kind***, struct memkind\_ops** *\*ops***, const char** *\*name***);**\
 **int memkind\_pmem\_destroy(struct memkind** *\*kind***);**\
 **void \*memkind\_pmem\_mmap(struct memkind** *\*kind***, void** *\*addr***, size\_t** *size***);**\
 **int memkind\_pmem\_get\_mmap\_flags(struct memkind** *\*kind***, int** *\*flags***);**\
 **int memkind\_pmem\_validate\_dir(const char** *\*dir***);**\

## DESCRIPTION

The pmem memory memkind operations enable memory kinds built on memory-mapped files.  These support traditional **volatile** memory allocation in a fashion similar to **libvmem**(3) library.  It uses the [**mmap**(2)](/mmap/2.md) system call to create a pool of volatile memory.  Such memory may have different attributes, depending on the file system containing the memory-mapped files. (See also *http://pmem.io/pmdk/libvmem*).

The pmem kinds are most useful when used with DAX (direct mapping of persistent memory), which is memory-addressable persistent storage that supports load/store access without being paged via the system page cache. A Persistent Memory-aware file system is typically used to provide this type of access.

The most convenient way to create pmem kinds is to use **memkind\_create\_pmem**() or **memkind\_create\_pmem\_with\_config**() (see [**memkind**(3)](/memkind/3.md)).

**memkind\_pmem\_create**() is an implementation of the memkind "create" operation for file-backed memory kinds.  This allocates a space for some pmem-specific metadata, then calls **memkind\_arena\_create**() (see [**memkind\_arena**(3)](/memkind_arena/3.md))

**memkind\_pmem\_destroy**() is an implementation of the memkind "destroy" operation for file-backed memory kinds.  This releases all of the resources allocated by **memkind\_pmem\_create**() and allows the file system space to be reclaimed.

**memkind\_pmem\_mmap**() allocates the file system space for a block of *size* bytes in the memory-mapped file associated with given kind. The *addr* hint is ignored.  The return value is the address of mapped memory region or **MAP\_FAILED** in the case of an error.

**memkind\_pmem\_get\_mmap\_flags**() sets *flags* to **MAP\_SHARED**. See [**mmap**(2)](/mmap/2.md) for more information about these flags.

**memkind\_pmem\_validate\_dir**() returns zero if file created in specified *pmem\_dir* supports DAX (direct mapping of persistent memory) or an error code from the **ERRORS** if not.

- **MEMKIND\_PMEM\_CHUNK\_SIZE**

  The size of the PMEM chunk size.

## COPYRIGHT

Copyright (C) 2015 - 2020 Intel Corporation. All rights reserved.

## SEE ALSO

[**memkind**(3)](/memkind/3.md), [**memkind\_arena**(3)](/memkind_arena/3.md), [**memkind\_default**(3)](/memkind_default/3.md), [**memkind\_hbw**(3)](/memkind_hbw/3.md), [**memkind\_hugetlb**(3)](/memkind_hugetlb/3.md), **libvmem**(3), [**jemalloc**(3)](/jemalloc/3.md), [**mbind**(2)](/mbind/2.md), [**mmap**(2)](/mmap/2.md)
