+ slab-__gfp_zero-is-incompatible-with-a-constructor.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: slab: __GFP_ZERO is incompatible with a constructor
has been added to the -mm tree.  Its filename is
     slab-__gfp_zero-is-incompatible-with-a-constructor.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/slab-__gfp_zero-is-incompatible-with-a-constructor.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/slab-__gfp_zero-is-incompatible-with-a-constructor.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: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx>
Subject: slab: __GFP_ZERO is incompatible with a constructor

__GFP_ZERO requests that the object be initialised to all-zeroes, while
the purpose of a constructor is to initialise an object to a particular
pattern.  We cannot do both.  Add a warning to catch any users who
mistakenly pass a __GFP_ZERO flag when allocating a slab with a
constructor.

Link: http://lkml.kernel.org/r/20180412191322.GA21205@xxxxxxxxxxxxxxxxxxxxxx
Fixes: d07dbea46405 ("Slab allocators: support __GFP_ZERO in all allocators")
Signed-off-by: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx>
Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>
Acked-by: Vlastimil Babka <vbabka@xxxxxxx>
Acked-by: Michal Hocko <mhocko@xxxxxxxx>
Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/slab.c |    2 ++
 mm/slob.c |    4 +++-
 mm/slub.c |    2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff -puN mm/slab.c~slab-__gfp_zero-is-incompatible-with-a-constructor mm/slab.c
--- a/mm/slab.c~slab-__gfp_zero-is-incompatible-with-a-constructor
+++ a/mm/slab.c
@@ -2665,6 +2665,7 @@ static struct page *cache_grow_begin(str
 				invalid_mask, &invalid_mask, flags, &flags);
 		dump_stack();
 	}
+	WARN_ON_ONCE(cachep->ctor && (flags & __GFP_ZERO));
 	local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK);
 
 	check_irq_off();
@@ -3071,6 +3072,7 @@ static inline void cache_alloc_debugchec
 static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
 				gfp_t flags, void *objp, unsigned long caller)
 {
+	WARN_ON_ONCE(cachep->ctor && (flags & __GFP_ZERO));
 	if (!objp)
 		return objp;
 	if (cachep->flags & SLAB_POISON) {
diff -puN mm/slob.c~slab-__gfp_zero-is-incompatible-with-a-constructor mm/slob.c
--- a/mm/slob.c~slab-__gfp_zero-is-incompatible-with-a-constructor
+++ a/mm/slob.c
@@ -555,8 +555,10 @@ static void *slob_alloc_node(struct kmem
 					    flags, node);
 	}
 
-	if (b && c->ctor)
+	if (b && c->ctor) {
+		WARN_ON_ONCE(flags & __GFP_ZERO);
 		c->ctor(b);
+	}
 
 	kmemleak_alloc_recursive(b, c->size, 1, c->flags, flags);
 	return b;
diff -puN mm/slub.c~slab-__gfp_zero-is-incompatible-with-a-constructor mm/slub.c
--- a/mm/slub.c~slab-__gfp_zero-is-incompatible-with-a-constructor
+++ a/mm/slub.c
@@ -2444,6 +2444,8 @@ static inline void *new_slab_objects(str
 	struct kmem_cache_cpu *c = *pc;
 	struct page *page;
 
+	WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO));
+
 	freelist = get_partial(s, flags, node, c);
 
 	if (freelist)
_

Patches currently in -mm which might be from mawilcox@xxxxxxxxxxxxx are

fix-null-pointer-in-page_cache_tree_insert.patch
slab-__gfp_zero-is-incompatible-with-a-constructor.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux