Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-next-5.11-rc1' of git://git.kernel.org/pub…
Browse files Browse the repository at this point in the history
…/scm/linux/kernel/git/shuah/linux-kselftest

Pull Kselftest updates from Shuah Khan:

 - Much needed gpio test Makefile cleanup to various problems with test
   dependencies and build errors from Michael Ellerman

 - Enabling vDSO test on non x86 platforms from Vincenzo Frascino

 - Fix intel_pstate to replace deprecated ftime() usages with
   clock_gettime() from Tommi Rantala

 - cgroup test build fix on older releases from Sachin Sant

 - A couple of spelling mistake fixes

* tag 'linux-kselftest-next-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests/cgroup: Fix build on older distros
  selftests/run_kselftest.sh: fix dry-run typo
  tool: selftests: fix spelling typo of 'writting'
  selftests/memfd: Fix implicit declaration warnings
  selftests: intel_pstate: ftime() is deprecated
  selftests/gpio: Add to CLEAN rule rather than overriding
  selftests/gpio: Fix build when source tree is read only
  selftests/gpio: Move include of lib.mk up
  selftests/gpio: Use TEST_GEN_PROGS_EXTENDED
  kselftest: Extend vdso correctness test to clock_gettime64
  kselftest: Move test_vdso to the vDSO test suite
  kselftest: Extend vDSO selftest to clock_getres
  kselftest: Extend vDSO selftest
  kselftest: Enable vDSO test on non x86 platforms
  • Loading branch information
Linus Torvalds committed Dec 16, 2020
2 parents b80affe + c2e46f6 commit 7194850
Show file tree
Hide file tree
Showing 14 changed files with 621 additions and 34 deletions.
1 change: 1 addition & 0 deletions tools/testing/selftests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ endif
TARGETS += tmpfs
TARGETS += tpm2
TARGETS += user
TARGETS += vDSO
TARGETS += vm
TARGETS += x86
TARGETS += zram
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/cgroup/cgroup_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,13 @@ pid_t clone_into_cgroup(int cgroup_fd)
#ifdef CLONE_ARGS_SIZE_VER2
pid_t pid;

struct clone_args args = {
struct __clone_args args = {
.flags = CLONE_INTO_CGROUP,
.exit_signal = SIGCHLD,
.cgroup = cgroup_fd,
};

pid = sys_clone3(&args, sizeof(struct clone_args));
pid = sys_clone3(&args, sizeof(struct __clone_args));
/*
* Verify that this is a genuine test failure:
* ENOSYS -> clone3() not available
Expand Down
25 changes: 12 additions & 13 deletions tools/testing/selftests/gpio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ LDLIBS += $(VAR_LDLIBS)

TEST_PROGS := gpio-mockup.sh
TEST_FILES := gpio-mockup-sysfs.sh
TEST_PROGS_EXTENDED := gpio-mockup-chardev
TEST_GEN_PROGS_EXTENDED := gpio-mockup-chardev

GPIODIR := $(realpath ../../../gpio)
GPIOOBJ := gpio-utils.o
KSFT_KHDR_INSTALL := 1
include ../lib.mk

all: $(TEST_PROGS_EXTENDED)
GPIODIR := $(realpath ../../../gpio)
GPIOOUT := $(OUTPUT)/tools-gpio/
GPIOOBJ := $(GPIOOUT)/gpio-utils.o

override define CLEAN
$(RM) $(TEST_PROGS_EXTENDED)
$(MAKE) -C $(GPIODIR) OUTPUT=$(GPIODIR)/ clean
endef
CLEAN += ; $(RM) -rf $(GPIOOUT)

KSFT_KHDR_INSTALL := 1
include ../lib.mk
$(TEST_GEN_PROGS_EXTENDED): $(GPIOOBJ)

$(TEST_PROGS_EXTENDED): $(GPIODIR)/$(GPIOOBJ)
$(GPIOOUT):
mkdir -p $@

$(GPIODIR)/$(GPIOOBJ):
$(MAKE) OUTPUT=$(GPIODIR)/ -C $(GPIODIR)
$(GPIOOBJ): $(GPIOOUT)
$(MAKE) OUTPUT=$(GPIOOUT) -C $(GPIODIR)
22 changes: 16 additions & 6 deletions tools/testing/selftests/intel_pstate/aperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
#include <sched.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include "../kselftest.h"

#define MSEC_PER_SEC 1000L
#define NSEC_PER_MSEC 1000000L

void usage(char *name) {
printf ("Usage: %s cpunum\n", name);
}
Expand All @@ -22,7 +26,7 @@ int main(int argc, char **argv) {
long long tsc, old_tsc, new_tsc;
long long aperf, old_aperf, new_aperf;
long long mperf, old_mperf, new_mperf;
struct timeb before, after;
struct timespec before, after;
long long int start, finish, total;
cpu_set_t cpuset;

Expand Down Expand Up @@ -55,7 +59,10 @@ int main(int argc, char **argv) {
return 1;
}

ftime(&before);
if (clock_gettime(CLOCK_MONOTONIC, &before) < 0) {
perror("clock_gettime");
return 1;
}
pread(fd, &old_tsc, sizeof(old_tsc), 0x10);
pread(fd, &old_aperf, sizeof(old_mperf), 0xe7);
pread(fd, &old_mperf, sizeof(old_aperf), 0xe8);
Expand All @@ -64,7 +71,10 @@ int main(int argc, char **argv) {
sqrt(i);
}

ftime(&after);
if (clock_gettime(CLOCK_MONOTONIC, &after) < 0) {
perror("clock_gettime");
return 1;
}
pread(fd, &new_tsc, sizeof(new_tsc), 0x10);
pread(fd, &new_aperf, sizeof(new_mperf), 0xe7);
pread(fd, &new_mperf, sizeof(new_aperf), 0xe8);
Expand All @@ -73,11 +83,11 @@ int main(int argc, char **argv) {
aperf = new_aperf-old_aperf;
mperf = new_mperf-old_mperf;

start = before.time*1000 + before.millitm;
finish = after.time*1000 + after.millitm;
start = before.tv_sec*MSEC_PER_SEC + before.tv_nsec/NSEC_PER_MSEC;
finish = after.tv_sec*MSEC_PER_SEC + after.tv_nsec/NSEC_PER_MSEC;
total = finish - start;

printf("runTime: %4.2f\n", 1.0*total/1000);
printf("runTime: %4.2f\n", 1.0*total/MSEC_PER_SEC);
printf("freq: %7.0f\n", tsc / (1.0*aperf / (1.0 * mperf)) / total);
return 0;
}
2 changes: 1 addition & 1 deletion tools/testing/selftests/memfd/fuse_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <inttypes.h>
#include <limits.h>
#include <linux/falloc.h>
#include <linux/fcntl.h>
#include <fcntl.h>
#include <linux/memfd.h>
#include <sched.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/memfd/memfd_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <inttypes.h>
#include <limits.h>
#include <linux/falloc.h>
#include <linux/fcntl.h>
#include <fcntl.h>
#include <linux/memfd.h>
#include <sched.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/run_kselftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ while true; do
-l | --list)
echo "$available"
exit 0 ;;
-n | --dry-run)
-d | --dry-run)
dryrun="echo"
shift ;;
-h | --help)
Expand Down
16 changes: 12 additions & 4 deletions tools/testing/selftests/vDSO/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@ uname_M := $(shell uname -m 2>/dev/null || echo not)
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)

TEST_GEN_PROGS := $(OUTPUT)/vdso_test_gettimeofday $(OUTPUT)/vdso_test_getcpu
ifeq ($(ARCH),x86)
TEST_GEN_PROGS += $(OUTPUT)/vdso_test_abi
TEST_GEN_PROGS += $(OUTPUT)/vdso_test_clock_getres
ifeq ($(ARCH),$(filter $(ARCH),x86 x86_64))
TEST_GEN_PROGS += $(OUTPUT)/vdso_standalone_test_x86
endif
TEST_GEN_PROGS += $(OUTPUT)/vdso_test_correctness

ifndef CROSS_COMPILE
CFLAGS := -std=gnu99
CFLAGS_vdso_standalone_test_x86 := -nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector
LDFLAGS_vdso_test_correctness := -ldl
ifeq ($(CONFIG_X86_32),y)
LDLIBS += -lgcc_s
endif

all: $(TEST_GEN_PROGS)
$(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c
$(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c
$(OUTPUT)/vdso_test_abi: parse_vdso.c vdso_test_abi.c
$(OUTPUT)/vdso_test_clock_getres: vdso_test_clock_getres.c
$(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c
$(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \
vdso_standalone_test_x86.c parse_vdso.c \
-o $@

endif
$(OUTPUT)/vdso_test_correctness: vdso_test_correctness.c
$(CC) $(CFLAGS) \
vdso_test_correctness.c \
-o $@ \
$(LDFLAGS_vdso_test_correctness)
92 changes: 92 additions & 0 deletions tools/testing/selftests/vDSO/vdso_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* vdso_config.h: Configuration options for vDSO tests.
* Copyright (c) 2019 Arm Ltd.
*/
#ifndef __VDSO_CONFIG_H__
#define __VDSO_CONFIG_H__

/*
* Each architecture exports its vDSO implementation with different names
* and a different version from the others, so we need to handle it as a
* special case.
*/
#if defined(__arm__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#elif defined(__aarch64__)
#define VDSO_VERSION 3
#define VDSO_NAMES 0
#elif defined(__powerpc__)
#define VDSO_VERSION 1
#define VDSO_NAMES 0
#define VDSO_32BIT 1
#elif defined(__powerpc64__)
#define VDSO_VERSION 1
#define VDSO_NAMES 0
#elif defined (__s390__)
#define VDSO_VERSION 2
#define VDSO_NAMES 0
#define VDSO_32BIT 1
#elif defined (__s390X__)
#define VDSO_VERSION 2
#define VDSO_NAMES 0
#elif defined(__mips__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#elif defined(__sparc__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#elif defined(__i386__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#elif defined(__x86_64__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#elif defined(__riscv__)
#define VDSO_VERSION 5
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#else /* nds32 */
#define VDSO_VERSION 4
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#endif

static const char *versions[6] = {
"LINUX_2.6",
"LINUX_2.6.15",
"LINUX_2.6.29",
"LINUX_2.6.39",
"LINUX_4",
"LINUX_4.15",
};

static const char *names[2][6] = {
{
"__kernel_gettimeofday",
"__kernel_clock_gettime",
"__kernel_time",
"__kernel_clock_getres",
"__kernel_getcpu",
#if defined(VDSO_32BIT)
"__kernel_clock_gettime64",
#endif
},
{
"__vdso_gettimeofday",
"__vdso_clock_gettime",
"__vdso_time",
"__vdso_clock_getres",
"__vdso_getcpu",
#if defined(VDSO_32BIT)
"__vdso_clock_gettime64",
#endif
},
};

#endif /* __VDSO_CONFIG_H__ */
Loading

0 comments on commit 7194850

Please sign in to comment.