From ea0c321784565c681507e02acf900deaa1e9e952 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Wed, 2 Dec 2015 20:44:10 +1100 Subject: [PATCH] selftests/powerpc: Make context_switch do something with no args For ease of use make the context_switch test do something useful when called with no arguments. Default to a 30 second run, using threads, doing yield, and use any online cpu. Make it print out what it's doing to avoid confusion. Signed-off-by: Michael Ellerman Acked-by: Anton Blanchard --- .../selftests/powerpc/benchmarks/Makefile | 1 + .../powerpc/benchmarks/context_switch.c | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile index 8cb7415c55aa..912445ff7ce7 100644 --- a/tools/testing/selftests/powerpc/benchmarks/Makefile +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile @@ -6,6 +6,7 @@ all: $(TEST_PROGS) $(TEST_PROGS): ../harness.c +context_switch: ../utils.c context_switch: LDLIBS += -lpthread include ../../lib.mk diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c b/tools/testing/selftests/powerpc/benchmarks/context_switch.c index ed21a83a0f99..d8b6d10f36a6 100644 --- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c +++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c @@ -26,7 +26,9 @@ #include #include -static unsigned int timeout = INT_MAX; +#include "../utils.h" + +static unsigned int timeout = 30; static int touch_vdso; struct timeval tv; @@ -363,9 +365,9 @@ static struct option options[] = { static void usage(void) { fprintf(stderr, "Usage: context_switch2 CPU1 CPU2\n\n"); - fprintf(stderr, "\t\t--test=X\tpipe, futex or yield\n"); + fprintf(stderr, "\t\t--test=X\tpipe, futex or yield (default)\n"); fprintf(stderr, "\t\t--process\tUse processes (default threads)\n"); - fprintf(stderr, "\t\t--timeout=X\tDuration in seconds to run\n"); + fprintf(stderr, "\t\t--timeout=X\tDuration in seconds to run (default 30)\n"); fprintf(stderr, "\t\t--vdso\t\ttouch VDSO\n"); fprintf(stderr, "\t\t--fp\t\ttouch FP\n"); #ifdef __powerpc__ @@ -377,7 +379,7 @@ static void usage(void) int main(int argc, char *argv[]) { signed char c; - struct actions *actions = &pipe_actions; + struct actions *actions = &yield_actions; int cpu1; int cpu2; static void (*start_fn)(void *(*fn)(void *), void *arg, unsigned long cpu); @@ -428,18 +430,30 @@ int main(int argc, char *argv[]) start_fn = start_thread_on; if (((argc - optind) != 2)) { - usage(); - exit(1); + cpu1 = cpu2 = pick_online_cpu(); + } else { + cpu1 = atoi(argv[optind++]); + cpu2 = atoi(argv[optind++]); } + printf("Using %s with ", processes ? "processes" : "threads"); + + if (actions == &pipe_actions) + printf("pipe"); + else if (actions == &yield_actions) + printf("yield"); + else + printf("futex"); + + printf(" on cpus %d/%d touching FP:%s altivec:%s vector:%s vdso:%s\n", + cpu1, cpu2, touch_fp ? "yes" : "no", touch_altivec ? "yes" : "no", + touch_vector ? "yes" : "no", touch_vdso ? "yes" : "no"); + /* Create a new process group so we can signal everyone for exit */ setpgid(getpid(), getpid()); signal(SIGUSR1, sigusr1_handler); - cpu1 = atoi(argv[optind++]); - cpu2 = atoi(argv[optind++]); - actions->setup(cpu1, cpu2); start_fn(actions->thread1, NULL, cpu1); -- GitLab