Skip to contentSkip to conversation

Small docparser fixes

PATCH New Cyril Hrubis 2 participants 13 messages Dec 16, 2020 – Jan 5, 2021

lore
Share & tools
lore
#0 lore raw

cover Small docparser fixes

Cyril Hrubis (5):
docparse/docparse: Warn on truncated docstring doc_parse/data_storage: Bump the array max size docparse/docparse: Eat only first whitespace for comment block syscalls/abort: Remove second space before description text syscalls/move_pages12: Add one more kernel git hash

 docparse/data_storage.h                       |  2 +-
 docparse/docparse.c                           |  9 ++--
 testcases/kernel/syscalls/abort/abort01.c     |  3 +-
 .../kernel/syscalls/move_pages/move_pages12.c | 52 ++++++++++++-------
 4 files changed, 40 insertions(+), 26 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/5 docparse/docparse: Warn on truncated docstring

---
 docparse/docparse.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
docparse/docparse.c +4 -3
index 22c5c6f2c..702820757 100644
@@ -12,6 +12,8 @@
 
 #include "data_storage.h"
 
+#define WARN(str) fprintf(stderr, "WARNING: " str "\n")
+
 static void oneline_comment(FILE *f)
 {
 	int c;
@@ -52,7 +54,8 @@ static void multiline_comment(FILE *f, struct data_node *doc)
 				struct data_node *line;
 				buf[bufp] = 0;
 				line = data_node_string(eat_asterisk_space(buf));
-				data_node_array_add(doc, line);
+				if (data_node_array_add(doc, line))
+					WARN("doc string comment truncated");
 				bufp = 0;
 				continue;
 			}
@@ -194,8 +197,6 @@ exit:
 	return buf;
 }
 
-#define WARN(str) fprintf(stderr, str "\n")
-
 static int parse_array(FILE *f, struct data_node *node)
 {
 	const char *token;
Signature · 1 line
2.26.2
#3 lore raw

PATCH 2/5 doc_parse/data_storage: Bump the array max size

In reply to Cyril Hrubis

Bump the array size to 100 from 20 for now. I will rewrite the code to reallocate the array if needed later on.

At least now we won't have longer description comments cut in half.

---
 docparse/data_storage.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
docparse/data_storage.h +1 -1
index 1a9265f92..ef420c08f 100644
@@ -64,7 +64,7 @@ static inline struct data_node *data_node_string(const char *string)
 	return node;
 }
 
-#define MAX_ELEMS 20
+#define MAX_ELEMS 100
 
 static inline struct data_node *data_node_hash(void)
 {
Signature · 1 line
2.26.2
#4 lore raw

PATCH 2/5 doc_parse/data_storage: Bump the array max size

Quoted 4 lines

Bump the array size to 100 from 20 for now. I will rewrite the code to reallocate the array if needed later on.

At least now we won't have longer description comments cut in half.

+1

Kind regards,
Petr

#5 lore raw

PATCH 3/5 docparse/docparse: Eat only first whitespace for comment block

In reply to Cyril Hrubis

Since we decided that the comment block is formatted in asciidoc we need the whitespaces since they are part of the format, e.g. literal blocks.

---
 docparse/docparse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
docparse/docparse.c +1 -1
index 702820757..9f617c8bb 100644
@@ -31,7 +31,7 @@ static const char *eat_asterisk_space(const char *c)
 		i++;
 
 	if (c[i] == '*') {
-		while (isspace(c[i+1]))
+		if (isspace(c[i+1]))
 			i++;
 		return &c[i+1];
 	}
Signature · 1 line
2.26.2
#6 lore raw

PATCH 3/5 docparse/docparse: Eat only first whitespace for comment block

Quoted 2 lines

Since we decided that the comment block is formatted in asciidoc we need the whitespaces since they are part of the format, e.g. literal blocks.

Makes sense.

Kind regards,
Petr

#7 lore raw

PATCH 4/5 syscalls/abort: Remove second space before description text

In reply to Cyril Hrubis

This seems to be the only case where the change to remove only first whitespace cause the test description to produce literal block unexpectedly.

---
 testcases/kernel/syscalls/abort/abort01.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/abort/abort01.c +2 -1
index b93324b34..ba89cc524 100644
@@ -9,7 +9,8 @@
 
 /*\
  * [DESCRIPTION]
- *  Checks that process which called abort() gets killed by SIGIOT and dumps core.
+ *
+ * Checks that process which called abort() gets killed by SIGIOT and dumps core.
  *
  * [ALGORITHM]
  *  - Fork child.
Signature · 1 line
2.26.2
#8 lore raw

PATCH 4/5 syscalls/abort: Remove second space before description text

Quoted 3 lines

This seems to be the only case where the change to remove only first whitespace cause the test description to produce literal block unexpectedly.

Hopefully :).

#9 lore raw

PATCH 5/5 syscalls/move_pages12: Add one more kernel git hash

In reply to Cyril Hrubis

+ Reformat the comment to asciidoc

---
 .../kernel/syscalls/move_pages/move_pages12.c | 52 ++++++++++++-------
 1 file changed, 32 insertions(+), 20 deletions(-)
testcases/kernel/syscalls/move_pages/move_pages12.c +32 -20
index c906acbe3..d209426c7 100644
@@ -7,16 +7,17 @@
  *  Ported: Yang Xu <[email protected]>
  */
 
-/*
- * Description:
+/*\
+ * [DESCRIPTION]
+ *
+ * *Test 1*
  *
- * Test #1:
- *  This is a regression test for the race condition between move_pages()
- *  and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
- *  for hugepages internally and tries to get its refcount without
- *  preventing concurrent freeing.
+ * This is a regression test for the race condition between move_pages()
+ * and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
+ * for hugepages internally and tries to get its refcount without
+ * preventing concurrent freeing.
  *
- *  This test can crash the buggy kernel, and the bug was fixed in:
+ * This test can crash the buggy kernel, and the bug was fixed in:
  *
  *   commit e66f17ff71772b209eed39de35aaa99ba819c93d
  *   Author: Naoya Horiguchi <[email protected]>
@@ -24,25 +25,25 @@
  *
  *   mm/hugetlb: take page table lock in follow_huge_pmd()
  *
- *  Test #2:
- *   #2.1:
- *   This is a regression test for the race condition, where move_pages()
- *   and soft offline are called on a single hugetlb page concurrently.
+ * *Test 2.1*
  *
- *   This bug can crash the buggy kernel, and was fixed by:
+ * This is a regression test for the race condition, where move_pages()
+ * and soft offline are called on a single hugetlb page concurrently.
+ *
+ * This test can crash the buggy kernel, and was fixed by:
  *
  *   commit c9d398fa237882ea07167e23bcfc5e6847066518
  *   Author: Naoya Horiguchi <[email protected]>
  *   Date:   Fri Mar 31 15:11:55 2017 -0700
  *
- *   mm, hugetlb: use pte_present() instead of pmd_present() in
- *   follow_huge_pmd()
+ *   mm, hugetlb: use pte_present() instead of pmd_present() in follow_huge_pmd()
+ *
+ * *Test 2.2*
  *
- *   #2.2:
- *   This is also a regression test for an race condition causing SIGBUS
- *   in hugepage migration/fault.
+ * This is also a regression test for an race condition causing SIGBUS
+ * in hugepage migration/fault.
  *
- *   This bug was fixed by:
+ * This bug was fixed by:
  *
  *   commit 4643d67e8cb0b3536ef0ab5cddd1cedc73fa14ad
  *   Author: Mike Kravetz <[email protected]>
@@ -50,7 +51,17 @@
  *
  *   hugetlbfs: fix hugetlb page migration/fault race causing SIGBUS
  *
- */
+ * *Test 2.3*
+ *
+ * The madvise() in the do_soft_online() was also triggering cases where soft
+ * online returned EIO when page migration failed, which was fixed in:
+ *
+ *    commit 3f4b815a439adfb8f238335612c4b28bc10084d8
+ *    Author: Oscar Salvador <[email protected]>
+ *    Date:   Mon Dec 14 19:11:51 2020 -0800
+ *
+ *    mm,hwpoison: return -EBUSY when migration fails
+\*/
 
 #include <errno.h>
 #include <unistd.h>
@@ -334,6 +345,7 @@ static struct tst_test test = {
 		{"linux-git", "e66f17ff7177"},
 		{"linux-git", "c9d398fa2378"},
 		{"linux-git", "4643d67e8cb0"},
+		{"linux-git", "3f4b815a439a"},
 		{}
 	}
 };
