0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 06:28:55 +02:00

ircd::allocator: Add mlock2(2) interface wrapping.

This commit is contained in:
Jason Volk 2022-02-21 11:04:05 -08:00
parent e9fe4f33bb
commit 8bb8c19cda
2 changed files with 20 additions and 0 deletions

View file

@ -53,6 +53,7 @@ namespace ircd::allocator
size_t flush(const const_buffer &, const bool invd = false);
size_t sync(const const_buffer &, const bool invd = false);
void lock(const const_buffer &, const bool = true);
void protect(const const_buffer &, const bool = true);
void readonly(const mutable_buffer &, const bool = true);

View file

@ -177,6 +177,25 @@ ircd::allocator::protect(const const_buffer &buf,
}
#endif
void
ircd::allocator::lock(const const_buffer &buf,
const bool enable)
#if defined(HAVE_MLOCK2) && defined(MLOCK_ONFAULT)
{
int flags {0};
flags |= MLOCK_ONFAULT;
if(enable)
syscall(::mlock2, data(buf), size(buf), flags);
else
syscall(::munlock, data(buf), size(buf));
}
#else
{
#warning "mlock2(2) not available for this compilation."
}
#endif
size_t
ircd::allocator::sync(const const_buffer &buf,
const bool invd)