RPMEM_PERSIST(3)
β¨ NAME β¨
rpmem_persist(), rpmem_deep_persist(), rpmem_flush(), rpmem_drain(), rpmem_read() β bestie, these are the functions that copy and read remote pools π«
This whole page lives in the PMDK Programmer's Manual, section 3, and it's literally the remote-persist core of librpmem. iykyk. π«Ά
πΈ SYNOPSIS πΈ
#include <librpmem.h>
int rpmem_persist(RPMEMpool *rpp, size_t offset,
size_t length, unsigned lane, unsigned flags);
int rpmem_deep_persist(RPMEMpool *rpp, size_t offset,
size_t length, unsigned lane);
int rpmem_flush(RPMEMpool *rpp, size_t offset,
size_t length, unsigned lane, unsigned flags);
int rpmem_drain(RPMEMpool *rpp, unsigned lane, unsigned flags);
int rpmem_read(RPMEMpool *rpp, void *buff, size_t offset,
size_t length, unsigned lane);
π¦ DESCRIPTION π¦
okay so. buckle up, this is the good part. π
rpmem_persist()β copies data of givenlengthat givenoffsetfrom the associated local memory pool, and makes sure the data is persistent on the remote node before the function returns. slay. The remote node is identified by therpphandle, which must be returned from eitherrpmem_open(3)orrpmem_create(3). Theoffsetis relative to thepool_addrspecified in therpmem_open(3)orrpmem_create(3)call. π
Now here's the β¨ important β¨ part: if the remote pool was created using rpmem_create() with a non-NULL create_attr argument, offset has to be greater or equal to 4096. In that case the first 4096 bytes of the pool is used for storing the pool metadata and cannot be overwritten. π If the pool was created with a NULL create_attr argument, the pool metadata is not stored with the pool and offset can be any non-negative number. The offset and length combined must not exceed the pool_size passed to rpmem_open(3) or rpmem_create(3). no cap. π
The rpmem_persist() operation is performed using the given lane number. The lane must be less than the value returned by rpmem_open(3) or rpmem_create(3) through the nlanes argument (so it can take a value from 0 to nlanes - 1). The flags argument can be 0 or RPMEM_PERSIST_RELAXED, which means the persist operation will be done without any guarantees regarding atomicity of memory transfer. π«£
rpmem_deep_persist()β works in the same way as therpmem_persist(3)function, but additionally it flushes the data to the lowest possible persistency domain available from software. π³οΈβ¨ Please seepmem_deep_persist(3)for details.rpmem_flush()andrpmem_drain()β these two are literally two halves of the singlerpmem_persist(). π«Ά Therpmem_persist()copies data and makes it persistent in the one shot, whereasrpmem_flush()andrpmem_drain()split this operation into two stages.rpmem_flush()copies data of givenlengthat a givenoffsetfrom the associated local memory pool to the remote node. π€rpmem_drain()makes sure the data copied in all precedingrpmem_flush()calls is persistent on the remote node before the function returns. π₯
Data copied using rpmem_flush() can not be considered persistent on the remote node before return from following rpmem_drain(). π A single rpmem_drain() confirms persistence on the remote node of data copied by all rpmem_flush() functions called before it and using the same lane. And the bestie bonus: the last rpmem_flush() + rpmem_drain() can be replaced with rpmem_persist() at no cost. π€
The flags argument for rpmem_flush() can be 0 or RPMEM_FLUSH_RELAXED, which means the flush operation will be done without any guarantees regarding atomicity of memory transfer. The flags argument for rpmem_drain() must be 0. periodt.
The rpmem_flush() function performance is affected by the RPMEM_WORK_QUEUE_SIZE environment variable (see librpmem(7) for more details). βοΈ
rpmem_read()β readslengthbytes of data from a remote pool atoffsetand copies it to the bufferbuff. π The operation is performed on the specifiedlane. Thelanemust be less than the value returned byrpmem_open(3)orrpmem_create(3)through thenlanesargument (so it can take a value from0tonlanes - 1). Therppmust point to a remote pool opened or created previously byrpmem_open(3)orrpmem_create(3). π
π RETURN VALUE π
rpmem_persist()returns0if the entire memory area was made persistent on the remote node. Otherwise it returns a non-zero value and setserrnoappropriately. βrpmem_flush()returns0if duplication of the memory area to the remote node was initialized successfully. Otherwise, it returns a non-zero value and setserrnoappropriately.rpmem_drain()returns0if the memory areas duplicated by allrpmem_flush()calls preceding therpmem_drain()are made persistent on the remote node. Otherwise, it returns a non-zero value and setserrnoappropriately.rpmem_read()returns0if the data was read entirely. Otherwise it returns a non-zero value and setserrnoappropriately.
β οΈ CAVEATS β οΈ
Ordering of rpmem_flush() and rpmem_persist() operations which are using different lane values is not guaranteed. so don't come for me if the order vibes different than you expected π
π SEE ALSO π
rpmem_create(3), rpmem_open(3), rpmem_persist(3), sysconf(3), limits.conf(5), libpmemobj(7) and https://pmem.io π
and that's the whole page bestie!! π this was PMDK - rpmem API version 1.3, dated 2021-09-24 β go forth and persist, you absolute icon πβ¨
π¦ where this page comes from
- ubuntu jammy: librpmem-dev 1.11.1-3build1 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2017-2018, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms