linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH selftests 0/6] Fix some broken tests
@ 2015-10-31 23:35 Ben Hutchings
       [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Ben Hutchings @ 2015-10-31 23:35 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-api-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1845 bytes --]

This series fixes some self-tests that are broken, unreliable or
produce compiler warnings in 4.3.

Ben.

Ben Hutchings (6):
  selftests: Add missing #include directives
  selftests: memfd: Stop unnecessary rebuilds
  selftests: kprobe: Choose an always-defined function to probe
  selftests: Make scripts executable
  selftests: vm: Try harder to allocate huge pages
  selftests: breakpoint: Actually build it

 tools/testing/selftests/breakpoints/Makefile              |  2 +-
 .../selftests/ftrace/test.d/kprobe/add_and_remove.tc      |  2 +-
 .../testing/selftests/ftrace/test.d/kprobe/busy_check.tc  |  2 +-
 .../testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc |  2 +-
 .../selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc       | 14 +++++++-------
 .../selftests/ftrace/test.d/kprobe/kretprobe_args.tc      |  2 +-
 tools/testing/selftests/memfd/Makefile                    | 12 ++++++------
 tools/testing/selftests/memfd/memfd_test.c                |  1 +
 tools/testing/selftests/memfd/run_fuse_test.sh            |  0
 tools/testing/selftests/mqueue/mq_open_tests.c            |  1 +
 tools/testing/selftests/mqueue/mq_perf_tests.c            |  1 +
 tools/testing/selftests/static_keys/test_static_keys.sh   |  0
 tools/testing/selftests/timers/nanosleep.c                |  1 +
 tools/testing/selftests/vm/run_vmtests                    | 15 ++++++++++++++-
 14 files changed, 36 insertions(+), 19 deletions(-)
 mode change 100644 => 100755 tools/testing/selftests/memfd/run_fuse_test.sh
 mode change 100644 => 100755 tools/testing/selftests/static_keys/test_static_keys.sh

-- 
Ben Hutchings
All extremists should be taken out and shot.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH selftests 1/6] selftests: Add missing #include directives
       [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
@ 2015-10-31 23:36   ` Ben Hutchings
  2015-10-31 23:37   ` [PATCH selftests 2/6] selftests: memfd: Stop unnecessary rebuilds Ben Hutchings
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Ben Hutchings @ 2015-10-31 23:36 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-api-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 2332 bytes --]

Several C programs fail to include the headers declaring all the
functions they call, resulting in warnings or errors.

After this, memfd_test.c is still missing some function declarations
but can't easily get them because of a conflict between
<linux/fcntl.h> and <sys/fcntl.h>.

Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
---
 tools/testing/selftests/memfd/memfd_test.c     | 1 +
 tools/testing/selftests/mqueue/mq_open_tests.c | 1 +
 tools/testing/selftests/mqueue/mq_perf_tests.c | 1 +
 tools/testing/selftests/timers/nanosleep.c     | 1 +
 4 files changed, 4 insertions(+)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index 0b9eafb..5347ef6 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -15,6 +15,7 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/syscall.h>
+#include <sys/wait.h>
 #include <unistd.h>
 
 #define MFD_DEF_SIZE 8192
diff --git a/tools/testing/selftests/mqueue/mq_open_tests.c b/tools/testing/selftests/mqueue/mq_open_tests.c
index 9c1a5d35..e0a74bd 100644
--- a/tools/testing/selftests/mqueue/mq_open_tests.c
+++ b/tools/testing/selftests/mqueue/mq_open_tests.c
@@ -31,6 +31,7 @@
 #include <sys/resource.h>
 #include <sys/stat.h>
 #include <mqueue.h>
+#include <error.h>
 
 static char *usage =
 "Usage:\n"
diff --git a/tools/testing/selftests/mqueue/mq_perf_tests.c b/tools/testing/selftests/mqueue/mq_perf_tests.c
index 8519e9e..8188f72 100644
--- a/tools/testing/selftests/mqueue/mq_perf_tests.c
+++ b/tools/testing/selftests/mqueue/mq_perf_tests.c
@@ -37,6 +37,7 @@
 #include <sys/stat.h>
 #include <mqueue.h>
 #include <popt.h>
+#include <error.h>
 
 static char *usage =
 "Usage:\n"
diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/selftests/timers/nanosleep.c
index 8a3c29d..ff942ff 100644
--- a/tools/testing/selftests/timers/nanosleep.c
+++ b/tools/testing/selftests/timers/nanosleep.c
@@ -19,6 +19,7 @@
  *   GNU General Public License for more details.
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>

-- 
Ben Hutchings
All extremists should be taken out and shot.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH selftests 2/6] selftests: memfd: Stop unnecessary rebuilds
       [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
  2015-10-31 23:36   ` [PATCH selftests 1/6] selftests: Add missing #include directives Ben Hutchings
@ 2015-10-31 23:37   ` Ben Hutchings
  2015-10-31 23:37   ` [PATCH selftests 3/6] selftests: kprobe: Choose an always-defined function to probe Ben Hutchings
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Ben Hutchings @ 2015-10-31 23:37 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-api-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1244 bytes --]

Instead of explicitly running the compiler, add dependencies and take
advantage of implicit rules to build only as necessary.

Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
---
 tools/testing/selftests/memfd/Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 3e7eb79..fd396ac 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -4,16 +4,16 @@ CFLAGS += -I../../../../include/uapi/
 CFLAGS += -I../../../../include/
 CFLAGS += -I../../../../usr/include/
 
-all:
-	$(CC) $(CFLAGS) memfd_test.c -o memfd_test
-
 TEST_PROGS := memfd_test
 
+all: $(TEST_PROGS)
+
 include ../lib.mk
 
-build_fuse:
-	$(CC) $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt
-	$(CC) $(CFLAGS) fuse_test.c -o fuse_test
+build_fuse: fuse_mnt fuse_test
+
+fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
+fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs)
 
 run_fuse: build_fuse
 	@./run_fuse_test.sh || echo "fuse_test: [FAIL]"

-- 
Ben Hutchings
All extremists should be taken out and shot.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH selftests 3/6] selftests: kprobe: Choose an always-defined function to probe
       [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
  2015-10-31 23:36   ` [PATCH selftests 1/6] selftests: Add missing #include directives Ben Hutchings
  2015-10-31 23:37   ` [PATCH selftests 2/6] selftests: memfd: Stop unnecessary rebuilds Ben Hutchings
@ 2015-10-31 23:37   ` Ben Hutchings
  2015-10-31 23:37   ` [PATCH selftests 4/6] selftests: Make scripts executable Ben Hutchings
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Ben Hutchings @ 2015-10-31 23:37 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-api-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 4794 bytes --]

do_fork() is no longer defined on x86, so probe _do_fork() instead.

Fixes: 3033f14ab78c ("clone: support passing tls argument via C ...")
Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
---
 .../selftests/ftrace/test.d/kprobe/add_and_remove.tc       |  2 +-
 tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc |  2 +-
 .../testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc  |  2 +-
 .../selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc        | 14 +++++++-------
 .../selftests/ftrace/test.d/kprobe/kretprobe_args.tc       |  2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc b/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc
index a5a4262..c3843ed 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc
@@ -5,7 +5,7 @@
 
 echo 0 > events/enable
 echo > kprobe_events
-echo p:myevent do_fork > kprobe_events
+echo p:myevent _do_fork > kprobe_events
 grep myevent kprobe_events
 test -d events/kprobes/myevent
 echo > kprobe_events
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc b/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
index d8c7bb6..74507db 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
@@ -5,7 +5,7 @@
 
 echo 0 > events/enable
 echo > kprobe_events
-echo p:myevent do_fork > kprobe_events
+echo p:myevent _do_fork > kprobe_events
 test -d events/kprobes/myevent
 echo 1 > events/kprobes/myevent/enable
 echo > kprobe_events && exit 1 # this must fail
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc
index c45ee27..64949d4 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc
@@ -5,7 +5,7 @@
 
 echo 0 > events/enable
 echo > kprobe_events
-echo 'p:testprobe do_fork $stack $stack0 +0($stack)' > kprobe_events
+echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events
 grep testprobe kprobe_events
 test -d events/kprobes/testprobe
 echo 1 > events/kprobes/testprobe/enable
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc
index ab41d2b..d6f2f49 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc
@@ -6,31 +6,31 @@ grep function available_tracers || exit_unsupported # this is configurable
 
 # prepare
 echo nop > current_tracer
-echo do_fork > set_ftrace_filter
+echo _do_fork > set_ftrace_filter
 echo 0 > events/enable
 echo > kprobe_events
-echo 'p:testprobe do_fork' > kprobe_events
+echo 'p:testprobe _do_fork' > kprobe_events
 
 # kprobe on / ftrace off
 echo 1 > events/kprobes/testprobe/enable
 echo > trace
 ( echo "forked")
 grep testprobe trace
-! grep 'do_fork <-' trace
+! grep '_do_fork <-' trace
 
 # kprobe on / ftrace on
 echo function > current_tracer
 echo > trace
 ( echo "forked")
 grep testprobe trace
-grep 'do_fork <-' trace
+grep '_do_fork <-' trace
 
 # kprobe off / ftrace on
 echo 0 > events/kprobes/testprobe/enable
 echo > trace
 ( echo "forked")
 ! grep testprobe trace
-grep 'do_fork <-' trace
+grep '_do_fork <-' trace
 
 # kprobe on / ftrace on
 echo 1 > events/kprobes/testprobe/enable
@@ -38,14 +38,14 @@ echo function > current_tracer
 echo > trace
 ( echo "forked")
 grep testprobe trace
-grep 'do_fork <-' trace
+grep '_do_fork <-' trace
 
 # kprobe on / ftrace off
 echo nop > current_tracer
 echo > trace
 ( echo "forked")
 grep testprobe trace
-! grep 'do_fork <-' trace
+! grep '_do_fork <-' trace
 
 # cleanup
 echo nop > current_tracer
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc
index 3171798..0d09546 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc
@@ -5,7 +5,7 @@
 
 echo 0 > events/enable
 echo > kprobe_events
-echo 'r:testprobe2 do_fork $retval' > kprobe_events
+echo 'r:testprobe2 _do_fork $retval' > kprobe_events
 grep testprobe2 kprobe_events
 test -d events/kprobes/testprobe2
 echo 1 > events/kprobes/testprobe2/enable

-- 
Ben Hutchings
All extremists should be taken out and shot.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH selftests 4/6] selftests: Make scripts executable
       [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
                     ` (2 preceding siblings ...)
  2015-10-31 23:37   ` [PATCH selftests 3/6] selftests: kprobe: Choose an always-defined function to probe Ben Hutchings
@ 2015-10-31 23:37   ` Ben Hutchings
  2015-10-31 23:39   ` [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages Ben Hutchings
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Ben Hutchings @ 2015-10-31 23:37 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-api-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

Fixes: 87b2d44026e0 ("selftests: add memfd/sealing page-pinning tests")
Fixes: 2bf9e0ab08c6 ("locking/static_keys: Provide a selftest")
Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
---
 tools/testing/selftests/memfd/run_fuse_test.sh          | 0
 tools/testing/selftests/static_keys/test_static_keys.sh | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 tools/testing/selftests/memfd/run_fuse_test.sh
 mode change 100644 => 100755 tools/testing/selftests/static_keys/test_static_keys.sh

diff --git a/tools/testing/selftests/memfd/run_fuse_test.sh b/tools/testing/selftests/memfd/run_fuse_test.sh
old mode 100644
new mode 100755
diff --git a/tools/testing/selftests/static_keys/test_static_keys.sh b/tools/testing/selftests/static_keys/test_static_keys.sh
old mode 100644
new mode 100755

-- 
Ben Hutchings
All extremists should be taken out and shot.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages
       [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
                     ` (3 preceding siblings ...)
  2015-10-31 23:37   ` [PATCH selftests 4/6] selftests: Make scripts executable Ben Hutchings
@ 2015-10-31 23:39   ` Ben Hutchings
       [not found]     ` <1446334747.2595.19.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
  2015-10-31 23:39   ` [PATCH selftests 6/6] selftests: breakpoint: Actually build it Ben Hutchings
  2015-11-02 12:15   ` [PATCH selftests 0/6] Fix some broken tests Ben Hutchings
  6 siblings, 1 reply; 12+ messages in thread
From: Ben Hutchings @ 2015-10-31 23:39 UTC (permalink / raw)
  To: Shuah Khan
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg

[-- Attachment #1: Type: text/plain, Size: 1632 bytes --]

If we need to increase the number of huge pages, drop caches first
to reduce fragmentation and then check that we actually allocated
as many as we wanted.  Retry once if that doesn't work.

Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
---
The test always fails for me in a 1 GB VM without this.

Ben.

 tools/testing/selftests/vm/run_vmtests | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
index 9179ce8..97ed1b2 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -20,13 +20,26 @@ done < /proc/meminfo
 if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
 	nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
 	needpgs=`expr $needmem / $pgsize`
-	if [ $freepgs -lt $needpgs ]; then
+	tries=2
+	while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
 		lackpgs=$(( $needpgs - $freepgs ))
+		echo 3 > /proc/sys/vm/drop_caches
 		echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
 		if [ $? -ne 0 ]; then
 			echo "Please run this test as root"
 			exit 1
 		fi
+		while read name size unit; do
+			if [ "$name" = "HugePages_Free:" ]; then
+				freepgs=$size
+			fi
+		done < /proc/meminfo
+		tries=$((tries - 1))
+	done
+	if [ $freepgs -lt $needpgs ]; then
+		printf "Not enough huge pages available (%d < %d)\n" \
+		       $freepgs $needpgs
+		exit 1
 	fi
 else
 	echo "no hugetlbfs support in kernel?"

-- 
Ben Hutchings
All extremists should be taken out and shot.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH selftests 6/6] selftests: breakpoint: Actually build it
       [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
                     ` (4 preceding siblings ...)
  2015-10-31 23:39   ` [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages Ben Hutchings
@ 2015-10-31 23:39   ` Ben Hutchings
  2015-11-02 12:15   ` [PATCH selftests 0/6] Fix some broken tests Ben Hutchings
  6 siblings, 0 replies; 12+ messages in thread
From: Ben Hutchings @ 2015-10-31 23:39 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-api-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 708 bytes --]

Fixes: 9fae100cbd10 ("selftests: breakpoints: fix installing error on ...")
Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
---
 tools/testing/selftests/breakpoints/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index d27108b..c0d9570 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -6,7 +6,7 @@ ifeq ($(ARCH),x86)
 TEST_PROGS := breakpoint_test
 endif
 
-all:
+all: $(TEST_PROGS)
 
 include ../lib.mk
 
-- 
Ben Hutchings
All extremists should be taken out and shot.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH selftests 0/6] Fix some broken tests
       [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
                     ` (5 preceding siblings ...)
  2015-10-31 23:39   ` [PATCH selftests 6/6] selftests: breakpoint: Actually build it Ben Hutchings
@ 2015-11-02 12:15   ` Ben Hutchings
  6 siblings, 0 replies; 12+ messages in thread
From: Ben Hutchings @ 2015-11-02 12:15 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-api-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 2120 bytes --]

