All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, andreyknvl@gmail.com,
	chinwen.chang@mediatek.com, dvyukov@google.com, elver@google.com,
	glider@google.com, Kuan-Ying.Lee@mediatek.com,
	linux-mm@kvack.org, mm-commits@vger.kernel.org,
	nicholas.tang@mediatek.com, ryabinin.a.a@gmail.com,
	torvalds@linux-foundation.org, willy@infradead.org,
	yee.lee@mediatek.com
Subject: [patch 01/13] mm: move helper to check slub_debug_enabled
Date: Wed, 14 Jul 2021 21:26:34 -0700	[thread overview]
Message-ID: <20210715042634.Ah06LCkDl%akpm@linux-foundation.org> (raw)
In-Reply-To: <20210714212609.fad116e584ba1194981a6294@linux-foundation.org>

From: Marco Elver <elver@google.com>
Subject: mm: move helper to check slub_debug_enabled

Move the helper to check slub_debug_enabled, so that we can confine the
use of #ifdef outside slub.c as well.

Link: https://lkml.kernel.org/r/20210705103229.8505-2-yee.lee@mediatek.com
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
Suggested-by: Matthew Wilcox <willy@infradead.org>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Chinwen Chang <chinwen.chang@mediatek.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Cc: Nicholas Tang <nicholas.tang@mediatek.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/slab.h |   15 +++++++++++----
 mm/slub.c |   14 --------------
 2 files changed, 11 insertions(+), 18 deletions(-)

--- a/mm/slab.h~mm-move-helper-to-check-slub_debug_enabled
+++ a/mm/slab.h
@@ -216,10 +216,18 @@ DECLARE_STATIC_KEY_FALSE(slub_debug_enab
 #endif
 extern void print_tracking(struct kmem_cache *s, void *object);
 long validate_slab_cache(struct kmem_cache *s);
+static inline bool __slub_debug_enabled(void)
+{
+	return static_branch_unlikely(&slub_debug_enabled);
+}
 #else
 static inline void print_tracking(struct kmem_cache *s, void *object)
 {
 }
+static inline bool __slub_debug_enabled(void)
+{
+	return false;
+}
 #endif
 
 /*
@@ -229,11 +237,10 @@ static inline void print_tracking(struct
  */
 static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags)
 {
-#ifdef CONFIG_SLUB_DEBUG
-	VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS));
-	if (static_branch_unlikely(&slub_debug_enabled))
+	if (IS_ENABLED(CONFIG_SLUB_DEBUG))
+		VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS));
+	if (__slub_debug_enabled())
 		return s->flags & flags;
-#endif
 	return false;
 }
 
--- a/mm/slub.c~mm-move-helper-to-check-slub_debug_enabled
+++ a/mm/slub.c
@@ -120,25 +120,11 @@
  */
 
 #ifdef CONFIG_SLUB_DEBUG
-
 #ifdef CONFIG_SLUB_DEBUG_ON
 DEFINE_STATIC_KEY_TRUE(slub_debug_enabled);
 #else
 DEFINE_STATIC_KEY_FALSE(slub_debug_enabled);
 #endif
-
-static inline bool __slub_debug_enabled(void)
-{
-	return static_branch_unlikely(&slub_debug_enabled);
-}
-
-#else		/* CONFIG_SLUB_DEBUG */
-
-static inline bool __slub_debug_enabled(void)
-{
-	return false;
-}
-
 #endif		/* CONFIG_SLUB_DEBUG */
 
 static inline bool kmem_cache_debug(struct kmem_cache *s)
_


  reply	other threads:[~2021-07-15  4:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15  4:26 incoming Andrew Morton
2021-07-15  4:26 ` Andrew Morton [this message]
2021-07-15  4:26 ` [patch 02/13] kasan: add memzero init for unaligned size at DEBUG Andrew Morton
2021-07-15  4:26 ` [patch 03/13] kasan: fix build by including kernel.h Andrew Morton
2021-07-15  4:26 ` [patch 04/13] Revert "mm/page_alloc: make should_fail_alloc_page() static" Andrew Morton
2021-07-15  4:26 ` [patch 05/13] mm/page_alloc: avoid page allocator recursion with pagesets.lock held Andrew Morton
2021-07-15  4:26 ` [patch 06/13] mm/page_alloc: correct return value when failing at preparing Andrew Morton
2021-07-15  4:26 ` [patch 07/13] mm/page_alloc: further fix __alloc_pages_bulk() return value Andrew Morton
2021-07-15  4:26 ` [patch 08/13] mm: fix the try_to_unmap prototype for !CONFIG_MMU Andrew Morton
2021-07-15  4:26 ` [patch 09/13] lib/test_hmm: remove set but unused page variable Andrew Morton
2021-07-15  4:27 ` [patch 10/13] hfs: add missing clean-up in hfs_fill_super Andrew Morton
2021-07-15  4:27 ` [patch 11/13] hfs: fix high memory mapping in hfs_bnode_read Andrew Morton
2021-07-15  4:27 ` [patch 12/13] hfs: add lock nesting notation to hfs_find_init Andrew Morton
2021-07-15  4:27 ` [patch 13/13] mm/hugetlb: fix refs calculation from unaligned @vaddr Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210715042634.Ah06LCkDl%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Kuan-Ying.Lee@mediatek.com \
    --cc=andreyknvl@gmail.com \
    --cc=chinwen.chang@mediatek.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=linux-mm@kvack.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=nicholas.tang@mediatek.com \
    --cc=ryabinin.a.a@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    --cc=yee.lee@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.