From e8a58986e83f6505a33ce5af0a57d752b405076e Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Tue, 17 Jun 2025 22:29:08 -0400 Subject: Support measuring the startup overhead of libsmctrl or nvtaskset Allows specifying an environment variable to only be applied to the child, e.g.: ./measure_startup_oh -e LD_PRELOAD=libsmctrl.so Or for starting the child process via a intermediate task, e.g.: ./measure_startup_oh ./nvtaskset 0xf ./measure_launch_oh 1 This allows for correctly measuring the startup overhead in the evaluation of the ECRTS'25 partitioning paper. --- measure_startup_oh.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/measure_startup_oh.c b/measure_startup_oh.c index 56f9ea7..7c7ba14 100644 --- a/measure_startup_oh.c +++ b/measure_startup_oh.c @@ -12,31 +12,32 @@ extern char **environ; #include "testbench.h" -#define measure_launch_oh "./measure_launch_oh" +static char* child_argv_default[3] = {"./measure_launch_oh", "1", NULL}; int main(int argc, char **argv) { - int *__unused, i; struct timespec start; if (argc == 2 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h"))) { - fprintf(stderr, "Usage: %s [environment var to apply to child (optional)]\n", argv[0]); + fprintf(stderr, "Usage: %s [-e environment var to apply to child (optional) | prog prog_arg...]\n", argv[0]); return 1; } - static char* child_argv[3]; - child_argv[0] = measure_launch_oh; - child_argv[1] = "1"; - child_argv[2] = NULL; - - // Use this to apply LD_PRELOAD to the child only - if (argv[1]) - putenv(argv[1]); + char **child_argv = child_argv_default; + if (argv[1]) { + // Change env + // (Use this to apply LD_PRELOAD to the child only) + if (!strcmp(argv[1], "-e")) + putenv(argv[2]); + // Special exec (e.g., ./nvtaskset --gpc-list 0 ./measure_launch_oh 1) + else + child_argv = &argv[1]; + } clock_gettime(CLOCK_MONOTONIC_RAW, &start); - fprintf(stderr, "(%d) Starting '"measure_launch_oh"' at CLOCK_MONOTONIC_RAW = %ld ns\n", - getpid(), time2ns(start)); - if (execve(measure_launch_oh, child_argv, environ)) { - perror("Unable to start '"measure_launch_oh"'"); + fprintf(stderr, "(%d) Starting '%s' at CLOCK_MONOTONIC_RAW = %ld ns\n", + getpid(), child_argv[0], time2ns(start)); + if (execve(child_argv[0], child_argv, environ)) { + perror("Unable to start subprogram"); return 1; } -- cgit v1.2.2