mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + maple-tree-add-new-data-structure-fix.patch added to -mm tree
@ 2022-04-19 18:46 Andrew Morton
  2022-04-19 19:07 ` Liam Howlett
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2022-04-19 18:46 UTC (permalink / raw)
  To: mm-commits, yuzhao, liam.howlett, akpm


The patch titled
     Subject: maple_tree: clean up after bulk allocation failure in mas_alloc_nodes()
has been added to the -mm tree.  Its filename is
     maple-tree-add-new-data-structure-fix.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/maple-tree-add-new-data-structure-fix.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/maple-tree-add-new-data-structure-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: Liam Howlett <liam.howlett@oracle.com>
Subject: maple_tree: clean up after bulk allocation failure in mas_alloc_nodes()

Link: https://lkml.kernel.org/r/20220419155055.qf52xpcftqb3r5nj@revolver
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/maple_tree.c |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

--- a/lib/maple_tree.c~maple-tree-add-new-data-structure-fix
+++ a/lib/maple_tree.c
@@ -1206,6 +1206,8 @@ static inline void mas_alloc_nodes(struc
 	unsigned long success = allocated;
 	unsigned int requested = mas_alloc_req(mas);
 	unsigned int count;
+	void **slots = NULL;
+	unsigned int max_req = 0;
 
 	if (!requested)
 		return;
@@ -1214,7 +1216,7 @@ static inline void mas_alloc_nodes(struc
 	if (!allocated || mas->alloc->node_count == MAPLE_ALLOC_SLOTS - 1) {
 		node = (struct maple_alloc *)mt_alloc_one(gfp);
 		if (!node)
-			goto nomem;
+			goto nomem_one;
 
 		if (allocated)
 			node->slot[0] = mas->alloc;
@@ -1226,20 +1228,20 @@ static inline void mas_alloc_nodes(struc
 
 	node = mas->alloc;
 	while (requested) {
-		void **slots = (void **)&node->slot;
-		unsigned int max_req = MAPLE_NODE_SLOTS - 1;
-
+		max_req = MAPLE_NODE_SLOTS - 1;
 		if (node->slot[0]) {
 			unsigned int offset = node->node_count + 1;
 
 			slots = (void **)&node->slot[offset];
 			max_req -= offset;
+		} else {
+			slots = (void **)&node->slot;
 		}
 
-		count = mt_alloc_bulk(gfp, min(requested, max_req),
-				      slots);
+		max_req = min(requested, max_req);
+		count = mt_alloc_bulk(gfp, max_req, slots);
 		if (!count)
-			goto nomem;
+			goto nomem_bulk;
 
 		node->node_count += count;
 		/* zero indexed. */
@@ -1253,7 +1255,11 @@ static inline void mas_alloc_nodes(struc
 	}
 	mas->alloc->total = success;
 	return;
-nomem:
+
+nomem_bulk:
+	/* Clean up potential freed allocations on bulk failure */
+	memset(slots, 0, max_req * sizeof(unsigned long));
+nomem_one:
 	mas_set_alloc_req(mas, requested);
 	if (mas->alloc && !(((unsigned long)mas->alloc & 0x1)))
 		mas->alloc->total = success;
_

Patches currently in -mm which might be from liam.howlett@oracle.com are

radix-tree-test-suite-add-lockdep_is_held-to-header.patch
mips-rename-mt_init-to-mips_mt_init.patch
maple-tree-add-new-data-structure-fix.patch
lib-test_maple_tree-add-testing-for-maple-tree.patch
mmap-change-zeroing-of-maple-tree-in-__vma_adjust.patch
riscv-use-vma-iterator-for-vdso.patch
mm-mmapc-pass-in-mapping-to-__vma_link_file.patch
mglru-vs-maple-tree-fix.patch


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

* Re: + maple-tree-add-new-data-structure-fix.patch added to -mm tree
  2022-04-19 18:46 + maple-tree-add-new-data-structure-fix.patch added to -mm tree Andrew Morton
@ 2022-04-19 19:07 ` Liam Howlett
  0 siblings, 0 replies; 3+ messages in thread
From: Liam Howlett @ 2022-04-19 19:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, yuzhao


Thanks.

This can be squashed into cf5c2c20d811 "Maple Tree: add new data
structure" when sending upstream.

Regards,
Liam

* Andrew Morton <akpm@linux-foundation.org> [220419 14:47]:
> 
> The patch titled
>      Subject: maple_tree: clean up after bulk allocation failure in mas_alloc_nodes()
> has been added to the -mm tree.  Its filename is
>      maple-tree-add-new-data-structure-fix.patch
> 
> This patch should soon appear at
>     https://ozlabs.org/~akpm/mmots/broken-out/maple-tree-add-new-data-structure-fix.patch
> and later at
>     https://ozlabs.org/~akpm/mmotm/broken-out/maple-tree-add-new-data-structure-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: Liam Howlett <liam.howlett@oracle.com>
> Subject: maple_tree: clean up after bulk allocation failure in mas_alloc_nodes()
> 
> Link: https://lkml.kernel.org/r/20220419155055.qf52xpcftqb3r5nj@revolver
> Cc: Yu Zhao <yuzhao@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  lib/maple_tree.c |   22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> --- a/lib/maple_tree.c~maple-tree-add-new-data-structure-fix
> +++ a/lib/maple_tree.c
> @@ -1206,6 +1206,8 @@ static inline void mas_alloc_nodes(struc
>  	unsigned long success = allocated;
>  	unsigned int requested = mas_alloc_req(mas);
>  	unsigned int count;
> +	void **slots = NULL;
> +	unsigned int max_req = 0;
>  
>  	if (!requested)
>  		return;
> @@ -1214,7 +1216,7 @@ static inline void mas_alloc_nodes(struc
>  	if (!allocated || mas->alloc->node_count == MAPLE_ALLOC_SLOTS - 1) {
>  		node = (struct maple_alloc *)mt_alloc_one(gfp);
>  		if (!node)
> -			goto nomem;
> +			goto nomem_one;
>  
>  		if (allocated)
>  			node->slot[0] = mas->alloc;
> @@ -1226,20 +1228,20 @@ static inline void mas_alloc_nodes(struc
>  
>  	node = mas->alloc;
>  	while (requested) {
> -		void **slots = (void **)&node->slot;
> -		unsigned int max_req = MAPLE_NODE_SLOTS - 1;
> -
> +		max_req = MAPLE_NODE_SLOTS - 1;
>  		if (node->slot[0]) {
>  			unsigned int offset = node->node_count + 1;
>  
>  			slots = (void **)&node->slot[offset];
>  			max_req -= offset;
> +		} else {
> +			slots = (void **)&node->slot;
>  		}
>  
> -		count = mt_alloc_bulk(gfp, min(requested, max_req),
> -				      slots);
> +		max_req = min(requested, max_req);
> +		count = mt_alloc_bulk(gfp, max_req, slots);
>  		if (!count)
> -			goto nomem;
> +			goto nomem_bulk;
>  
>  		node->node_count += count;
>  		/* zero indexed. */
> @@ -1253,7 +1255,11 @@ static inline void mas_alloc_nodes(struc
>  	}
>  	mas->alloc->total = success;
>  	return;
> -nomem:
> +
> +nomem_bulk:
> +	/* Clean up potential freed allocations on bulk failure */
> +	memset(slots, 0, max_req * sizeof(unsigned long));
> +nomem_one:
>  	mas_set_alloc_req(mas, requested);
>  	if (mas->alloc && !(((unsigned long)mas->alloc & 0x1)))
>  		mas->alloc->total = success;
> _
> 
> Patches currently in -mm which might be from liam.howlett@oracle.com are
> 
> radix-tree-test-suite-add-lockdep_is_held-to-header.patch
> mips-rename-mt_init-to-mips_mt_init.patch
> maple-tree-add-new-data-structure-fix.patch
> lib-test_maple_tree-add-testing-for-maple-tree.patch
> mmap-change-zeroing-of-maple-tree-in-__vma_adjust.patch
> riscv-use-vma-iterator-for-vdso.patch
> mm-mmapc-pass-in-mapping-to-__vma_link_file.patch
> mglru-vs-maple-tree-fix.patch
> 

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

* + maple-tree-add-new-data-structure-fix.patch added to -mm tree
@ 2022-04-27 17:41 Andrew Morton
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2022-04-27 17:41 UTC (permalink / raw)
  To: mm-commits, sfr, Liam.Howlett, liam.howlett, akpm


The patch titled
     Subject: maple_tree: fix mas_store_prealloc() documentation
has been added to the -mm tree.  Its filename is
     maple-tree-add-new-data-structure-fix.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/maple-tree-add-new-data-structure-fix.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/maple-tree-add-new-data-structure-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: Liam Howlett <liam.howlett@oracle.com>
Subject: maple_tree: fix mas_store_prealloc() documentation

Add gfp flags to the docs

Link: https://lkml.kernel.org/r/20220427141528.4thdegotfheuhfdu@revolver
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/maple_tree.c |    1 +
 1 file changed, 1 insertion(+)

--- a/lib/maple_tree.c~maple-tree-add-new-data-structure-fix
+++ a/lib/maple_tree.c
@@ -5571,6 +5571,7 @@ void mas_store_prealloc(struct ma_state
  * mas_preallocate() - Preallocate enough nodes for a store operation
  * @mas: The maple state
  * @entry: The entry that will be stored
+ * @gfp: The GFP_FLAGS to use for allocations.
  *
  * Return: 0 on success, -ENOMEM if memory could not be allocated.
  */
_

Patches currently in -mm which might be from liam.howlett@oracle.com are

maple-tree-add-new-data-structure-fix.patch


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

end of thread, other threads:[~2022-04-27 17:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 18:46 + maple-tree-add-new-data-structure-fix.patch added to -mm tree Andrew Morton
2022-04-19 19:07 ` Liam Howlett
2022-04-27 17:41 Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).