373 static char* map_memory(int fd, const char* file_name, size_t file_offset,
374 char *addr, size_t bytes, bool read_only = false,
375 bool allow_exec = false);
376 static char* remap_memory(int fd, const char* file_name, size_t file_offset,
377 char *addr, size_t bytes, bool read_only,
378 bool allow_exec);
379 static bool unmap_memory(char *addr, size_t bytes);
380 static void free_memory(char *addr, size_t bytes, size_t alignment_hint);
381 static void realign_memory(char *addr, size_t bytes, size_t alignment_hint);
382
383 // NUMA-specific interface
384 static bool numa_has_static_binding();
385 static bool numa_has_group_homing();
386 static void numa_make_local(char *addr, size_t bytes, int lgrp_hint);
387 static void numa_make_global(char *addr, size_t bytes);
388 static size_t numa_get_groups_num();
389 static size_t numa_get_leaf_groups(int *ids, size_t size);
390 static bool numa_topology_changed();
391 static int numa_get_group_id();
392
393 // Page manipulation
394 struct page_info {
395 size_t size;
396 int lgrp_id;
397 };
398 static bool get_page_info(char *start, page_info* info);
399 static char* scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found);
400
401 static char* non_memory_address_word();
402 // reserve, commit and pin the entire memory region
403 static char* reserve_memory_special(size_t size, size_t alignment,
404 char* addr, bool executable);
405 static bool release_memory_special(char* addr, size_t bytes);
406 static void large_page_init();
407 static size_t large_page_size();
408 static bool can_commit_large_page_memory();
409 static bool can_execute_large_page_memory();
410
411 // OS interface to polling page
412 static address get_polling_page() { return _polling_page; }
|
373 static char* map_memory(int fd, const char* file_name, size_t file_offset,
374 char *addr, size_t bytes, bool read_only = false,
375 bool allow_exec = false);
376 static char* remap_memory(int fd, const char* file_name, size_t file_offset,
377 char *addr, size_t bytes, bool read_only,
378 bool allow_exec);
379 static bool unmap_memory(char *addr, size_t bytes);
380 static void free_memory(char *addr, size_t bytes, size_t alignment_hint);
381 static void realign_memory(char *addr, size_t bytes, size_t alignment_hint);
382
383 // NUMA-specific interface
384 static bool numa_has_static_binding();
385 static bool numa_has_group_homing();
386 static void numa_make_local(char *addr, size_t bytes, int lgrp_hint);
387 static void numa_make_global(char *addr, size_t bytes);
388 static size_t numa_get_groups_num();
389 static size_t numa_get_leaf_groups(int *ids, size_t size);
390 static bool numa_topology_changed();
391 static int numa_get_group_id();
392
393 enum NumaIdState {
394 InvalidId = -1,
395 AnyId = -2
396 };
397
398 static int numa_get_address_id(uintptr_t address);
399
400 // Page manipulation
401 struct page_info {
402 size_t size;
403 int lgrp_id;
404 };
405 static bool get_page_info(char *start, page_info* info);
406 static char* scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found);
407
408 static char* non_memory_address_word();
409 // reserve, commit and pin the entire memory region
410 static char* reserve_memory_special(size_t size, size_t alignment,
411 char* addr, bool executable);
412 static bool release_memory_special(char* addr, size_t bytes);
413 static void large_page_init();
414 static size_t large_page_size();
415 static bool can_commit_large_page_memory();
416 static bool can_execute_large_page_memory();
417
418 // OS interface to polling page
419 static address get_polling_page() { return _polling_page; }
|