Skip to content

Commit

Permalink
Prevent process pages from being swapped (#32)
Browse files Browse the repository at this point in the history
Signed-off-by: Atrate <[email protected]>

Signed-off-by: Atrate <[email protected]>
  • Loading branch information
Atrate authored Dec 14, 2022
1 parent 4b96c88 commit 829b1f2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/vramfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cstdint>
#include <limits>
#include <regex>
#include <sys/mman.h>

// Internal dependencies
#include "vramfs.hpp"
Expand Down Expand Up @@ -529,6 +530,11 @@ int main(int argc, char* argv[]) {
memory::set_device(atoi(argv[4]));
}

// Lock process pages in memory to prevent them from being swapped
if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
std::cerr << "failed to lock process pages in memory, vramfs may freeze if swapped" << std::endl;
}

// Check for OpenCL supported GPU and allocate memory
if (!memory::is_available()) {
std::cerr << "no opencl capable gpu found" << std::endl;
Expand Down

0 comments on commit 829b1f2

Please sign in to comment.