On Sat, 2015-10-31 at 23:35 +0000, Ben Hutchings wrote:
> This series fixes some self-tests that are broken, unreliable or
> produce compiler warnings in 4.3.

I now realise that Evolution 3.18 has regressed and is mangling the
patches I send.  I'll send unmangled patches shortly.

Ben.

> Ben.
> 
> Ben Hutchings (6):
>   selftests: Add missing #include directives
>   selftests: memfd: Stop unnecessary rebuilds
>   selftests: kprobe: Choose an always-defined function to probe
>   selftests: Make scripts executable
>   selftests: vm: Try harder to allocate huge pages
>   selftests: breakpoint: Actually build it
> 
>  tools/testing/selftests/breakpoints/Makefile              |  2 +-
>  .../selftests/ftrace/test.d/kprobe/add_and_remove.tc      |  2 +-
>  .../testing/selftests/ftrace/test.d/kprobe/busy_check.tc  |  2 +-
>  .../testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc |  2 +-
>  .../selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc       | 14 +++++++-------
>  .../selftests/ftrace/test.d/kprobe/kretprobe_args.tc      |  2 +-
>  tools/testing/selftests/memfd/Makefile                    | 12 ++++++------
>  tools/testing/selftests/memfd/memfd_test.c                |  1 +
>  tools/testing/selftests/memfd/run_fuse_test.sh            |  0
>  tools/testing/selftests/mqueue/mq_open_tests.c            |  1 +
>  tools/testing/selftests/mqueue/mq_perf_tests.c            |  1 +
>  tools/testing/selftests/static_keys/test_static_keys.sh   |  0
>  tools/testing/selftests/timers/nanosleep.c                |  1 +
>  tools/testing/selftests/vm/run_vmtests                    | 15 ++++++++++++++-
>  14 files changed, 36 insertions(+), 19 deletions(-)
>  mode change 100644 => 100755 tools/testing/selftests/memfd/run_fuse_test.sh
>  mode change 100644 => 100755 tools/testing/selftests/static_keys/test_static_keys.sh
> 
-- 
Ben Hutchings
Nothing is ever a complete failure; it can always serve as a bad example.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages
       [not found]     ` <1446334747.2595.19.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
@ 2015-11-10 20:01       ` David Rientjes
       [not found]         ` <alpine.DEB.2.10.1511101159480.29993-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: David Rientjes @ 2015-11-10 20:01 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Shuah Khan, linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1926 bytes --]

On Sat, 31 Oct 2015, Ben Hutchings wrote:

> If we need to increase the number of huge pages, drop caches first
> to reduce fragmentation and then check that we actually allocated
> as many as we wanted.  Retry once if that doesn't work.
> 
> Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
> ---
> The test always fails for me in a 1 GB VM without this.
> 
> Ben.
> 
>  tools/testing/selftests/vm/run_vmtests | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
> index 9179ce8..97ed1b2 100755
> --- a/tools/testing/selftests/vm/run_vmtests
> +++ b/tools/testing/selftests/vm/run_vmtests
> @@ -20,13 +20,26 @@ done < /proc/meminfo
>  if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
>  	nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
>  	needpgs=`expr $needmem / $pgsize`
> -	if [ $freepgs -lt $needpgs ]; then
> +	tries=2
> +	while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
>  		lackpgs=$(( $needpgs - $freepgs ))
> +		echo 3 > /proc/sys/vm/drop_caches
>  		echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
>  		if [ $? -ne 0 ]; then
>  			echo "Please run this test as root"
>  			exit 1
>  		fi
> +		while read name size unit; do
> +			if [ "$name" = "HugePages_Free:" ]; then
> +				freepgs=$size
> +			fi
> +		done < /proc/meminfo
> +		tries=$((tries - 1))
> +	done
> +	if [ $freepgs -lt $needpgs ]; then
> +		printf "Not enough huge pages available (%d < %d)\n" \
> +		       $freepgs $needpgs
> +		exit 1
>  	fi
>  else
>  	echo "no hugetlbfs support in kernel?"
> 

I know this patch is in -mm and hasn't been merged by Linus yet, but I'm 
wondering why the multiple /proc/sys/vm/drop_caches is helping?  Would it 
simply suffice to put a sleep in there instead or is drop_caches actually 
doing something useful a second time around?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages
       [not found]         ` <alpine.DEB.2.10.1511101159480.29993-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
@ 2015-11-10 20:05           ` Shuah Khan
  2015-11-10 21:48           ` Ben Hutchings
  1 sibling, 0 replies; 12+ messages in thread
From: Shuah Khan @ 2015-11-10 20:05 UTC (permalink / raw)
  To: David Rientjes, Ben Hutchings
  Cc: linux-api-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	Shuah Khan

On 11/10/2015 01:01 PM, David Rientjes wrote:
> On Sat, 31 Oct 2015, Ben Hutchings wrote:
> 
>> If we need to increase the number of huge pages, drop caches first
>> to reduce fragmentation and then check that we actually allocated
>> as many as we wanted.  Retry once if that doesn't work.
>>
>> Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
>> ---
>> The test always fails for me in a 1 GB VM without this.
>>
>> Ben.
>>
>>  tools/testing/selftests/vm/run_vmtests | 15 ++++++++++++++-
>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
>> index 9179ce8..97ed1b2 100755
>> --- a/tools/testing/selftests/vm/run_vmtests
>> +++ b/tools/testing/selftests/vm/run_vmtests
>> @@ -20,13 +20,26 @@ done < /proc/meminfo
>>  if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
>>  	nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
>>  	needpgs=`expr $needmem / $pgsize`
>> -	if [ $freepgs -lt $needpgs ]; then
>> +	tries=2
>> +	while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
>>  		lackpgs=$(( $needpgs - $freepgs ))
>> +		echo 3 > /proc/sys/vm/drop_caches
>>  		echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
>>  		if [ $? -ne 0 ]; then
>>  			echo "Please run this test as root"
>>  			exit 1
>>  		fi
>> +		while read name size unit; do
>> +			if [ "$name" = "HugePages_Free:" ]; then
>> +				freepgs=$size
>> +			fi
>> +		done < /proc/meminfo
>> +		tries=$((tries - 1))
>> +	done
>> +	if [ $freepgs -lt $needpgs ]; then
>> +		printf "Not enough huge pages available (%d < %d)\n" \
>> +		       $freepgs $needpgs
>> +		exit 1
>>  	fi
>>  else
>>  	echo "no hugetlbfs support in kernel?"
>>
> 
> I know this patch is in -mm and hasn't been merged by Linus yet, but I'm 
> wondering why the multiple /proc/sys/vm/drop_caches is helping?  Would it 
> simply suffice to put a sleep in there instead or is drop_caches actually 
> doing something useful a second time around?
> 

