Skip to contentSkip to conversation

Migrating the libhugetlbfs/testcases/truncate_above_4GB.c test

PATCH In review Pavithra 2 participants 2 messages Mar 12 – Mar 23

lore
Share & tools
lore

Pavithra

author
#0 lore raw

PATCH v5 1/1 Migrating the libhugetlbfs/testcases/truncate_above_4GB.c test

Changes in v5:
- Modified code to use FOURGIG instead of truncate_point.

---
 runtest/hugetlb                               |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 .../kernel/mem/hugetlb/hugemmap/hugemmap36.c  | 150 ++++++++++++++++++
 3 files changed, 152 insertions(+)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c
runtest/hugetlb +1 -0
index 0896d3c94..bd40a7a30 100644
@@ -36,6 +36,7 @@ hugemmap30 hugemmap30
 hugemmap31 hugemmap31
 hugemmap32 hugemmap32
 hugemmap34 hugemmap34
+hugemmap36 hugemmap36
 hugemmap05_1 hugemmap05 -m
 hugemmap05_2 hugemmap05 -s
 hugemmap05_3 hugemmap05 -s -m
testcases/kernel/mem/.gitignore +1 -0
index b4455de51..2ddef6bf1 100644
@@ -36,6 +36,7 @@
 /hugetlb/hugemmap/hugemmap31
 /hugetlb/hugemmap/hugemmap32
 /hugetlb/hugemmap/hugemmap34
+/hugetlb/hugemmap/hugemmap36
 /hugetlb/hugeshmat/hugeshmat01
 /hugetlb/hugeshmat/hugeshmat02
 /hugetlb/hugeshmat/hugeshmat03
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c new file +150 -0

150 lines not on this page · raw message

Signature · 5 lines
2.53.0


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

Hi Pavithra,

The following is just a coding style/conventions review, not a logic review. I will leave that for people who worked on huge files.

---------

The subject line should follow LTP conventions:

hugemmap: Add test for hugepage truncation above 4GB

Quoted 2 lines

Changes in v5:
- Modified code to use FOURGIG instead of truncate_point.

Same issue as noted on your previous patch: the commit body should explain *why* the test is being added — what kernel bug it guards against, what it verifies. Changelog entries belong below the --- separator in the patch email, not in the commit body.

Quoted 1 line

+ *[Descripiton]

Missing space after *, "Descripiton" is misspelled, and [Description] is a deprecated label in LTP doc comments. Drop the label entirely — the existing description text below it is fine on its own:

/*\
* At one stage, a misconversion of hugetlb_vmtruncate_list to a
* ...

testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c line 40

Quoted 6 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c new file +6 -0
+static void sigbus_handler_fail(int signum, siginfo_t *si, void *uc)
+{
+	siglongjmp(sig_escape, 17);
+}
+
+static void sigbus_handler_pass(int signum, siginfo_t *si, void *uc)

All three parameters are unused in both handlers, producing a compiler warning for 'uc'. Mark them with LTP_ATTRIBUTE_UNUSED:

static void sigbus_handler_fail(int signum LTP_ATTRIBUTE_UNUSED,
siginfo_t *si LTP_ATTRIBUTE_UNUSED, void *uc LTP_ATTRIBUTE_UNUSED)

Apply the same to sigbus_handler_pass.

testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c line 65

Quoted 4 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c new file +4 -0
+	static long long buggy_offset;
+	...
+	buggy_offset = FOURGIG / (hpage_size / page_size);
+	buggy_offset = (long long)PALIGN(buggy_offset, hpage_size);

buggy_offset is recomputed from global statics, make it public instead.

testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c line 120

Quoted 3 lines
testcases/kernel/mem/hugetlb/hugemmap/hugemmap36.c new file +3 -0
+cleanup:
+	SAFE_MUNMAP(q, 3*hpage_size);
+	SAFE_MUNMAP(p, hpage_size);

p == q + 2*hpage_size, which falls within [q, q + 3*hpage_size). The first SAFE_MUNMAP already covers p's region, so the second call is a redundant double-unmap.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp