Skip to contentSkip to conversation

+ xarray-add-xas_split-fix.patch added to -mm tree

PATCH [email protected] 2 participants 3 messages Sep 4, 2020 – Sep 10, 2020

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer tree notice
#0 lore raw

The patch titled
Subject: xarray-add-xas_split-fix
has been added to the -mm tree. Its filename is
xarray-add-xas_split-fix.patch

This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/xarray-add-xas_split-fix.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/xarray-add-xas_split-fix.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: xarray-add-xas_split-fix

export xas_split_alloc() to modules

ERROR: modpost: "xas_split_alloc" [lib/test_xarray.ko] undefined!

Cc "Kirill A . Shutemov" <[email protected]>
Cc "Matthew Wilcox (Oracle)" <[email protected]>
Cc Qian Cai <[email protected]>
Cc Song Liu <[email protected]>

---

 lib/xarray.c |    1 +
 1 file changed, 1 insertion(+)
lib/xarray.c renamed from lib/xarray.c~xarray-add-xas_split-fix +1 -0
@@ -1025,6 +1025,7 @@ nomem:
 	xas_destroy(xas);
 	xas_set_err(xas, -ENOMEM);
 }
+EXPORT_SYMBOL_GPL(xas_split_alloc);
 
 /**
  * xas_split() - Split a multi-index entry into smaller entries.

_

Patches currently in -mm which might be from [email protected] are

mm-slub-re-initialize-randomized-freelist-sequence-in-calculate_sizes-fix.patch mm.patch mm-memory_hotplug-introduce-default-phys_to_target_node-implementation-fix.patch device-dax-make-align-a-per-device-property-fix.patch powerpc-mm-move-setting-pte-specific-flags-to-pfn_pte-fix.patch mm-gup-dont-permit-users-to-call-get_user_pages-with-foll_longterm-fix.patch memblock-make-memblock_debug-and-related-functionality-private-fix.patch arch-drivers-replace-for_each_membock-with-for_each_mem_range-fix.patch xarray-add-xa_get_order-fix.patch
xarray-add-xas_split-fix.patch mmhwpoison-refactor-soft_offline_huge_page-and-__soft_offline_page-fix.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix-2.patch fs-binfmt_elf-use-pt_load-p_align-values-for-suitable-start-address-fix.patch linux-next-rejects.patch kernel-forkc-export-kernel_thread-to-modules.patch

maintainer
#1 lore raw
Quoted 2 lines · On Fri, Sep 04, 2020 at 10:23:53AM -0700, [email protected] wrote:

From: Andrew Morton <[email protected]>
Subject: xarray-add-xas_split-fix

Can I ask you to add another -fix patch?

In my testing, I found that splitting a THP that was of order 6 or higher meant that marking it as dirty no longer worked. It was pretty weird. I figured out that what I was doing was setting all the mark bits in the new child node unconditionally (instead of only if the split entry was marked). Once the mark bits were set in the node, calling xa_set_mark() no longer works because it sees the leaf of the tree is already marked, and so it does not walk up the tree to set the mark on the parents. And thus the call to xa_get_mark() never walks _down_ to see the child is marked.

It doesn't affect your tree because it's only used for read-only pages, but in my tree it causes failures once I induce splitting to happen more frequently.

I've included an update to the test-suite which ensures this doesn't happen again (if you apply just the test suite update, it'll cause failures in the test suite).

From edcd692083586b2b218ce3d935429a2349969ba9 Mon Sep 17 00:00:00 2001
From: "Matthew Wilcox (Oracle)" <[email protected]>
Date: Tue, 8 Sep 2020 17:55:22 -0400
Subject: [PATCH] fix xarray split

---
 lib/test_xarray.c | 3 +++
 lib/xarray.c      | 7 ++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
lib/test_xarray.c +3 -0
index 37f7fed3e982..4115979cc716 100644
@@ -1546,6 +1546,9 @@ static void check_split_1(struct xarray *xa, unsigned long index,
 	}
 	XA_BUG_ON(xa, i != 1 << order);
 
+	xa_set_mark(xa, index, XA_MARK_0);
+	XA_BUG_ON(xa, !xa_get_mark(xa, index, XA_MARK_0));
+
 	xa_destroy(xa);
 }
 
lib/xarray.c +4 -3
index 53045e14ad22..9180a7d48315 100644
@@ -973,10 +973,11 @@ static void node_set_marks(struct xa_node *node, unsigned int offset,
 	xa_mark_t mark = XA_MARK_0;
 
 	for (;;) {
-		if (marks & (1 << (__force unsigned int)mark))
+		if (marks & (1 << (__force unsigned int)mark)) {
 			node_set_mark(node, offset, mark);
-		if (child)
-			node_mark_all(child, mark);
+			if (child)
+				node_mark_all(child, mark);
+		}
 		if (mark == XA_MARK_MAX)
 			break;
 		mark_inc(mark);
Signature · 1 line
2.28.0
maintainer
#2 lore raw
Quoted 5 lines · Matthew Wilcox
Quoted 2 lines · On Fri, Sep 04, 2020 at 10:23:53AM -0700, [email protected] wrote:

From: Andrew Morton <[email protected]>
Subject: xarray-add-xas_split-fix

Can I ask you to add another -fix patch?

... updated to also fix the documentation. Thanks, Mauro.

commit 71c3da6f580dc6ce98143d92da768c85638d4518

Author: Matthew Wilcox (Oracle) <[email protected]>
Date:   Tue Sep 8 17:55:22 2020 -0400

fix xarray split

lib/test_xarray.c +3 -0
index 16fe5adcac62..8262c3f05a5d 100644
@@ -1524,6 +1524,9 @@ static void check_split_1(struct xarray *xa, unsigned long index,
 	}
 	XA_BUG_ON(xa, i != 1 << order);
 
+	xa_set_mark(xa, index, XA_MARK_0);
+	XA_BUG_ON(xa, !xa_get_mark(xa, index, XA_MARK_0));
+
 	xa_destroy(xa);
 }
 
lib/xarray.c +16 -5
index ff3652657bd8..b573db455c43 100644
@@ -973,10 +973,11 @@ static void node_set_marks(struct xa_node *node, unsigned int offset,
 	xa_mark_t mark = XA_MARK_0;
 
 	for (;;) {
-		if (marks & (1 << (__force unsigned int)mark))
+		if (marks & (1 << (__force unsigned int)mark)) {
 			node_set_mark(node, offset, mark);
-		if (child)
-			node_mark_all(child, mark);
+			if (child)
+				node_mark_all(child, mark);
+		}
 		if (mark == XA_MARK_MAX)
 			break;
 		mark_inc(mark);
@@ -984,8 +985,18 @@ static void node_set_marks(struct xa_node *node, unsigned int offset,
 }
 
 /**
- * Allocate memory for splitting an entry of @order size into the order
- * stored in the @xas.
+ * xas_split_alloc() - Allocate memory for splitting an entry.
+ * @xas: XArray operation state.
+ * @entry: New entry which will be stored in the array.
+ * @order: New entry order.
+ * @gfp: Memory allocation flags.
+ *
+ * This function should be called before calling xas_split().
+ * If necessary, it will allocate new nodes (and fill them with @entry)
+ * to prepare for the upcoming split of an entry of @order size into
+ * entries of the order stored in the @xas.
+ *
+ * Context: May sleep if @gfp flags permit.
  */
 void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order,
 		gfp_t gfp)