Signature · 1 line
2.26.2
#10 lore raw

PATCH 5/5 syscalls/move_pages12: Add one more kernel git hash

Quoted 1 line

+ Reformat the comment to asciidoc

Thanks!

...

Quoted 12 lines
testcases/kernel/syscalls/move_pages/move_pages12.c +4 -7
-/*
- * Description:
+/*\
+ * [DESCRIPTION]
+ *
+ * *Test 1*
  *
- * Test #1:
- *  This is a regression test for the race condition between move_pages()
- *  and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
- *  for hugepages internally and tries to get its refcount without
- *  preventing concurrent freeing.

testcases/kernel/syscalls/move_pages/move_pages12.c line 23

Quoted 10 lines
testcases/kernel/syscalls/move_pages/move_pages12.c +5 -1
+ * This is a regression test for the race condition between move_pages()
+ * and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
+ * for hugepages internally and tries to get its refcount without
+ * preventing concurrent freeing.
  *
- *  This test can crash the buggy kernel, and the bug was fixed in:
+ * This test can crash the buggy kernel, and the bug was fixed in:
  *
  *   commit e66f17ff71772b209eed39de35aaa99ba819c93d
  *   Author: Naoya Horiguchi <[email protected]>

I wonder if we should format "commit XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" as
link to Linus' tree (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX).

Kind regards,
Petr

#11 lore raw

PATCH 5/5 syscalls/move_pages12: Add one more kernel git hash

Hi!

Quoted 1 line

Patchset pushed, thanks for the review.

Quoted 18 lines

...

Quoted 17 lines
testcases/kernel/syscalls/move_pages/move_pages12.c +8 -7
-/*
- * Description:
+/*\
+ * [DESCRIPTION]
+ *
+ * *Test 1*
  *
- * Test #1:
- *  This is a regression test for the race condition between move_pages()
- *  and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
- *  for hugepages internally and tries to get its refcount without
- *  preventing concurrent freeing.
+ * This is a regression test for the race condition between move_pages()
+ * and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
+ * for hugepages internally and tries to get its refcount without
+ * preventing concurrent freeing.
  *
Quoted 8 lines
Quoted 5 lines

- * This test can crash the buggy kernel, and the bug was fixed in:
+ * This test can crash the buggy kernel, and the bug was fixed in:
*
* commit e66f17ff71772b209eed39de35aaa99ba819c93d
* Author: Naoya Horiguchi <[email protected]>

I wonder if we should format "commit XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" as
link to Linus' tree (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX).

Well we do have links in the tags anyways so I think that it's a bit more readable as it is.

Signature · 2 lines
Cyril Hrubis
[email protected]
#12 lore raw

PATCH 5/5 syscalls/move_pages12: Add one more kernel git hash

Hi Cyril,

Quoted 4 lines

Hi!

Quoted 1 line

Patchset pushed, thanks for the review.

Great, thanks!

Quoted 27 lines
Quoted 18 lines

...

Quoted 17 lines
testcases/kernel/syscalls/move_pages/move_pages12.c +8 -7
-/*
- * Description:
+/*\
+ * [DESCRIPTION]
+ *
+ * *Test 1*
  *
- * Test #1:
- *  This is a regression test for the race condition between move_pages()
- *  and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
- *  for hugepages internally and tries to get its refcount without
- *  preventing concurrent freeing.
+ * This is a regression test for the race condition between move_pages()
+ * and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
+ * for hugepages internally and tries to get its refcount without
+ * preventing concurrent freeing.
  *
Quoted 8 lines
Quoted 5 lines

- * This test can crash the buggy kernel, and the bug was fixed in:
+ * This test can crash the buggy kernel, and the bug was fixed in:
*
* commit e66f17ff71772b209eed39de35aaa99ba819c93d
* Author: Naoya Horiguchi <[email protected]>

I wonder if we should format "commit XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" as
link to Linus' tree (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX).

Quoted 2 lines

Well we do have links in the tags anyways so I think that it's a bit more readable as it is.

I meant in the output (pdf, html) the text would be the same but become link to Linus' tree (instead of being a plain text).

But that's really minor.

Kind regards,
Petr