f50a7f3d92
Based on 1 normalized pattern(s): licensed under gplv2 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 99 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Steve Winslow <swinslow@gmail.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190528170027.163048684@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
44 lines
850 B
C
44 lines
850 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright 2016, Anton Blanchard, Michael Ellerman, IBM Corp.
|
|
*/
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <stdio.h>
|
|
#include <sys/syscall.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
#include <linux/futex.h>
|
|
|
|
#include "utils.h"
|
|
|
|
#define ITERATIONS 100000000
|
|
|
|
#define futex(A, B, C, D, E, F) syscall(__NR_futex, A, B, C, D, E, F)
|
|
|
|
int test_futex(void)
|
|
{
|
|
struct timespec ts_start, ts_end;
|
|
unsigned long i = ITERATIONS;
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts_start);
|
|
|
|
while (i--) {
|
|
unsigned int addr = 0;
|
|
futex(&addr, FUTEX_WAKE, 1, NULL, NULL, 0);
|
|
}
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts_end);
|
|
|
|
printf("time = %.6f\n", ts_end.tv_sec - ts_start.tv_sec + (ts_end.tv_nsec - ts_start.tv_nsec) / 1e9);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
test_harness_set_timeout(300);
|
|
return test_harness(test_futex, "futex_bench");
|
|
}
|