I sent this up for merge in my pull request. Adding sleep would increase
test run-time. Something to keep in mind.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages
       [not found]         ` <alpine.DEB.2.10.1511101159480.29993-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
  2015-11-10 20:05           ` Shuah Khan
@ 2015-11-10 21:48           ` Ben Hutchings
  2015-11-11  1:11             ` David Rientjes
  1 sibling, 1 reply; 12+ messages in thread
From: Ben Hutchings @ 2015-11-10 21:48 UTC (permalink / raw)
  To: David Rientjes
  Cc: Shuah Khan, linux-api-u79uwXL29TY76Z2rM5mHXA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg

[-- Attachment #1: Type: text/plain, Size: 2978 bytes --]

On Tue, 2015-11-10 at 12:01 -0800, David Rientjes wrote:
> On Sat, 31 Oct 2015, Ben Hutchings wrote:
> 
> > If we need to increase the number of huge pages, drop caches first
> > to reduce fragmentation and then check that we actually allocated
> > as many as we wanted.  Retry once if that doesn't work.
> > 
> > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > ---
> > The test always fails for me in a 1 GB VM without this.
> > 
> > Ben.
> > 
> >  tools/testing/selftests/vm/run_vmtests | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
> > index 9179ce8..97ed1b2 100755
> > --- a/tools/testing/selftests/vm/run_vmtests
> > +++ b/tools/testing/selftests/vm/run_vmtests
> > @@ -20,13 +20,26 @@ done < /proc/meminfo
> >  if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
> >       nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
> >       needpgs=`expr $needmem / $pgsize`
> > -     if [ $freepgs -lt $needpgs ]; then
> > +     tries=2
> > +     while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
> >               lackpgs=$(( $needpgs - $freepgs ))
> > +             echo 3 > /proc/sys/vm/drop_caches
> >               echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
> >               if [ $? -ne 0 ]; then
> >                       echo "Please run this test as root"
> >                       exit 1
> >               fi
> > +             while read name size unit; do
> > +                     if [ "$name" = "HugePages_Free:" ]; then
> > +                             freepgs=$size
> > +                     fi
> > +             done < /proc/meminfo
> > +             tries=$((tries - 1))
> > +     done
> > +     if [ $freepgs -lt $needpgs ]; then
> > +             printf "Not enough huge pages available (%d < %d)\n" \
> > +                    $freepgs $needpgs
> > +             exit 1
> >       fi
> >  else
> >       echo "no hugetlbfs support in kernel?"
> > 
> 
> I know this patch is in -mm and hasn't been merged by Linus yet, but I'm 
> wondering why the multiple /proc/sys/vm/drop_caches is helping?  Would it 
> simply suffice to put a sleep in there instead or is drop_caches actually 
> doing something useful a second time around?

Initially I just retried setting nr_hugepages up to 10 times, which
wasn't sufficient.  Then I added the drop_caches, and after that
setting nr_hugepages tended to worked first time so I reduced the retry
count.  It might not be necessary to retry at all.

Ben.

-- 
Ben Hutchings
All the simple programs have been written, and all the good names taken.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages
  2015-11-10 21:48           ` Ben Hutchings
@ 2015-11-11  1:11             ` David Rientjes
  0 siblings, 0 replies; 12+ messages in thread
From: David Rientjes @ 2015-11-11  1:11 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Shuah Khan, linux-api, linux-mm

[-- Attachment #1: Type: TEXT/PLAIN, Size: 783 bytes --]

On Tue, 10 Nov 2015, Ben Hutchings wrote:

> > I know this patch is in -mm and hasn't been merged by Linus yet, but I'm 
> > wondering why the multiple /proc/sys/vm/drop_caches is helping?  Would it 
> > simply suffice to put a sleep in there instead or is drop_caches actually 
> > doing something useful a second time around?
> 
> Initially I just retried setting nr_hugepages up to 10 times, which
> wasn't sufficient.  Then I added the drop_caches, and after that
> setting nr_hugepages tended to worked first time so I reduced the retry
> count.  It might not be necessary to retry at all.
> 

Ok, thanks.  I was just trying to make sure that the additional 
drop_caches wasn't actually required for the test, in which case we would 
have to fix drop_caches :)

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-11-11  1:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-31 23:35 [PATCH selftests 0/6] Fix some broken tests Ben Hutchings
     [not found] ` <1446334510.2595.13.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
2015-10-31 23:36   ` [PATCH selftests 1/6] selftests: Add missing #include directives Ben Hutchings
2015-10-31 23:37   ` [PATCH selftests 2/6] selftests: memfd: Stop unnecessary rebuilds Ben Hutchings
2015-10-31 23:37   ` [PATCH selftests 3/6] selftests: kprobe: Choose an always-defined function to probe Ben Hutchings
2015-10-31 23:37   ` [PATCH selftests 4/6] selftests: Make scripts executable Ben Hutchings
2015-10-31 23:39   ` [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages Ben Hutchings
     [not found]     ` <1446334747.2595.19.camel-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
2015-11-10 20:01       ` David Rientjes
     [not found]         ` <alpine.DEB.2.10.1511101159480.29993-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2015-11-10 20:05           ` Shuah Khan
2015-11-10 21:48           ` Ben Hutchings
2015-11-11  1:11             ` David Rientjes
2015-10-31 23:39   ` [PATCH selftests 6/6] selftests: breakpoint: Actually build it Ben Hutchings
2015-11-02 12:15   ` [PATCH selftests 0/6] Fix some broken tests Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).