Skip to contentSkip to conversation

Hugetlb:Migrating the libhugetlbfs tests

PATCH In review Tarun Sahu 2 participants 26 messages Nov 20, 2022 – Dec 1, 2022 Library code

v5 of 8 In review Latest is v8 →

lore
Share & tools
lore

Tarun Sahu

author
#0 lore raw

v5 cover Hugetlb:Migrating the libhugetlbfs tests

Hi,
This patch series is in continuation to first part [1] This series include 5 more tests taken from libhugetlbfs.

Background:
Libhugetlbfs is not being maintained actively, and some distro is dropping support for it. There are some tests that are good for testing hugetlb functionality in kernel. These patches include tests from libhugetlbfs.

ref:
1. https://lore.kernel.org/all/[email protected]/

v4 -> v5
1. PATCH[1/7] Removed the srand() call from tst_creat_unlinked.
2. PATCH[2/7] Reworked on the code. Removed the macro based condition check. Added condition check for each function call and created a new function for loop action.

v3 -> v4
1. Removing redundant access call to check if file already exists. and removing the retry path, as the case is very rare.

v2 -> v3
1. Changed from setjmp/longjmp logic to check/return logic in hugemmap10.c
2. Added a new patch to create support for custom flags in tst_creat_unlinked api.
3. Added patch to add safe macros for posix_fadvise call.
4. Updated coding asthetics.
5. Added description along with the line of failure in hugemmap10.c

v1 -> v2
1. Fixed comments

Tarun Sahu (7):
Hugetlb: Add new argument flags in tst_creat_unlinked
Hugetlb: Migrating libhugetlbfs counters
Hugetlb: Migrating libhugetlbfs directio
Hugetlb: Safe macro for posix_fadvise call
Hugetlb: Migrating libhugetlbfs fadvise_reserve
Hugetlb: Migrating libhugetlbfs fallocate_align
Hugetlb: Migrating libhugetlbfs fallocate_basic

 include/tst_safe_macros.h                     |  17 +
 include/tst_test.h                            |   2 +-
 lib/tst_test.c                                |  16 +-
 runtest/hugetlb                               |   6 +
 testcases/kernel/mem/.gitignore               |   5 +
 .../kernel/mem/hugetlb/hugefallocate/Makefile |  10 +
 .../hugetlb/hugefallocate/hugefallocate01.c   | 169 +++++++
 .../hugetlb/hugefallocate/hugefallocate02.c   |  90 ++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap07.c  |   2 +-
 .../kernel/mem/hugetlb/hugemmap/hugemmap08.c  |   2 +-
 .../kernel/mem/hugetlb/hugemmap/hugemmap09.c  |   2 +-
 .../kernel/mem/hugetlb/hugemmap/hugemmap10.c  | 462 ++++++++++++++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap11.c  |  87 ++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap12.c  |  84 ++++
 14 files changed, 946 insertions(+), 8 deletions(-)
 create mode 100644 testcases/kernel/mem/hugetlb/hugefallocate/Makefile
 create mode 100644 testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate01.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate02.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap10.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap11.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap12.c
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH v5 1/7 Hugetlb: Add new argument flags in tst_creat_unlinked

Some test requires custom flags for file opened by tst_creat_unlinked along with O_CREAT|O_EXCL|O_RDWR. This patch creates support to pass custom flags in tst_creat_unlinked.

---
 include/tst_test.h                               |  2 +-
 lib/tst_test.c                                   | 16 ++++++++++++----
 .../kernel/mem/hugetlb/hugemmap/hugemmap07.c     |  2 +-
 .../kernel/mem/hugetlb/hugemmap/hugemmap08.c     |  2 +-
 .../kernel/mem/hugetlb/hugemmap/hugemmap09.c     |  2 +-
 5 files changed, 16 insertions(+), 8 deletions(-)
include/tst_test.h +1 -1
index acf2421de..a62515bfe 100644
@@ -365,7 +365,7 @@ void tst_set_max_runtime(int max_runtime);
  * Create and open a random file inside the given dir path.
  * It unlinks the file after opening and return file descriptor.
  */
-int tst_creat_unlinked(const char *path);
+int tst_creat_unlinked(const char *path, int flags);
 
 /*
  * Returns path to the test temporary directory in a newly allocated buffer.
lib/tst_test.c +12 -4
index b225ba082..9c4c4f064 100644
@@ -1027,18 +1027,26 @@ static void prepare_and_mount_hugetlb_fs(void)
 	mntpoint_mounted = 1;
 }
 
-int tst_creat_unlinked(const char *path)
+int tst_creat_unlinked(const char *path, int flags)
 {
 	char template[PATH_MAX];
+	int len, c, range;
 	int fd;
+	int start[3] = {'0', 'a', 'A'};
 
 	snprintf(template, PATH_MAX, "%s/ltp_%.3sXXXXXX",
 			path, tid);
 
-	fd = mkstemp(template);
-	if (fd < 0)
-		tst_brk(TBROK | TERRNO, "mkstemp(%s) failed", template);
+	len = strlen(template) - 1;
+	while (template[len] == 'X') {
+		c = rand() % 3;
+		range = start[c] == '0' ? 10 : 26;
+		c = start[c] + (rand() % range);
+		template[len--] = (char)c;
+	}
 
+	flags |= O_CREAT|O_EXCL|O_RDWR;
+	fd = SAFE_OPEN(template, flags);
 	SAFE_UNLINK(template);
 	return fd;
 }
testcases/kernel/mem/hugetlb/hugemmap/hugemmap07.c +1 -1
index bd0fb440a..3122d5b9d 100644
@@ -113,7 +113,7 @@ cleanup:
 static void setup(void)
 {
 	hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
-	huge_fd = tst_creat_unlinked(MNTPOINT);
+	huge_fd = tst_creat_unlinked(MNTPOINT, 0);
 }
 
 static void cleanup(void)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap08.c +1 -1
index ce40e7b69..f66b331dc 100644
@@ -118,7 +118,7 @@ static void run_test(unsigned int test_type)
 static void setup(void)
 {
 	hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
-	huge_fd = tst_creat_unlinked(MNTPOINT);
+	huge_fd = tst_creat_unlinked(MNTPOINT, 0);
 }
 
 static void cleanup(void)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap09.c +1 -1
index 1008395a4..ceb0f64a1 100644
@@ -60,7 +60,7 @@ static void run_test(void)
 static void setup(void)
 {
 	hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
-	huge_fd = tst_creat_unlinked(MNTPOINT);
+	huge_fd = tst_creat_unlinked(MNTPOINT, 0);
 }
 
 static void cleanup(void)
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

PATCH v5 2/7 Hugetlb: Migrating libhugetlbfs counters

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/counters.c test

Test Description: This Test perform mmap, munmap and write operation on hugetlb file based mapping. Mapping can be shared or private. and it checks for Hugetlb counter (Total, Free, Reserve, Surplus) in /proc/meminfo and compare them with expected (calculated) value. If all checks are successful, the test passes.

---
 runtest/hugetlb                               |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap10.c  | 462 ++++++++++++++++++
 3 files changed, 464 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap10.c
runtest/hugetlb +1 -0
index e2ada7a97..8a56d52a3 100644
@@ -6,6 +6,7 @@ hugemmap06 hugemmap06
 hugemmap07 hugemmap07
 hugemmap08 hugemmap08
 hugemmap09 hugemmap09
+hugemmap10 hugemmap10
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index 1a242ffe0..e7def68cb 100644
@@ -7,6 +7,7 @@
 /hugetlb/hugemmap/hugemmap07
 /hugetlb/hugemmap/hugemmap08
 /hugetlb/hugemmap/hugemmap09
+/hugetlb/hugemmap/hugemmap10
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap10.c new file +462 -0

462 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#4 lore raw

PATCH v5 3/7 Hugetlb: Migrating libhugetlbfs directio

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/direct.c test

Test Description: This Test perform Direct Write/Read from/To hugetlbfs file which is mapped to process address space. The test is checking if it succeeds and data written or read is not corrupted.

---
 runtest/hugetlb                               |  1 +
 testcases/kernel/mem/.gitignore               |  1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap11.c  | 87 +++++++++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap11.c
runtest/hugetlb +1 -0
index 8a56d52a3..b9ee7227d 100644
@@ -7,6 +7,7 @@ hugemmap07 hugemmap07
 hugemmap08 hugemmap08
 hugemmap09 hugemmap09
 hugemmap10 hugemmap10
+hugemmap11 hugemmap11
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index e7def68cb..3e64b67be 100644
@@ -8,6 +8,7 @@
 /hugetlb/hugemmap/hugemmap08
 /hugetlb/hugemmap/hugemmap09
 /hugetlb/hugemmap/hugemmap10
+/hugetlb/hugemmap/hugemmap11
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap11.c new file +87 -0

87 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw

PATCH v5 4/7 Hugetlb: Safe macro for posix_fadvise call

In reply to Tarun Sahu

This patch adds SAFE_POSIX_FADVISE for posix_fadvise call.

---
 include/tst_safe_macros.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/tst_safe_macros.h +17 -0
index 81c4b0844..4965e44d0 100644
@@ -298,6 +298,23 @@ static inline int safe_ftruncate(const char *file, const int lineno,
 #define SAFE_FTRUNCATE(fd, length) \
 	safe_ftruncate(__FILE__, __LINE__, (fd), (length))
 
+static inline int safe_posix_fadvise(const char *file, const int lineno,
+                                int fd, off_t offset, off_t len, int advice)
+{
+	int rval;
+
+	rval = posix_fadvise(fd, offset, len, advice);
+
+	if (rval)
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"posix_fadvise(%d,%ld,%ld,%d) failed",
+			fd, (long)offset, (long)len, advice);
+
+	return rval;
+}
+#define SAFE_POSIX_FADVISE(fd, offset, len, advice) \
+	safe_posix_fadvise(__FILE__, __LINE__, (fd), (offset), (len), (advice))
+
 static inline int safe_truncate(const char *file, const int lineno,
                                 const char *path, off_t length)
 {
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#9 lore raw

PATCH v5 5/7 Hugetlb: Migrating libhugetlbfs fadvise_reserve

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/fadvise_reserve.c test

Test Description: fadvise() on some kernels can cause the reservation counter to get corrupted. The problem is that the patches are allocated for the reservation but not faulted in at the time of allocation. The counters do not get updated and effectively "leak". This test identifies whether the kernel is vulnerable to the problem or not. It's fixed in kernel by 'commit f2deae9d4e70 ("Remove implementation of readpage from the hugetlbfs_aops")'

---
 runtest/hugetlb                               |  1 +
 testcases/kernel/mem/.gitignore               |  1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap12.c  | 84 +++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap12.c
runtest/hugetlb +1 -0
index b9ee7227d..b019c4195 100644
@@ -8,6 +8,7 @@ hugemmap08 hugemmap08
 hugemmap09 hugemmap09
 hugemmap10 hugemmap10
 hugemmap11 hugemmap11
+hugemmap12 hugemmap12
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index 3e64b67be..ec250592d 100644
@@ -9,6 +9,7 @@
 /hugetlb/hugemmap/hugemmap09
 /hugetlb/hugemmap/hugemmap10
 /hugetlb/hugemmap/hugemmap11
+/hugetlb/hugemmap/hugemmap12
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap12.c new file +84 -0

84 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#10 lore raw

PATCH v5 6/7 Hugetlb: Migrating libhugetlbfs fallocate_align

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/fallocate_align.c test

Test Description: It tests alignment of fallocate arguments. fallocate will take non-huge page aligned offsets and addresses. However, operations are only performed on huge pages. This is different that than fallocate behavior in "normal" filesystems.

---
 runtest/hugetlb                               |   2 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugefallocate/Makefile |  10 ++
 .../hugetlb/hugefallocate/hugefallocate01.c   | 169 ++++++++++++++++++
 4 files changed, 182 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugefallocate/Makefile
 create mode 100644 testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate01.c
runtest/hugetlb +2 -0
index b019c4195..ca92dfcff 100644
@@ -1,3 +1,5 @@
+hugefallocate01 hugefallocate01
+
 hugemmap01 hugemmap01
 hugemmap02 hugemmap02
 hugemmap04 hugemmap04
testcases/kernel/mem/.gitignore +1 -0
index ec250592d..cafdb5259 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugemmap/hugemmap01
 /hugetlb/hugemmap/hugemmap02
 /hugetlb/hugemmap/hugemmap04
testcases/kernel/mem/hugetlb/hugefallocate/Makefile new file +10 -0
new file mode 100644
index 000000000..77ebb0aef
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2009, Cisco Systems Inc.
+# Ngie Cooper, July 2009
+
+top_srcdir		?= ../../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate01.c new file +169 -0

169 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#12 lore raw

PATCH v5 7/7 Hugetlb: Migrating libhugetlbfs fallocate_basic

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/fallocate_basic.c test

Test Description: It tests basic fallocate functionality in hugetlbfs. Preallocate huge pages to a file in hugetlbfs, and then remove the pages via hole punch.

---
 runtest/hugetlb                               |  1 +
 testcases/kernel/mem/.gitignore               |  1 +
 .../hugetlb/hugefallocate/hugefallocate02.c   | 90 +++++++++++++++++++
 3 files changed, 92 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate02.c
runtest/hugetlb +1 -0
index ca92dfcff..ec1fc2515 100644
@@ -1,4 +1,5 @@
 hugefallocate01 hugefallocate01
+hugefallocate02 hugefallocate02
 
 hugemmap01 hugemmap01
 hugemmap02 hugemmap02
testcases/kernel/mem/.gitignore +1 -0
index cafdb5259..c0906f3d3 100644
@@ -1,5 +1,6 @@
 /cpuset/cpuset01
 /hugetlb/hugefallocate/hugefallocate01
+/hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugemmap/hugemmap01
 /hugetlb/hugemmap/hugemmap02
 /hugetlb/hugemmap/hugemmap04
testcases/kernel/mem/hugetlb/hugefallocate/hugefallocate02.c new file +90 -0

90 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH v5 1/7] Hugetlb: Add new argument flags in tst_creat_unlinked

In reply to Tarun Sahu

Hi!
I pushed the first three patches in the series, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH v5 4/7] Hugetlb: Safe macro for posix_fadvise call

In reply to Tarun Sahu

Hi!

Quoted 12 lines
 include/tst_safe_macros.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/tst_safe_macros.h +1 -0
index 81c4b0844..4965e44d0 100644
@@ -298,6 +298,23 @@ static inline int safe_ftruncate(const char *file, const int lineno,
 #define SAFE_FTRUNCATE(fd, length) \
 	safe_ftruncate(__FILE__, __LINE__, (fd), (length))
 
+static inline int safe_posix_fadvise(const char *file, const int lineno,

include/tst_safe_macros.h static inline int safe_ftruncate(const char *file, const int lineno, · line 311

Quoted 10 lines
include/tst_safe_macros.h +10 -0
+                                int fd, off_t offset, off_t len, int advice)
+{
+	int rval;
+
+	rval = posix_fadvise(fd, offset, len, advice);
+
+	if (rval)
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"posix_fadvise(%d,%ld,%ld,%d) failed",
+			fd, (long)offset, (long)len, advice);

I did a closer look at the posix_fadvise() manual and it returns an error in case of a failure, so the TERRNO is wrong here since that would print whatever was the last error stored in there.

So we either have to do errno = rval; in the if (rval) branch or use tst_strerrno() to print the errno ourselves.

Looking at the code we have the safe_pthread.c does use tst_strerrno() to print the error, so I would be inclined to do so here as well.

Also LKML coding style prefers curly braces around multiline blocks, so I would enclose the multiline tst_brk_() into curly braces, but that is very minor.

Quoted 11 lines
include/tst_safe_macros.h +5 -0
+	return rval;
+}
+#define SAFE_POSIX_FADVISE(fd, offset, len, advice) \
+	safe_posix_fadvise(__FILE__, __LINE__, (fd), (offset), (len), (advice))
+
 static inline int safe_truncate(const char *file, const int lineno,
                                 const char *path, off_t length)
 {
Signature · 1 line
2.31.1
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

Re: [LTP] [PATCH v5 6/7] Hugetlb: Migrating libhugetlbfs fallocate_align

In reply to Tarun Sahu

Hi!
And I've pushed the two hugefallocate tests as well, thanks.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#7 lore raw

Re: [LTP] [PATCH v5 4/7] Hugetlb: Safe macro for posix_fadvise call

In reply to Cyril Hrubis
Quoted 28 lines · Cyril Hrubis

Hi!

Quoted 12 lines
 include/tst_safe_macros.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/tst_safe_macros.h +1 -0
index 81c4b0844..4965e44d0 100644
@@ -298,6 +298,23 @@ static inline int safe_ftruncate(const char *file, const int lineno,
 #define SAFE_FTRUNCATE(fd, length) \
 	safe_ftruncate(__FILE__, __LINE__, (fd), (length))
 
+static inline int safe_posix_fadvise(const char *file, const int lineno,

include/tst_safe_macros.h static inline int safe_ftruncate(const char *file, const int lineno, · line 311

Quoted 10 lines
include/tst_safe_macros.h +10 -0
+                                int fd, off_t offset, off_t len, int advice)
+{
+	int rval;
+
+	rval = posix_fadvise(fd, offset, len, advice);
+
+	if (rval)
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"posix_fadvise(%d,%ld,%ld,%d) failed",
+			fd, (long)offset, (long)len, advice);

I did a closer look at the posix_fadvise() manual and it returns an error in case of a failure, so the TERRNO is wrong here since that would print whatever was the last error stored in there.

Quoted 6 lines

So we either have to do errno = rval; in the if (rval) branch or use tst_strerrno() to print the errno ourselves.

Looking at the code we have the safe_pthread.c does use tst_strerrno() to print the error, so I would be inclined to do so here as well.

posix_fadvise should be inline, and so for the convention it will be part of tst_safe_macros.h
tst_strerrno is defined in lib/errnos.h

there are only two such header file declared in this way. errnos.h and signame.h. To be able to use tst_strerrno, it will require some cleanup (like converting .h to .c and transfer PAIR, STRPAIR macros definition to header files too from tst_res.c).

As, Even looking at past commits, I am not sure why these two file are implememnted as .h, and not available as in general. I am currently thinking of errno = rval way.

Can those file be converted?

Quoted 22 lines

Also LKML coding style prefers curly braces around multiline blocks, so I would enclose the multiline tst_brk_() into curly braces, but that is very minor.

Quoted 11 lines
include/tst_safe_macros.h +5 -0
+	return rval;
+}
+#define SAFE_POSIX_FADVISE(fd, offset, len, advice) \
+	safe_posix_fadvise(__FILE__, __LINE__, (fd), (offset), (len), (advice))
+
 static inline int safe_truncate(const char *file, const int lineno,
                                 const char *path, off_t length)
 {
Signature · 1 line
2.31.1
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Re: [LTP] [PATCH v5 4/7] Hugetlb: Safe macro for posix_fadvise call

Hi!

Quoted 43 lines
Quoted 27 lines
Quoted 12 lines
 include/tst_safe_macros.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/tst_safe_macros.h +1 -0
index 81c4b0844..4965e44d0 100644
@@ -298,6 +298,23 @@ static inline int safe_ftruncate(const char *file, const int lineno,
 #define SAFE_FTRUNCATE(fd, length) \
 	safe_ftruncate(__FILE__, __LINE__, (fd), (length))
 
+static inline int safe_posix_fadvise(const char *file, const int lineno,

include/tst_safe_macros.h static inline int safe_ftruncate(const char *file, const int lineno, · line 311

Quoted 10 lines
include/tst_safe_macros.h +10 -0
+                                int fd, off_t offset, off_t len, int advice)
+{
+	int rval;
+
+	rval = posix_fadvise(fd, offset, len, advice);
+
+	if (rval)
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"posix_fadvise(%d,%ld,%ld,%d) failed",
+			fd, (long)offset, (long)len, advice);

I did a closer look at the posix_fadvise() manual and it returns an error in case of a failure, so the TERRNO is wrong here since that would print whatever was the last error stored in there.

Quoted 6 lines

So we either have to do errno = rval; in the if (rval) branch or use tst_strerrno() to print the errno ourselves.

Looking at the code we have the safe_pthread.c does use tst_strerrno() to print the error, so I would be inclined to do so here as well.

posix_fadvise should be inline, and so for the convention it will be part of tst_safe_macros.h
tst_strerrno is defined in lib/errnos.h

there are only two such header file declared in this way. errnos.h and signame.h. To be able to use tst_strerrno, it will require some cleanup (like converting .h to .c and transfer PAIR, STRPAIR macros definition to header files too from tst_res.c).

Quoted 5 lines

As, Even looking at past commits, I am not sure why these two file are implememnted as .h, and not available as in general. I am currently thinking of errno = rval way.

Can those file be converted?

Isn't the tst_strerrno() prototype defined in the tst_test.h?

The headers in lib/ are strictly internal implementation and shouldn't be used from tests at all. And they don't have to be included at all, since these are included in the test library in order to provide the implementation for these functions.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#13 lore raw

PATCH v6 1/2 Hugetlb: Safe macro for posix_fadvise call

In reply to Tarun Sahu

This patch adds SAFE_POSIX_FADVISE for posix_fadvise call.

---
 include/tst_safe_macros.h | 17 +++++++++++++++++
 include/tst_test.h        | 24 ++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)
include/tst_safe_macros.h +17 -0
index 81c4b0844..ab00dd14a 100644
@@ -298,6 +298,23 @@ static inline int safe_ftruncate(const char *file, const int lineno,
 #define SAFE_FTRUNCATE(fd, length) \
 	safe_ftruncate(__FILE__, __LINE__, (fd), (length))
 
+static inline int safe_posix_fadvise(const char *file, const int lineno,
+                                int fd, off_t offset, off_t len, int advice)
+{
+	int rval;
+
+	rval = posix_fadvise(fd, offset, len, advice);
+
+	if (rval)
+		tst_brk_(file, lineno, TBROK,
+			"posix_fadvise(%d,%ld,%ld,%d) failed: %s",
+			fd, (long)offset, (long)len, advice, tst_strerrno(rval));
+
+	return rval;
+}
+#define SAFE_POSIX_FADVISE(fd, offset, len, advice) \
+	safe_posix_fadvise(__FILE__, __LINE__, (fd), (offset), (len), (advice))
+
 static inline int safe_truncate(const char *file, const int lineno,
                                 const char *path, off_t length)
 {
include/tst_test.h +12 -12
index a62515bfe..2de9301e5 100644
@@ -95,6 +95,18 @@ pid_t safe_fork(const char *filename, unsigned int lineno);
 	({int ret = expr;                                           \
 	  ret != 0 ? tst_res(TINFO, #expr " failed"), ret : ret; }) \
 
+/*
+ * Functions to convert ERRNO to its name and SIGNAL to its name.
+ */
+const char *tst_strerrno(int err);
+const char *tst_strsig(int sig);
+/*
+ * Returns string describing status as returned by wait().
+ *
+ * BEWARE: Not thread safe.
+ */
+const char *tst_strstatus(int status);
+
 #include "tst_safe_macros.h"
 #include "tst_safe_file_ops.h"
 #include "tst_safe_net.h"
@@ -333,18 +345,6 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
  */
 void tst_reinit(void);
 
-/*
- * Functions to convert ERRNO to its name and SIGNAL to its name.
- */
-const char *tst_strerrno(int err);
-const char *tst_strsig(int sig);
-/*
- * Returns string describing status as returned by wait().
- *
- * BEWARE: Not thread safe.
- */
-const char *tst_strstatus(int status);
-
 unsigned int tst_multiply_timeout(unsigned int timeout);
 
 /*
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#14 lore raw

PATCH v6 2/2 Hugetlb: Migrating libhugetlbfs fadvise_reserve

Migrating the libhugetlbfs/testcases/fadvise_reserve.c test

Test Description: fadvise() on some kernels can cause the reservation counter to get corrupted. The problem is that the patches are allocated for the reservation but not faulted in at the time of allocation. The counters do not get updated and effectively "leak". This test identifies whether the kernel is vulnerable to the problem or not. It's fixed in kernel by 'commit f2deae9d4e70 ("Remove implementation of readpage from the hugetlbfs_aops")'

---
 runtest/hugetlb                               |  1 +
 testcases/kernel/mem/.gitignore               |  1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap12.c  | 84 +++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap12.c
runtest/hugetlb +1 -0
index b9ee7227d..b019c4195 100644
@@ -8,6 +8,7 @@ hugemmap08 hugemmap08
 hugemmap09 hugemmap09
 hugemmap10 hugemmap10
 hugemmap11 hugemmap11
+hugemmap12 hugemmap12
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index 3e64b67be..ec250592d 100644
@@ -9,6 +9,7 @@
 /hugetlb/hugemmap/hugemmap09
 /hugetlb/hugemmap/hugemmap10
 /hugetlb/hugemmap/hugemmap11
+/hugetlb/hugemmap/hugemmap12
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap12.c new file +84 -0

84 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

Re: [LTP] [PATCH v6 1/2] Hugetlb: Safe macro for posix_fadvise call

In reply to Tarun Sahu

Hi!
I did split this patch into two, one that touches tst_test.h and one that adds the safe macro and pushed the patchset, thanks.

The cleanest way how to split changes into patchset is that each patch does one logical change and properly explains why the change is needed in the commit message too.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#16 lore raw

Re: [LTP] [PATCH v6 1/2] Hugetlb: Safe macro for posix_fadvise call

Quoted 9 lines · Cyril Hrubis

Hi!
I did split this patch into two, one that touches tst_test.h and one that adds the safe macro and pushed the patchset, thanks.

The cleanest way how to split changes into patchset is that each patch does one logical change and properly explains why the change is needed in the commit message too.

Ok. I will keep it in mind..
Thanks.

Quoted 6 lines
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#18 lore raw

PATCH 1/8 Hugetlb: Migrating libhugetlbfs fork-cow

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/fork-cow.c test

Test Description: This checks copy-on-write semantics, specifically the semantics of a MAP_PRIVATE mapping across a fork(). Some versions of the powerpc kernel had a bug in huge_ptep_set_wrprotect() which would fail to flush the hash table after setting the write protect bit in the parent's page tables, thus allowing the parent to pollute the child's mapping.

---
 runtest/hugetlb                               |   2 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugefork/Makefile      |  10 ++
 .../kernel/mem/hugetlb/hugefork/hugefork01.c  | 108 ++++++++++++++++++
 4 files changed, 121 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugefork/Makefile
 create mode 100644 testcases/kernel/mem/hugetlb/hugefork/hugefork01.c
runtest/hugetlb +2 -0
index ec1fc2515..4c16e1e7c 100644
@@ -1,6 +1,8 @@
 hugefallocate01 hugefallocate01
 hugefallocate02 hugefallocate02
 
+hugefork01 hugefork01
+
 hugemmap01 hugemmap01
 hugemmap02 hugemmap02
 hugemmap04 hugemmap04
testcases/kernel/mem/.gitignore +1 -0
index c0906f3d3..adea760c7 100644
@@ -1,6 +1,7 @@
 /cpuset/cpuset01
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
+/hugetlb/hugefork/hugefork01
 /hugetlb/hugemmap/hugemmap01
 /hugetlb/hugemmap/hugemmap02
 /hugetlb/hugemmap/hugemmap04
testcases/kernel/mem/hugetlb/hugefork/Makefile new file +10 -0
new file mode 100644
index 000000000..77ebb0aef
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2009, Cisco Systems Inc.
+# Ngie Cooper, July 2009
+
+top_srcdir		?= ../../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
testcases/kernel/mem/hugetlb/hugefork/hugefork01.c new file +108 -0

108 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#17 lore raw

cover Hugetlb:Migrating the libhugetlbfs tests

In reply to Tarun Sahu

Hi,
This patch series is in continuation to part [1] and part [2] This series include 8 more tests taken from libhugetlbfs.

Background:
Libhugetlbfs is not being maintained actively, and some distro is dropping support for it. There are some tests that are good for testing hugetlb functionality in kernel. These patches include tests from libhugetlbfs.

ref:
1. https://lore.kernel.org/all/[email protected]/
2. https://lore.kernel.org/all/[email protected]/

Tarun Sahu (8):
Hugetlb: Migrating libhugetlbfs fork-cow
Hugetlb: Migrating libhugetlbfs huge_at_4GB_normal_below
Hugetlb: Migrating libhugetlbfs huge_below_4GB_normal_above
Hugetlb: Migrating libhugetlbfs icache-hygiene
Hugetlb: Migrating libhugetlbfs madvise_reserve
Hugetlb: Migrating libhugetlbfs map_high_truncate_2
Hugetlb: Migrating libhugetlbfs misalign
Hugetlb: Migrating libhugetlbfs misaligned_offset

 runtest/hugetlb                               |   9 +
 testcases/kernel/mem/.gitignore               |   8 +
 .../kernel/mem/hugetlb/hugefork/Makefile      |  10 +
 .../kernel/mem/hugetlb/hugefork/hugefork01.c  | 108 ++++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap13.c  | 122 +++++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap14.c  | 156 ++++++++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap15.c  | 239 ++++++++++++++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap16.c  |  83 ++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap17.c  | 103 ++++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap18.c  | 153 +++++++++++
 .../kernel/mem/hugetlb/hugemmap/hugemmap19.c  | 147 +++++++++++
 11 files changed, 1138 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugefork/Makefile
 create mode 100644 testcases/kernel/mem/hugetlb/hugefork/hugefork01.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap13.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap14.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap16.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap17.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap18.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap19.c
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#19 lore raw

PATCH 2/8 Hugetlb: Migrating libhugetlbfs huge_at_4GB_normal_below

Migrating the libhugetlbfs/testcases/huge_at_4GB_normal_below.c test

Test Description: Designed to pick up a bug on ppc64 where touches_hugepage_high_range() falsely reported true for ranges reaching below 4GB

---
 runtest/hugetlb                               |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap13.c  | 122 ++++++++++++++++++
 3 files changed, 124 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap13.c
runtest/hugetlb +1 -0
index 4c16e1e7c..2029ee4b3 100644
@@ -14,6 +14,7 @@ hugemmap09 hugemmap09
 hugemmap10 hugemmap10
 hugemmap11 hugemmap11
 hugemmap12 hugemmap12
+hugemmap13 hugemmap13
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index adea760c7..5955ed613 100644
@@ -13,6 +13,7 @@
 /hugetlb/hugemmap/hugemmap10
 /hugetlb/hugemmap/hugemmap11
 /hugetlb/hugemmap/hugemmap12
+/hugetlb/hugemmap/hugemmap13
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap13.c new file +122 -0

122 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#20 lore raw

PATCH 3/8 Hugetlb: Migrating libhugetlbfs huge_below_4GB_normal_above

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/huge_below_4GB_normal_above.c test

Test Description: Designed to pick up a bug on ppc64 where touches_hugepage_low_range() could give false positives because of the peculiar (undefined) behaviour of << for large shifts

---
 runtest/hugetlb                               |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap14.c  | 156 ++++++++++++++++++
 3 files changed, 158 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap14.c
runtest/hugetlb +1 -0
index 2029ee4b3..796ebe7fa 100644
@@ -15,6 +15,7 @@ hugemmap10 hugemmap10
 hugemmap11 hugemmap11
 hugemmap12 hugemmap12
 hugemmap13 hugemmap13
+hugemmap14 hugemmap14
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index 5955ed613..3106579ce 100644
@@ -14,6 +14,7 @@
 /hugetlb/hugemmap/hugemmap11
 /hugetlb/hugemmap/hugemmap12
 /hugetlb/hugemmap/hugemmap13
+/hugetlb/hugemmap/hugemmap14
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap14.c new file +156 -0

156 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#21 lore raw

PATCH 4/8 Hugetlb: Migrating libhugetlbfs icache-hygiene

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/icache-hygiene.c test

Test Description: Older ppc64 kernels don't properly flush dcache to icache before giving a cleared page to userspace. With some exceedingly hairy code, this attempts to test for this bug.

This test will never trigger (obviously) on machines with coherent icache and dcache (including x86 and POWER5). On any given run, even on a buggy kernel there's a chance the bug won't trigger - either because we don't get the same physical page back when we remap, or because the icache happens to get flushed in the interim.

---
 runtest/hugetlb                               |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap15.c  | 239 ++++++++++++++++++
 3 files changed, 241 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
runtest/hugetlb +1 -0
index 796ebe7fa..0714ed34c 100644
@@ -16,6 +16,7 @@ hugemmap11 hugemmap11
 hugemmap12 hugemmap12
 hugemmap13 hugemmap13
 hugemmap14 hugemmap14
+hugemmap15 hugemmap15
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index 3106579ce..d59b60fd4 100644
@@ -15,6 +15,7 @@
 /hugetlb/hugemmap/hugemmap12
 /hugetlb/hugemmap/hugemmap13
 /hugetlb/hugemmap/hugemmap14
+/hugetlb/hugemmap/hugemmap15
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c new file +239 -0

239 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#22 lore raw

PATCH 5/8 Hugetlb: Migrating libhugetlbfs madvise_reserve

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/madvise_reserve.c test

Test Description: madvise() on some kernels can cause the reservation counter to get corrupted. The problem is that the patches are allocated for the reservation but not faulted in at the time of allocation. The counters do not get updated and effectively "leak". This test identifies whether the kernel is vulnerable to the problem or not. It is fixed in kernel by 'commit f2deae9d4e70
("Remove implementation of readpage from the hugetlbfs_aops")'.

---
 runtest/hugetlb                               |  1 +
 testcases/kernel/mem/.gitignore               |  1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap16.c  | 83 +++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap16.c
runtest/hugetlb +1 -0
index 0714ed34c..1691ce37d 100644
@@ -17,6 +17,7 @@ hugemmap12 hugemmap12
 hugemmap13 hugemmap13
 hugemmap14 hugemmap14
 hugemmap15 hugemmap15
+hugemmap16 hugemmap16
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index d59b60fd4..eb8e87c40 100644
@@ -16,6 +16,7 @@
 /hugetlb/hugemmap/hugemmap13
 /hugetlb/hugemmap/hugemmap14
 /hugetlb/hugemmap/hugemmap15
+/hugetlb/hugemmap/hugemmap16
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap16.c new file +83 -0

83 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#23 lore raw

PATCH 6/8 Hugetlb: Migrating libhugetlbfs map_high_truncate_2

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/map_high_truncate_2.c test

Test Description: At one stage, a misconversion of hugetlb_vmtruncate_list to a prio_tree meant that on 32-bit machines, certain combinations of mapping and truncations could truncate incorrect pages, or overwrite pmds from other VMAs, triggering BUG_ON()s or other wierdness.

Test adapted from an example by Kenneth Chen <[email protected]>

WARNING: The offsets and addresses used within are specifically calculated to trigger the bug as it existed. Don't mess with them unless you *really* know what you're doing.

The kernel bug in question was fixed with
'commit 856fc2950555 ("[PATCH] hugetlb: fix prio_tree unit")'.

---
 runtest/hugetlb                               |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap17.c  | 103 ++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap17.c
runtest/hugetlb +1 -0
index 1691ce37d..5fac3481c 100644
@@ -18,6 +18,7 @@ hugemmap13 hugemmap13
 hugemmap14 hugemmap14
 hugemmap15 hugemmap15
 hugemmap16 hugemmap16
+hugemmap17 hugemmap17
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index eb8e87c40..6aa54f902 100644
@@ -17,6 +17,7 @@
 /hugetlb/hugemmap/hugemmap14
 /hugetlb/hugemmap/hugemmap15
 /hugetlb/hugemmap/hugemmap16
+/hugetlb/hugemmap/hugemmap17
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap17.c new file +103 -0

103 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#24 lore raw

PATCH 7/8 Hugetlb: Migrating libhugetlbfs misalign

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/misalign.c test

Test Description: Just as normal mmap()s can't have an address, length or offset which is not page aligned, so hugepage mmap()s can't have an address, length or offset with is not hugepage aligned.

However, from time to time when the various mmap() / get_unmapped_area() paths are updated, somebody misses one of the necessary checks for the hugepage paths. This testcase ensures that attempted hugepage mappings with parameters which are not correctly hugepage aligned are rejected.

However starting with 3.10-rc1, length passed in mmap() doesn't need to be aligned because 'commit af73e4d9506d
("hugetlbfs: fix mmap failure in unaligned size request")' added ALIGN() to kernel side, in mmap_pgoff(), when mapping huge page files.

---
 runtest/hugetlb                               |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap18.c  | 153 ++++++++++++++++++
 3 files changed, 155 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap18.c
runtest/hugetlb +1 -0
index 5fac3481c..de76cdaf2 100644
@@ -19,6 +19,7 @@ hugemmap14 hugemmap14
 hugemmap15 hugemmap15
 hugemmap16 hugemmap16
 hugemmap17 hugemmap17
+hugemmap18 hugemmap18
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index 6aa54f902..daee70586 100644
@@ -18,6 +18,7 @@
 /hugetlb/hugemmap/hugemmap15
 /hugetlb/hugemmap/hugemmap16
 /hugetlb/hugemmap/hugemmap17
+/hugetlb/hugemmap/hugemmap18
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap18.c new file +153 -0

153 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#25 lore raw

PATCH 8/8 Hugetlb: Migrating libhugetlbfs misaligned_offset

In reply to Tarun Sahu

Migrating the libhugetlbfs/testcases/misaligned_offset.c test

Test Name: Misaligned offset

Test Description: At one stage, a misconversion of hugetlb_vmtruncate_list to a prio_tree meant that on 32-bit machines, truncates at or above 4GB could truncate lower pages, resulting in BUG_ON()s.

WARNING: The offsets and addresses used within are specifically calculated to trigger the bug as it existed. Don't mess with them unless you *really* know what you're doing.

The kernel bug in question was fixed with
'commit 856fc2950555 ("[PATCH] hugetlb: fix prio_tree unit")'.

---
 runtest/hugetlb                               |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap19.c  | 147 ++++++++++++++++++
 3 files changed, 149 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap19.c
runtest/hugetlb +1 -0
index de76cdaf2..4da1525a7 100644
@@ -20,6 +20,7 @@ hugemmap15 hugemmap15
 hugemmap16 hugemmap16
 hugemmap17 hugemmap17
 hugemmap18 hugemmap18
+hugemmap19 hugemmap19
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index daee70586..b6b3e5ddd 100644
@@ -19,6 +19,7 @@
 /hugetlb/hugemmap/hugemmap16
 /hugetlb/hugemmap/hugemmap17
 /hugetlb/hugemmap/hugemmap18
+/hugetlb/hugemmap/hugemmap19
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap19.c new file +147 -0

147 lines not on this page · raw message

Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp