Linux-mm Archive on
 help / color / Atom feed
* [patch 010/158] mm/slub.c: clean up validate_slab()
@ 2019-12-01  1:49 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2019-12-01  1:49 UTC (permalink / raw)
  To: akpm, cl,, kirill.shutemov, linux-mm, mm-commits,
	penberg, penguin-kernel, rientjes, torvalds, yuzhao

From: Yu Zhao <>
Subject: mm/slub.c: clean up validate_slab()

The function doesn't need to return any value, and the check can be done
in one pass.

There is a behavior change: before the patch, we stop at the first invalid
free object; after the patch, we stop at the first invalid object, free or
in use.  This shouldn't matter because the original behavior isn't
intended anyway.

Signed-off-by: Yu Zhao <>
Acked-by: Kirill A. Shutemov <>
Cc: Christoph Lameter <>
Cc: Pekka Enberg <>
Cc: David Rientjes <>
Cc: Joonsoo Kim <>
Cc: Tetsuo Handa <>
Cc: Yu Zhao <>
Signed-off-by: Andrew Morton <>

 mm/slub.c |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

--- a/mm/slub.c~mm-clean-up-validate_slab
+++ a/mm/slub.c
@@ -4384,31 +4384,26 @@ static int count_total(struct page *page
-static int validate_slab(struct kmem_cache *s, struct page *page,
+static void validate_slab(struct kmem_cache *s, struct page *page,
 						unsigned long *map)
 	void *p;
 	void *addr = page_address(page);
-	if (!check_slab(s, page) ||
-			!on_freelist(s, page, NULL))
-		return 0;
+	if (!check_slab(s, page) || !on_freelist(s, page, NULL))
+		return;
 	/* Now we know that a valid freelist exists */
 	bitmap_zero(map, page->objects);
 	get_map(s, page, map);
 	for_each_object(p, s, addr, page->objects) {
-		if (test_bit(slab_index(p, s, addr), map))
-			if (!check_object(s, page, p, SLUB_RED_INACTIVE))
-				return 0;
-	}
+		u8 val = test_bit(slab_index(p, s, addr), map) ?
-	for_each_object(p, s, addr, page->objects)
-		if (!test_bit(slab_index(p, s, addr), map))
-			if (!check_object(s, page, p, SLUB_RED_ACTIVE))
-				return 0;
-	return 1;
+		if (!check_object(s, page, p, val))
+			break;
+	}
 static void validate_slab_slab(struct kmem_cache *s, struct page *page,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01  1:49 [patch 010/158] mm/slub.c: clean up validate_slab() akpm

Linux-mm Archive on

Archives are clonable:
	git clone --mirror linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ \
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone