All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/shmget02: Handle missing hugepage support in HW
@ 2021-09-23 11:04 Martin Doucha
  2021-09-23 12:18 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Doucha @ 2021-09-23 11:04 UTC (permalink / raw)
  To: ltp

When hugepage support is enabled in kernel but hardware support is missing,
the last two test cases in shmget02 will fail because kernel will return
ENOENT. Check hardware support and update expected errnos accordingly.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 .../kernel/syscalls/ipc/shmget/shmget02.c     | 33 +++++++++++++------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmget/shmget02.c b/testcases/kernel/syscalls/ipc/shmget/shmget02.c
index effd33799..165a34456 100644
--- a/testcases/kernel/syscalls/ipc/shmget/shmget02.c
+++ b/testcases/kernel/syscalls/ipc/shmget/shmget02.c
@@ -63,15 +63,27 @@ static struct tcase {
 	{&shmkey1, SHM_SIZE, IPC_CREAT | SHM_HUGETLB, 0, 0, ENOMEM}
 };
 
-static int hugetlbfs_supported(void)
+static int get_hugetlb_exp_error(void)
 {
+	long tmp;
 	struct tst_kconfig_var kconfig = {
 		.id = CONFIG_HUGETLBFS,
 		.id_len = sizeof(CONFIG_HUGETLBFS)-1,
 	};
 
 	tst_kconfig_read(&kconfig, 1);
-	return kconfig.choice == 'y';
+
+	if (kconfig.choice != 'y') {
+		tst_res(TINFO, "SHM_HUGETLB not supported by kernel");
+		return EINVAL;
+	}
+
+	if (FILE_LINES_SCANF("/proc/meminfo", "Hugepagesize: %ld", &tmp)) {
+		tst_res(TINFO, "Huge pages not supported by hardware");
+		return ENOENT;
+	}
+
+	return 0;
 }
 
 static void do_test(unsigned int n)
@@ -102,22 +114,23 @@ static void do_test(unsigned int n)
 static void setup(void)
 {
 	struct rlimit rl = { 0, 0 };
+	int hugetlb_errno;
+	unsigned int i;
+
 	shmkey = GETIPCKEY();
 	shmkey1 = GETIPCKEY();
 
 	SAFE_SETRLIMIT(RLIMIT_MEMLOCK, &rl);
 	shm_id = SAFE_SHMGET(shmkey, SHM_SIZE, IPC_CREAT | IPC_EXCL);
 	pw = SAFE_GETPWNAM("nobody");
+	hugetlb_errno = get_hugetlb_exp_error();
 
-	if (!hugetlbfs_supported()) {
-		unsigned int i;
-
-		tst_res(TINFO, "SHM_HUGETLB not supported by kernel");
+	if (!hugetlb_errno)
+		return;
 
-		for (i = 0; i < ARRAY_SIZE(tcases); i++) {
-			if (tcases[i].flags & SHM_HUGETLB)
-				tcases[i].exp_err = EINVAL;
-		}
+	for (i = 0; i < ARRAY_SIZE(tcases); i++) {
+		if (tcases[i].flags & SHM_HUGETLB)
+			tcases[i].exp_err = hugetlb_errno;
 	}
 }
 
-- 
2.33.0


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

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

* Re: [LTP] [PATCH] syscalls/shmget02: Handle missing hugepage support in HW
  2021-09-23 11:04 [LTP] [PATCH] syscalls/shmget02: Handle missing hugepage support in HW Martin Doucha
@ 2021-09-23 12:18 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2021-09-23 12:18 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi!
Applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2021-09-23 12:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 11:04 [LTP] [PATCH] syscalls/shmget02: Handle missing hugepage support in HW Martin Doucha
2021-09-23 12:18 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.