diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-17 16:31:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-17 16:31:50 -0500 |
commit | 12768c1e2c83b05ea1658470045789a14b6edf4c (patch) | |
tree | e2dd8f33ba4c3f9f525d092bdbd222422a9b97b1 | |
parent | a4eff16c54886c11972d6396ce8447b99e097343 (diff) | |
parent | 1b1fe542b6f010cf6bc7e1c92805e1c0e133e007 (diff) |
Merge tag 'linux-kselftest-4.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest updates from Shuah Khan:
"This 14 patch update:
- adds a new test for intel_pstate driver
- adds empty string and async test cases to firmware class tests
- fixes and cleans up several existing tests"
* tag 'linux-kselftest-4.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests: firmware: add empty string and async tests
firmware: actually return NULL on failed request_firmware_nowait()
test: firmware_class: add asynchronous request trigger
test: firmware_class: use kstrndup() where appropriate
test: firmware_class: report errors properly on failure
selftests/seccomp: fix 32-bit build warnings
add breakpoints/.gitignore
add ptrace/.gitignore
update .gitignore in selftests/timers
update .gitignore in selftests/vm
tools, testing, add test for intel_pstate driver
selftest/ipc: actually test it
selftests/capabilities: actually test it
selftests/capabilities: clean up for Makefile
-rw-r--r-- | drivers/base/firmware_class.c | 8 | ||||
-rw-r--r-- | lib/test_firmware.c | 79 | ||||
-rw-r--r-- | tools/testing/selftests/Makefile | 2 | ||||
-rw-r--r-- | tools/testing/selftests/breakpoints/.gitignore | 1 | ||||
-rw-r--r-- | tools/testing/selftests/capabilities/Makefile | 21 | ||||
-rwxr-xr-x | tools/testing/selftests/firmware/fw_filesystem.sh | 29 | ||||
-rw-r--r-- | tools/testing/selftests/intel_pstate/Makefile | 15 | ||||
-rw-r--r-- | tools/testing/selftests/intel_pstate/aperf.c | 80 | ||||
-rw-r--r-- | tools/testing/selftests/intel_pstate/msr.c | 39 | ||||
-rwxr-xr-x | tools/testing/selftests/intel_pstate/run.sh | 113 | ||||
-rw-r--r-- | tools/testing/selftests/ptrace/.gitignore | 1 | ||||
-rw-r--r-- | tools/testing/selftests/seccomp/test_harness.h | 5 | ||||
-rw-r--r-- | tools/testing/selftests/timers/.gitignore | 1 | ||||
-rw-r--r-- | tools/testing/selftests/vm/.gitignore | 5 |
14 files changed, 376 insertions, 23 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 8524450e75bd..b9250e564ebf 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -1118,15 +1118,17 @@ static int | |||
1118 | _request_firmware(const struct firmware **firmware_p, const char *name, | 1118 | _request_firmware(const struct firmware **firmware_p, const char *name, |
1119 | struct device *device, unsigned int opt_flags) | 1119 | struct device *device, unsigned int opt_flags) |
1120 | { | 1120 | { |
1121 | struct firmware *fw; | 1121 | struct firmware *fw = NULL; |
1122 | long timeout; | 1122 | long timeout; |
1123 | int ret; | 1123 | int ret; |
1124 | 1124 | ||
1125 | if (!firmware_p) | 1125 | if (!firmware_p) |
1126 | return -EINVAL; | 1126 | return -EINVAL; |
1127 | 1127 | ||
1128 | if (!name || name[0] == '\0') | 1128 | if (!name || name[0] == '\0') { |
1129 | return -EINVAL; | 1129 | ret = -EINVAL; |
1130 | goto out; | ||
1131 | } | ||
1130 | 1132 | ||
1131 | ret = _request_firmware_prepare(&fw, name, device); | 1133 | ret = _request_firmware_prepare(&fw, name, device); |
1132 | if (ret <= 0) /* error or already assigned */ | 1134 | if (ret <= 0) /* error or already assigned */ |
diff --git a/lib/test_firmware.c b/lib/test_firmware.c index 86374c1c49a4..a3e8ec3fb1c5 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/printk.h> | 14 | #include <linux/printk.h> |
15 | #include <linux/completion.h> | ||
15 | #include <linux/firmware.h> | 16 | #include <linux/firmware.h> |
16 | #include <linux/device.h> | 17 | #include <linux/device.h> |
17 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
@@ -54,10 +55,9 @@ static ssize_t trigger_request_store(struct device *dev, | |||
54 | int rc; | 55 | int rc; |
55 | char *name; | 56 | char *name; |
56 | 57 | ||
57 | name = kzalloc(count + 1, GFP_KERNEL); | 58 | name = kstrndup(buf, count, GFP_KERNEL); |
58 | if (!name) | 59 | if (!name) |
59 | return -ENOSPC; | 60 | return -ENOSPC; |
60 | memcpy(name, buf, count); | ||
61 | 61 | ||
62 | pr_info("loading '%s'\n", name); | 62 | pr_info("loading '%s'\n", name); |
63 | 63 | ||
@@ -65,17 +65,73 @@ static ssize_t trigger_request_store(struct device *dev, | |||
65 | release_firmware(test_firmware); | 65 | release_firmware(test_firmware); |
66 | test_firmware = NULL; | 66 | test_firmware = NULL; |
67 | rc = request_firmware(&test_firmware, name, dev); | 67 | rc = request_firmware(&test_firmware, name, dev); |
68 | if (rc) | 68 | if (rc) { |
69 | pr_info("load of '%s' failed: %d\n", name, rc); | 69 | pr_info("load of '%s' failed: %d\n", name, rc); |
70 | pr_info("loaded: %zu\n", test_firmware ? test_firmware->size : 0); | 70 | goto out; |
71 | } | ||
72 | pr_info("loaded: %zu\n", test_firmware->size); | ||
73 | rc = count; | ||
74 | |||
75 | out: | ||
71 | mutex_unlock(&test_fw_mutex); | 76 | mutex_unlock(&test_fw_mutex); |
72 | 77 | ||
73 | kfree(name); | 78 | kfree(name); |
74 | 79 | ||
75 | return count; | 80 | return rc; |
76 | } | 81 | } |
77 | static DEVICE_ATTR_WO(trigger_request); | 82 | static DEVICE_ATTR_WO(trigger_request); |
78 | 83 | ||
84 | static DECLARE_COMPLETION(async_fw_done); | ||
85 | |||
86 | static void trigger_async_request_cb(const struct firmware *fw, void *context) | ||
87 | { | ||
88 | test_firmware = fw; | ||
89 | complete(&async_fw_done); | ||
90 | } | ||
91 | |||
92 | static ssize_t trigger_async_request_store(struct device *dev, | ||
93 | struct device_attribute *attr, | ||
94 | const char *buf, size_t count) | ||
95 | { | ||
96 | int rc; | ||
97 | char *name; | ||
98 | |||
99 | name = kstrndup(buf, count, GFP_KERNEL); | ||
100 | if (!name) | ||
101 | return -ENOSPC; | ||
102 | |||
103 | pr_info("loading '%s'\n", name); | ||
104 | |||
105 | mutex_lock(&test_fw_mutex); | ||
106 | release_firmware(test_firmware); | ||
107 | test_firmware = NULL; | ||
108 | rc = request_firmware_nowait(THIS_MODULE, 1, name, dev, GFP_KERNEL, | ||
109 | NULL, trigger_async_request_cb); | ||
110 | if (rc) { | ||
111 | pr_info("async load of '%s' failed: %d\n", name, rc); | ||
112 | kfree(name); | ||
113 | goto out; | ||
114 | } | ||
115 | /* Free 'name' ASAP, to test for race conditions */ | ||
116 | kfree(name); | ||
117 | |||
118 | wait_for_completion(&async_fw_done); | ||
119 | |||
120 | if (test_firmware) { | ||
121 | pr_info("loaded: %zu\n", test_firmware->size); | ||
122 | rc = count; | ||
123 | } else { | ||
124 | pr_err("failed to async load firmware\n"); | ||
125 | rc = -ENODEV; | ||
126 | } | ||
127 | |||
128 | out: | ||
129 | mutex_unlock(&test_fw_mutex); | ||
130 | |||
131 | return rc; | ||
132 | } | ||
133 | static DEVICE_ATTR_WO(trigger_async_request); | ||
134 | |||
79 | static int __init test_firmware_init(void) | 135 | static int __init test_firmware_init(void) |
80 | { | 136 | { |
81 | int rc; | 137 | int rc; |
@@ -92,9 +148,20 @@ static int __init test_firmware_init(void) | |||
92 | goto dereg; | 148 | goto dereg; |
93 | } | 149 | } |
94 | 150 | ||
151 | rc = device_create_file(test_fw_misc_device.this_device, | ||
152 | &dev_attr_trigger_async_request); | ||
153 | if (rc) { | ||
154 | pr_err("could not create async sysfs interface: %d\n", rc); | ||
155 | goto remove_file; | ||
156 | } | ||
157 | |||
95 | pr_warn("interface ready\n"); | 158 | pr_warn("interface ready\n"); |
96 | 159 | ||
97 | return 0; | 160 | return 0; |
161 | |||
162 | remove_file: | ||
163 | device_remove_file(test_fw_misc_device.this_device, | ||
164 | &dev_attr_trigger_async_request); | ||
98 | dereg: | 165 | dereg: |
99 | misc_deregister(&test_fw_misc_device); | 166 | misc_deregister(&test_fw_misc_device); |
100 | return rc; | 167 | return rc; |
@@ -106,6 +173,8 @@ static void __exit test_firmware_exit(void) | |||
106 | { | 173 | { |
107 | release_firmware(test_firmware); | 174 | release_firmware(test_firmware); |
108 | device_remove_file(test_fw_misc_device.this_device, | 175 | device_remove_file(test_fw_misc_device.this_device, |
176 | &dev_attr_trigger_async_request); | ||
177 | device_remove_file(test_fw_misc_device.this_device, | ||
109 | &dev_attr_trigger_request); | 178 | &dev_attr_trigger_request); |
110 | misc_deregister(&test_fw_misc_device); | 179 | misc_deregister(&test_fw_misc_device); |
111 | pr_warn("removed interface\n"); | 180 | pr_warn("removed interface\n"); |
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index c8edff6803d1..b04afc3295df 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
@@ -1,10 +1,12 @@ | |||
1 | TARGETS = breakpoints | 1 | TARGETS = breakpoints |
2 | TARGETS += capabilities | ||
2 | TARGETS += cpu-hotplug | 3 | TARGETS += cpu-hotplug |
3 | TARGETS += efivarfs | 4 | TARGETS += efivarfs |
4 | TARGETS += exec | 5 | TARGETS += exec |
5 | TARGETS += firmware | 6 | TARGETS += firmware |
6 | TARGETS += ftrace | 7 | TARGETS += ftrace |
7 | TARGETS += futex | 8 | TARGETS += futex |
9 | TARGETS += ipc | ||
8 | TARGETS += kcmp | 10 | TARGETS += kcmp |
9 | TARGETS += lib | 11 | TARGETS += lib |
10 | TARGETS += membarrier | 12 | TARGETS += membarrier |
diff --git a/tools/testing/selftests/breakpoints/.gitignore b/tools/testing/selftests/breakpoints/.gitignore new file mode 100644 index 000000000000..9b3193d06608 --- /dev/null +++ b/tools/testing/selftests/breakpoints/.gitignore | |||
@@ -0,0 +1 @@ | |||
breakpoint_test | |||
diff --git a/tools/testing/selftests/capabilities/Makefile b/tools/testing/selftests/capabilities/Makefile index 8c8f0c1f0889..008602aed920 100644 --- a/tools/testing/selftests/capabilities/Makefile +++ b/tools/testing/selftests/capabilities/Makefile | |||
@@ -1,18 +1,15 @@ | |||
1 | all: | 1 | TEST_FILES := validate_cap |
2 | |||
3 | include ../lib.mk | ||
4 | |||
5 | .PHONY: all clean | ||
6 | |||
7 | TARGETS := validate_cap test_execve | ||
8 | TEST_PROGS := test_execve | 2 | TEST_PROGS := test_execve |
9 | 3 | ||
10 | CFLAGS := -O2 -g -std=gnu99 -Wall -lcap-ng | 4 | BINARIES := $(TEST_FILES) $(TEST_PROGS) |
11 | 5 | ||
12 | all: $(TARGETS) | 6 | CFLAGS += -O2 -g -std=gnu99 -Wall |
7 | LDLIBS += -lcap-ng -lrt -ldl | ||
8 | |||
9 | all: $(BINARIES) | ||
13 | 10 | ||
14 | clean: | 11 | clean: |
15 | $(RM) $(TARGETS) | 12 | $(RM) $(BINARIES) |
13 | |||
14 | include ../lib.mk | ||
16 | 15 | ||
17 | $(TARGETS): %: %.c | ||
18 | $(CC) -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl | ||
diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh index c4366dc74e01..5c495ad7958a 100755 --- a/tools/testing/selftests/firmware/fw_filesystem.sh +++ b/tools/testing/selftests/firmware/fw_filesystem.sh | |||
@@ -48,8 +48,21 @@ echo "ABCD0123" >"$FW" | |||
48 | 48 | ||
49 | NAME=$(basename "$FW") | 49 | NAME=$(basename "$FW") |
50 | 50 | ||
51 | if printf '\000' >"$DIR"/trigger_request; then | ||
52 | echo "$0: empty filename should not succeed" >&2 | ||
53 | exit 1 | ||
54 | fi | ||
55 | |||
56 | if printf '\000' >"$DIR"/trigger_async_request; then | ||
57 | echo "$0: empty filename should not succeed (async)" >&2 | ||
58 | exit 1 | ||
59 | fi | ||
60 | |||
51 | # Request a firmware that doesn't exist, it should fail. | 61 | # Request a firmware that doesn't exist, it should fail. |
52 | echo -n "nope-$NAME" >"$DIR"/trigger_request | 62 | if echo -n "nope-$NAME" >"$DIR"/trigger_request; then |
63 | echo "$0: firmware shouldn't have loaded" >&2 | ||
64 | exit 1 | ||
65 | fi | ||
53 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then | 66 | if diff -q "$FW" /dev/test_firmware >/dev/null ; then |
54 | echo "$0: firmware was not expected to match" >&2 | 67 | echo "$0: firmware was not expected to match" >&2 |
55 | exit 1 | 68 | exit 1 |
@@ -74,4 +87,18 @@ else | |||
74 | echo "$0: filesystem loading works" | 87 | echo "$0: filesystem loading works" |
75 | fi | 88 | fi |
76 | 89 | ||
90 | # Try the asynchronous version too | ||
91 | if ! echo -n "$NAME" >"$DIR"/trigger_async_request ; then | ||
92 | echo "$0: could not trigger async request" >&2 | ||
93 | exit 1 | ||
94 | fi | ||
95 | |||
96 | # Verify the contents are what we expect. | ||
97 | if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then | ||
98 | echo "$0: firmware was not loaded (async)" >&2 | ||
99 | exit 1 | ||
100 | else | ||
101 | echo "$0: async filesystem loading works" | ||
102 | fi | ||
103 | |||
77 | exit 0 | 104 | exit 0 |
diff --git a/tools/testing/selftests/intel_pstate/Makefile b/tools/testing/selftests/intel_pstate/Makefile new file mode 100644 index 000000000000..f5f1a28715ff --- /dev/null +++ b/tools/testing/selftests/intel_pstate/Makefile | |||
@@ -0,0 +1,15 @@ | |||
1 | CC := $(CROSS_COMPILE)gcc | ||
2 | CFLAGS := $(CFLAGS) -Wall -D_GNU_SOURCE | ||
3 | LDFLAGS := $(LDFLAGS) -lm | ||
4 | |||
5 | TARGETS := msr aperf | ||
6 | |||
7 | TEST_PROGS := $(TARGETS) run.sh | ||
8 | |||
9 | .PHONY: all clean | ||
10 | all: $(TARGETS) | ||
11 | |||
12 | $(TARGETS): $(HEADERS) | ||
13 | |||
14 | clean: | ||
15 | rm -f $(TARGETS) | ||
diff --git a/tools/testing/selftests/intel_pstate/aperf.c b/tools/testing/selftests/intel_pstate/aperf.c new file mode 100644 index 000000000000..6046e183f4ad --- /dev/null +++ b/tools/testing/selftests/intel_pstate/aperf.c | |||
@@ -0,0 +1,80 @@ | |||
1 | #include <math.h> | ||
2 | #include <unistd.h> | ||
3 | #include <stdio.h> | ||
4 | #include <stdlib.h> | ||
5 | #include <sys/types.h> | ||
6 | #include <sys/stat.h> | ||
7 | #include <fcntl.h> | ||
8 | #include <sys/timeb.h> | ||
9 | #include <sched.h> | ||
10 | #include <errno.h> | ||
11 | |||
12 | void usage(char *name) { | ||
13 | printf ("Usage: %s cpunum\n", name); | ||
14 | } | ||
15 | |||
16 | int main(int argc, char **argv) { | ||
17 | int i, cpu, fd; | ||
18 | char msr_file_name[64]; | ||
19 | long long tsc, old_tsc, new_tsc; | ||
20 | long long aperf, old_aperf, new_aperf; | ||
21 | long long mperf, old_mperf, new_mperf; | ||
22 | struct timeb before, after; | ||
23 | long long int start, finish, total; | ||
24 | cpu_set_t cpuset; | ||
25 | |||
26 | if (argc != 2) { | ||
27 | usage(argv[0]); | ||
28 | return 1; | ||
29 | } | ||
30 | |||
31 | errno = 0; | ||
32 | cpu = strtol(argv[1], (char **) NULL, 10); | ||
33 | |||
34 | if (errno) { | ||
35 | usage(argv[0]); | ||
36 | return 1; | ||
37 | } | ||
38 | |||
39 | sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu); | ||
40 | fd = open(msr_file_name, O_RDONLY); | ||
41 | |||
42 | if (fd == -1) { | ||
43 | perror("Failed to open"); | ||
44 | return 1; | ||
45 | } | ||
46 | |||
47 | CPU_ZERO(&cpuset); | ||
48 | CPU_SET(cpu, &cpuset); | ||
49 | |||
50 | if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) { | ||
51 | perror("Failed to set cpu affinity"); | ||
52 | return 1; | ||
53 | } | ||
54 | |||
55 | ftime(&before); | ||
56 | pread(fd, &old_tsc, sizeof(old_tsc), 0x10); | ||
57 | pread(fd, &old_aperf, sizeof(old_mperf), 0xe7); | ||
58 | pread(fd, &old_mperf, sizeof(old_aperf), 0xe8); | ||
59 | |||
60 | for (i=0; i<0x8fffffff; i++) { | ||
61 | sqrt(i); | ||
62 | } | ||
63 | |||
64 | ftime(&after); | ||
65 | pread(fd, &new_tsc, sizeof(new_tsc), 0x10); | ||
66 | pread(fd, &new_aperf, sizeof(new_mperf), 0xe7); | ||
67 | pread(fd, &new_mperf, sizeof(new_aperf), 0xe8); | ||
68 | |||
69 | tsc = new_tsc-old_tsc; | ||
70 | aperf = new_aperf-old_aperf; | ||
71 | mperf = new_mperf-old_mperf; | ||
72 | |||
73 | start = before.time*1000 + before.millitm; | ||
74 | finish = after.time*1000 + after.millitm; | ||
75 | total = finish - start; | ||
76 | |||
77 | printf("runTime: %4.2f\n", 1.0*total/1000); | ||
78 | printf("freq: %7.0f\n", tsc / (1.0*aperf / (1.0 * mperf)) / total); | ||
79 | return 0; | ||
80 | } | ||
diff --git a/tools/testing/selftests/intel_pstate/msr.c b/tools/testing/selftests/intel_pstate/msr.c new file mode 100644 index 000000000000..abbbfc84d359 --- /dev/null +++ b/tools/testing/selftests/intel_pstate/msr.c | |||
@@ -0,0 +1,39 @@ | |||
1 | #include <math.h> | ||
2 | #include <unistd.h> | ||
3 | #include <stdio.h> | ||
4 | #include <stdlib.h> | ||
5 | #include <sys/types.h> | ||
6 | #include <sys/stat.h> | ||
7 | #include <fcntl.h> | ||
8 | #include <sys/timeb.h> | ||
9 | #include <sched.h> | ||
10 | #include <errno.h> | ||
11 | |||
12 | |||
13 | int main(int argc, char **argv) { | ||
14 | int cpu, fd; | ||
15 | long long msr; | ||
16 | char msr_file_name[64]; | ||
17 | |||
18 | if (argc != 2) | ||
19 | return 1; | ||
20 | |||
21 | errno = 0; | ||
22 | cpu = strtol(argv[1], (char **) NULL, 10); | ||
23 | |||
24 | if (errno) | ||
25 | return 1; | ||
26 | |||
27 | sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu); | ||
28 | fd = open(msr_file_name, O_RDONLY); | ||
29 | |||
30 | if (fd == -1) { | ||
31 | perror("Failed to open"); | ||
32 | return 1; | ||
33 | } | ||
34 | |||
35 | pread(fd, &msr, sizeof(msr), 0x199); | ||
36 | |||
37 | printf("msr 0x199: 0x%llx\n", msr); | ||
38 | return 0; | ||
39 | } | ||
diff --git a/tools/testing/selftests/intel_pstate/run.sh b/tools/testing/selftests/intel_pstate/run.sh new file mode 100755 index 000000000000..bdaf37e92684 --- /dev/null +++ b/tools/testing/selftests/intel_pstate/run.sh | |||
@@ -0,0 +1,113 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # This test runs on Intel x86 based hardware which support the intel_pstate | ||
4 | # driver. The test checks the frequency settings from the maximum turbo | ||
5 | # state to the minimum supported frequency, in decrements of 100MHz. The | ||
6 | # test runs the aperf.c program to put load on each processor. | ||
7 | # | ||
8 | # The results are displayed in a table which indicate the "Target" state, | ||
9 | # or the requested frequency in MHz, the Actual frequency, as read from | ||
10 | # /proc/cpuinfo, the difference between the Target and Actual frequencies, | ||
11 | # and the value of MSR 0x199 (MSR_IA32_PERF_CTL) which indicates what | ||
12 | # pstate the cpu is in, and the value of | ||
13 | # /sys/devices/system/cpu/intel_pstate/max_perf_pct X maximum turbo state | ||
14 | # | ||
15 | # Notes: In some cases several frequency values may be placed in the | ||
16 | # /tmp/result.X files. This is done on purpose in order to catch cases | ||
17 | # where the pstate driver may not be working at all. There is the case | ||
18 | # where, for example, several "similar" frequencies are in the file: | ||
19 | # | ||
20 | # | ||
21 | #/tmp/result.3100:1:cpu MHz : 2899.980 | ||
22 | #/tmp/result.3100:2:cpu MHz : 2900.000 | ||
23 | #/tmp/result.3100:3:msr 0x199: 0x1e00 | ||
24 | #/tmp/result.3100:4:max_perf_pct 94 | ||
25 | # | ||
26 | # and the test will error out in those cases. The result.X file can be checked | ||
27 | # for consistency and modified to remove the extra MHz values. The result.X | ||
28 | # files can be re-evaluated by setting EVALUATE_ONLY to 1 below. | ||
29 | |||
30 | EVALUATE_ONLY=0 | ||
31 | |||
32 | max_cpus=$(($(nproc)-1)) | ||
33 | |||
34 | # compile programs | ||
35 | gcc -o aperf aperf.c -lm | ||
36 | [ $? -ne 0 ] && echo "Problem compiling aperf.c." && exit 1 | ||
37 | gcc -o msr msr.c -lm | ||
38 | [ $? -ne 0 ] && echo "Problem compiling msr.c." && exit 1 | ||
39 | |||
40 | function run_test () { | ||
41 | |||
42 | file_ext=$1 | ||
43 | for cpu in `seq 0 $max_cpus` | ||
44 | do | ||
45 | echo "launching aperf load on $cpu" | ||
46 | ./aperf $cpu & | ||
47 | done | ||
48 | |||
49 | echo "sleeping for 5 seconds" | ||
50 | sleep 5 | ||
51 | num_freqs=$(cat /proc/cpuinfo | grep MHz | sort -u | wc -l) | ||
52 | if [ $num_freqs -le 2 ]; then | ||
53 | cat /proc/cpuinfo | grep MHz | sort -u | tail -1 > /tmp/result.$1 | ||
54 | else | ||
55 | cat /proc/cpuinfo | grep MHz | sort -u > /tmp/result.$1 | ||
56 | fi | ||
57 | ./msr 0 >> /tmp/result.$1 | ||
58 | |||
59 | max_perf_pct=$(cat /sys/devices/system/cpu/intel_pstate/max_perf_pct) | ||
60 | echo "max_perf_pct $max_perf_pct" >> /tmp/result.$1 | ||
61 | |||
62 | for job in `jobs -p` | ||
63 | do | ||
64 | echo "waiting for job id $job" | ||
65 | wait $job | ||
66 | done | ||
67 | } | ||
68 | |||
69 | # | ||
70 | # MAIN (ALL UNITS IN MHZ) | ||
71 | # | ||
72 | |||
73 | # Get the marketing frequency | ||
74 | _mkt_freq=$(cat /proc/cpuinfo | grep -m 1 "model name" | awk '{print $NF}') | ||
75 | _mkt_freq=$(echo $_mkt_freq | tr -d [:alpha:][:punct:]) | ||
76 | mkt_freq=${_mkt_freq}0 | ||
77 | |||
78 | # Get the ranges from cpupower | ||
79 | _min_freq=$(cpupower frequency-info -l | tail -1 | awk ' { print $1 } ') | ||
80 | min_freq=$(($_min_freq / 1000)) | ||
81 | _max_freq=$(cpupower frequency-info -l | tail -1 | awk ' { print $2 } ') | ||
82 | max_freq=$(($_max_freq / 1000)) | ||
83 | |||
84 | |||
85 | for freq in `seq $max_freq -100 $min_freq` | ||
86 | do | ||
87 | echo "Setting maximum frequency to $freq" | ||
88 | cpupower frequency-set -g powersave --max=${freq}MHz >& /dev/null | ||
89 | [ $EVALUATE_ONLY -eq 0 ] && run_test $freq | ||
90 | done | ||
91 | |||
92 | echo "==============================================================================" | ||
93 | |||
94 | echo "The marketing frequency of the cpu is $mkt_freq MHz" | ||
95 | echo "The maximum frequency of the cpu is $max_freq MHz" | ||
96 | echo "The minimum frequency of the cpu is $min_freq MHz" | ||
97 | |||
98 | cpupower frequency-set -g powersave --max=${max_freq}MHz >& /dev/null | ||
99 | |||
100 | # make a pretty table | ||
101 | echo "Target Actual Difference MSR(0x199) max_perf_pct" | ||
102 | for freq in `seq $max_freq -100 $min_freq` | ||
103 | do | ||
104 | result_freq=$(cat /tmp/result.${freq} | grep "cpu MHz" | awk ' { print $4 } ' | awk -F "." ' { print $1 } ') | ||
105 | msr=$(cat /tmp/result.${freq} | grep "msr" | awk ' { print $3 } ') | ||
106 | max_perf_pct=$(cat /tmp/result.${freq} | grep "max_perf_pct" | awk ' { print $2 } ' ) | ||
107 | if [ $result_freq -eq $freq ]; then | ||
108 | echo " $freq $result_freq 0 $msr $(($max_perf_pct*3300))" | ||
109 | else | ||
110 | echo " $freq $result_freq $(($result_freq-$freq)) $msr $(($max_perf_pct*$max_freq))" | ||
111 | fi | ||
112 | done | ||
113 | exit 0 | ||
diff --git a/tools/testing/selftests/ptrace/.gitignore b/tools/testing/selftests/ptrace/.gitignore new file mode 100644 index 000000000000..b3e59d41fd82 --- /dev/null +++ b/tools/testing/selftests/ptrace/.gitignore | |||
@@ -0,0 +1 @@ | |||
peeksiginfo | |||
diff --git a/tools/testing/selftests/seccomp/test_harness.h b/tools/testing/selftests/seccomp/test_harness.h index fb2841601f2f..a786c69c7584 100644 --- a/tools/testing/selftests/seccomp/test_harness.h +++ b/tools/testing/selftests/seccomp/test_harness.h | |||
@@ -42,6 +42,7 @@ | |||
42 | #define TEST_HARNESS_H_ | 42 | #define TEST_HARNESS_H_ |
43 | 43 | ||
44 | #define _GNU_SOURCE | 44 | #define _GNU_SOURCE |
45 | #include <stdint.h> | ||
45 | #include <stdio.h> | 46 | #include <stdio.h> |
46 | #include <stdlib.h> | 47 | #include <stdlib.h> |
47 | #include <string.h> | 48 | #include <string.h> |
@@ -370,8 +371,8 @@ | |||
370 | __typeof__(_expected) __exp = (_expected); \ | 371 | __typeof__(_expected) __exp = (_expected); \ |
371 | __typeof__(_seen) __seen = (_seen); \ | 372 | __typeof__(_seen) __seen = (_seen); \ |
372 | if (!(__exp _t __seen)) { \ | 373 | if (!(__exp _t __seen)) { \ |
373 | unsigned long long __exp_print = (unsigned long long)__exp; \ | 374 | unsigned long long __exp_print = (uintptr_t)__exp; \ |
374 | unsigned long long __seen_print = (unsigned long long)__seen; \ | 375 | unsigned long long __seen_print = (uintptr_t)__seen; \ |
375 | __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ | 376 | __TH_LOG("Expected %s (%llu) %s %s (%llu)", \ |
376 | #_expected, __exp_print, #_t, \ | 377 | #_expected, __exp_print, #_t, \ |
377 | #_seen, __seen_print); \ | 378 | #_seen, __seen_print); \ |
diff --git a/tools/testing/selftests/timers/.gitignore b/tools/testing/selftests/timers/.gitignore index ced998151bc4..68f3fc71ac44 100644 --- a/tools/testing/selftests/timers/.gitignore +++ b/tools/testing/selftests/timers/.gitignore | |||
@@ -16,3 +16,4 @@ set-timer-lat | |||
16 | skew_consistency | 16 | skew_consistency |
17 | threadtest | 17 | threadtest |
18 | valid-adjtimex | 18 | valid-adjtimex |
19 | adjtick | ||
diff --git a/tools/testing/selftests/vm/.gitignore b/tools/testing/selftests/vm/.gitignore index ff1bb16cec4f..a937a9d26b60 100644 --- a/tools/testing/selftests/vm/.gitignore +++ b/tools/testing/selftests/vm/.gitignore | |||
@@ -2,3 +2,8 @@ hugepage-mmap | |||
2 | hugepage-shm | 2 | hugepage-shm |
3 | map_hugetlb | 3 | map_hugetlb |
4 | thuge-gen | 4 | thuge-gen |
5 | compaction_test | ||
6 | mlock2-tests | ||
7 | on-fault-limit | ||
8 | transhuge-stress | ||
9 | userfaultfd | ||