mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* incoming
@ 2020-10-03  5:20 Andrew Morton
  2020-10-03  5:21 ` [patch 1/3] mm, slub: restore initial kmem_cache flags Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrew Morton @ 2020-10-03  5:20 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-mm, mm-commits

3 patches, based on d3d45f8220d60a0b2aaaacf8fb2be4e6ffd9008e.

Subsystems affected by this patch series:

  mm/slub
  mm/cma
  scripts

Subsystem: mm/slub

    Eric Farman <farman@linux.ibm.com>:
      mm, slub: restore initial kmem_cache flags

Subsystem: mm/cma

    Joonsoo Kim <iamjoonsoo.kim@lge.com>:
      mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs

Subsystem: scripts

    Eric Biggers <ebiggers@google.com>:
      scripts/spelling.txt: fix malformed entry

 mm/page_alloc.c      |   19 ++++++++++++++++---
 mm/slub.c            |    6 +-----
 scripts/spelling.txt |    2 +-
 3 files changed, 18 insertions(+), 9 deletions(-)


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

* [patch 1/3] mm, slub: restore initial kmem_cache flags
  2020-10-03  5:20 incoming Andrew Morton
@ 2020-10-03  5:21 ` Andrew Morton
  2020-10-03  5:21 ` [patch 2/3] mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs Andrew Morton
  2020-10-03  5:21 ` [patch 3/3] scripts/spelling.txt: fix malformed entry Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2020-10-03  5:21 UTC (permalink / raw)
  To: akpm, cl, farman, iamjoonsoo.kim, keescook, linux-mm, mm-commits,
	penberg, rientjes, torvalds, vbabka

From: Eric Farman <farman@linux.ibm.com>
Subject: mm, slub: restore initial kmem_cache flags

The routine that applies debug flags to the kmem_cache slabs inadvertantly
prevents non-debug flags from being applied to those same objects.  That
is, if slub_debug=<flag>,<slab> is specified, non-debugged slabs will end
up having flags of zero, and the slabs may be unusable.

Fix this by including the input flags for non-matching slabs with the
contents of slub_debug, so that the caches are created as expected
alongside any debugging options that may be requested.  With this, we can
remove the check for a NULL slub_debug_string, since it's covered by the
loop itself.

Link: https://lkml.kernel.org/r/20200930161931.28575-1-farman@linux.ibm.com
Fixes: e17f1dfba37b ("mm, slub: extend slub_debug syntax for multiple blocks")
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Kees Cook <keescook@chromium.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/slub.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

--- a/mm/slub.c~mm-slub-restore-initial-kmem_cache-flags
+++ a/mm/slub.c
@@ -1413,10 +1413,6 @@ slab_flags_t kmem_cache_flags(unsigned i
 	char *next_block;
 	slab_flags_t block_flags;
 
-	/* If slub_debug = 0, it folds into the if conditional. */
-	if (!slub_debug_string)
-		return flags | slub_debug;
-
 	len = strlen(name);
 	next_block = slub_debug_string;
 	/* Go through all blocks of debug options, see if any matches our slab's name */
@@ -1450,7 +1446,7 @@ slab_flags_t kmem_cache_flags(unsigned i
 		}
 	}
 
-	return slub_debug;
+	return flags | slub_debug;
 }
 #else /* !CONFIG_SLUB_DEBUG */
 static inline void setup_object_debug(struct kmem_cache *s,
_

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

* [patch 2/3] mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs
  2020-10-03  5:20 incoming Andrew Morton
  2020-10-03  5:21 ` [patch 1/3] mm, slub: restore initial kmem_cache flags Andrew Morton
@ 2020-10-03  5:21 ` Andrew Morton
  2020-10-03  5:21 ` [patch 3/3] scripts/spelling.txt: fix malformed entry Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2020-10-03  5:21 UTC (permalink / raw)
  To: akpm, aneesh.kumar, iamjoonsoo.kim, linux-mm, mgorman, mhocko,
	mm-commits, torvalds, vbabka

From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs

memalloc_nocma_{save/restore} APIs can be used to skip page allocation on
CMA area, but, there is a missing case and the page on CMA area could be
allocated even if APIs are used.  This patch handles this case to fix the
potential issue.

For now, these APIs are used to prevent long-term pinning on the CMA page.
When the long-term pinning is requested on the CMA page, it is migrated
to the non-CMA page before pinning.  This non-CMA page is allocated by
using memalloc_nocma_{save/restore} APIs.  If APIs doesn't work as
intended, the CMA page is allocated and it is pinned for a long time. 
This long-term pin for the CMA page causes cma_alloc() failure and it
could result in wrong behaviour on the device driver who uses the
cma_alloc().

Missing case is an allocation from the pcplist.  MIGRATE_MOVABLE pcplist
could have the pages on CMA area so we need to skip it if ALLOC_CMA isn't
specified.

Link: https://lkml.kernel.org/r/1601429472-12599-1-git-send-email-iamjoonsoo.kim@lge.com
Fixes: 8510e69c8efe (mm/page_alloc: fix memalloc_nocma_{save/restore} APIs)
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/page_alloc.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

--- a/mm/page_alloc.c~mm-page_alloc-handle-a-missing-case-for-memalloc_nocma_save-restore-apis
+++ a/mm/page_alloc.c
@@ -3367,9 +3367,16 @@ struct page *rmqueue(struct zone *prefer
 	struct page *page;
 
 	if (likely(order == 0)) {
-		page = rmqueue_pcplist(preferred_zone, zone, gfp_flags,
+		/*
+		 * MIGRATE_MOVABLE pcplist could have the pages on CMA area and
+		 * we need to skip it when CMA area isn't allowed.
+		 */
+		if (!IS_ENABLED(CONFIG_CMA) || alloc_flags & ALLOC_CMA ||
+				migratetype != MIGRATE_MOVABLE) {
+			page = rmqueue_pcplist(preferred_zone, zone, gfp_flags,
 					migratetype, alloc_flags);
-		goto out;
+			goto out;
+		}
 	}
 
 	/*
@@ -3381,7 +3388,13 @@ struct page *rmqueue(struct zone *prefer
 
 	do {
 		page = NULL;
-		if (alloc_flags & ALLOC_HARDER) {
+		/*
+		 * order-0 request can reach here when the pcplist is skipped
+		 * due to non-CMA allocation context. HIGHATOMIC area is
+		 * reserved for high-order atomic allocation, so order-0
+		 * request should skip it.
+		 */
+		if (order > 0 && alloc_flags & ALLOC_HARDER) {
 			page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC);
 			if (page)
 				trace_mm_page_alloc_zone_locked(page, order, migratetype);
_

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

* [patch 3/3] scripts/spelling.txt: fix malformed entry
  2020-10-03  5:20 incoming Andrew Morton
  2020-10-03  5:21 ` [patch 1/3] mm, slub: restore initial kmem_cache flags Andrew Morton
  2020-10-03  5:21 ` [patch 2/3] mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs Andrew Morton
@ 2020-10-03  5:21 ` Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2020-10-03  5:21 UTC (permalink / raw)
  To: akpm, ebiggers, linux-mm, mm-commits, torvalds

From: Eric Biggers <ebiggers@google.com>
Subject: scripts/spelling.txt: fix malformed entry

One of the entries has three fields "mistake||correction||correction"
rather than the expected two fields "mistake||correction".  Fix it.

Link: https://lkml.kernel.org/r/20200930234359.255295-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 scripts/spelling.txt |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/scripts/spelling.txt~scripts-spellingtxt-fix-malformed-entry
+++ a/scripts/spelling.txt
@@ -589,7 +589,7 @@ explictly||explicitly
 expresion||expression
 exprimental||experimental
 extened||extended
-exteneded||extended||extended
+exteneded||extended
 extensability||extensibility
 extention||extension
 extenstion||extension
_

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

end of thread, other threads:[~2020-10-03  5:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03  5:20 incoming Andrew Morton
2020-10-03  5:21 ` [patch 1/3] mm, slub: restore initial kmem_cache flags Andrew Morton
2020-10-03  5:21 ` [patch 2/3] mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs Andrew Morton
2020-10-03  5:21 ` [patch 3/3] scripts/spelling.txt: fix malformed entry 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).