Skip to contentSkip to conversation

incoming

PATCH New Andrew Morton 1 participant 4 messages Oct 3, 2020

Subsystems (3)
lore
Share & tools
lore

Andrew Morton

author maintainer
#0 lore raw

3 patches, based on d3d45f8220d60a0b2aaaacf8fb2be4e6ffd9008e.

Subsystems affected by this patch series:

mm/slub
mm/cma
scripts

Subsystem: mm/slub

Eric Farman <[email protected]>:
mm, slub: restore initial kmem_cache flags

Subsystem: mm/cma

Joonsoo Kim <[email protected]>:
mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs

Subsystem: scripts

Eric Biggers <[email protected]>:
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(-)
author maintainer
#1 lore raw

PATCH 1/3 mm, slub: restore initial kmem_cache flags

From: Eric Farman <[email protected]>
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.

Fixes e17f1dfba37b ("mm, slub: extend slub_debug syntax for multiple blocks")
Cc Kees Cook <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc David Rientjes <[email protected]>
Cc Joonsoo Kim <[email protected]>

---

 mm/slub.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
mm/slub.c renamed from mm/slub.c~mm-slub-restore-initial-kmem_cache-flags +1 -5
@@ -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,

_

author maintainer
#2 lore raw

PATCH 2/3 mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs

In reply to Andrew Morton

From: Joonsoo Kim <[email protected]>
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.

Fixes 8510e69c8efe (mm/page_alloc: fix memalloc_nocma_{save/restore} APIs)
Cc "Aneesh Kumar K . V" <[email protected]>
Cc Mel Gorman <[email protected]>

---

 mm/page_alloc.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
mm/page_alloc.c renamed from mm/page_alloc.c~mm-page_alloc-handle-a-missing-case-for-memalloc_nocma_save-restore-apis +16 -3
@@ -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);

_

author maintainer
#3 lore raw

PATCH 3/3 scripts/spelling.txt: fix malformed entry

In reply to Andrew Morton

From: Eric Biggers <[email protected]>
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.

---

 scripts/spelling.txt |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/spelling.txt renamed from scripts/spelling.txt~scripts-spellingtxt-fix-malformed-entry +1 -1
@@ -589,7 +589,7 @@ explictly||explicitly
 expresion||expression
 exprimental||experimental
 extened||extended
-exteneded||extended||extended
+exteneded||extended
 extensability||extensibility
 extention||extension
 extenstion||extension

_