From 021b32acd3cec8e255dd47681939797ec64b8206 Mon Sep 17 00:00:00 2001 From: John Ogness Date: Tue, 20 Feb 2018 15:03:14 +0100 Subject: tools: rename 'rtex' tool to 'pgflt' The rtex tool only demonstrates prefaultingn to avoid runtime page faults. It makes more sense to call it pgflt. Signed-off-by: John Ogness --- schulung_tools/rtex/rt.c | 72 ------------------------------------------------ 1 file changed, 72 deletions(-) delete mode 100644 schulung_tools/rtex/rt.c (limited to 'schulung_tools/rtex/rt.c') diff --git a/schulung_tools/rtex/rt.c b/schulung_tools/rtex/rt.c deleted file mode 100644 index 86a6506..0000000 --- a/schulung_tools/rtex/rt.c +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include - -extern void timestamp(const char *msg, int val); -extern void testfunc_malloc(void); -extern void testfunc_deepstack(void); - -void prefault_stack(void) -{ -#define STACK_SIZE (7680 * 1024) /* 7.5 MiB */ - char buf[STACK_SIZE]; - long pagesize; - int i; - - pagesize = sysconf(_SC_PAGESIZE); - - for (i = 0; i < STACK_SIZE; i += pagesize) - buf[i] = 0; -} - -void prefault_heap(void) -{ -#define HEAP_SIZE (20 * 1024 * 1024) /* 20 MiB */ - long pagesize; - char *buf; - int i; - - pagesize = sysconf(_SC_PAGESIZE); - - buf = malloc(HEAP_SIZE); - if (!buf) { - fprintf(stderr, "MALLOC FAILED: %s:%d\n", __FILE__, __LINE__); - return; - } - - for (i = 0; i < HEAP_SIZE; i += pagesize) - buf[i] = 0; - - free(buf); -} - -void setup_rt(unsigned int opts) -{ - if (opts & 0x1) { - if (mallopt(M_TRIM_THRESHOLD, -1) == 0) { - fprintf(stderr, "MALLOPT FAILED: %s:%d\n", - __FILE__, __LINE__); - } - - if (mallopt(M_MMAP_MAX, 0) == 0) { - fprintf(stderr, "MALLOPT FAILED: %s:%d\n", - __FILE__, __LINE__); - } - } - - if (opts & 0x2) { - if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) { - fprintf(stderr, "MLOCKALL FAILED: %s:%d\n", - __FILE__, __LINE__); - } - } - - if (opts & 0x4) - prefault_stack(); - - if (opts & 0x8) - prefault_heap(); -} - -- cgit v1.2.3