From 79ba7c05e35b18aa2dc24da57399cfbb94a07d0e Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Wed, 4 Dec 2019 12:56:58 -0700 Subject: initial commit --- main.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..43aba7f --- /dev/null +++ b/main.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +#define GIG (1024*1024*1024ul) +#define VOLUME (2ul*GIG) + +// Real values is in the ~65536, only use half of it to be safe +// sysctl vm.max_map_count +#define MAXMMAPS 32768 + +int main(int argc, char **argv) { + auto page_size = sysconf(_SC_PAGESIZE); + std::cout << "The system have a page size of " << page_size << std::endl; + auto dst = (long*)malloc(VOLUME); + // Src is using anonymous mapping + long nmaps = std::stoi(argv[1]); + if (GIG % (page_size * nmaps) != 0) { + std::cout << "nmaps is not perfect multiple" << std::endl; + nmaps = GIG / (page_size * nmaps); + } + std::cout << argv[1] << std::endl; + uint8_t *hint = (uint8_t*)0x600000000000UL; + mmap(hint); + auto src = + return 0; +} -- cgit v1.2.3-70-g09d2