From: Waiman Long <longman@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>
Cc: linux-kernel@vger.kernel.org, Waiman Long <longman@redhat.com>
Subject: [PATCH 1/3] debugobjects: Add ODEBUG_FLAG_NO_ALLOC to disable memory allocation
Date: Wed, 4 Jun 2025 18:09:24 -0400 [thread overview]
Message-ID: <20250604220926.870760-2-longman@redhat.com> (raw)
In-Reply-To: <20250604220926.870760-1-longman@redhat.com>
Some of the objects associated with debug_obj may be handled
in a sensitive context that allowing debug_obj pre-allocation
in debug_objects_fill_pool() may casue deadlock. Add a new flags
parameter to the debug_obj_descr structure as well as adding the new
ODEBUG_FLAG_NO_ALLOC flag to enable us to disallow memory allocation
for those types of objects.
Signed-off-by: Waiman Long <longman@redhat.com>
---
include/linux/debugobjects.h | 6 ++++++
lib/debugobjects.c | 10 +++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/include/linux/debugobjects.h b/include/linux/debugobjects.h
index 8b95545e7924..a058c7dba898 100644
--- a/include/linux/debugobjects.h
+++ b/include/linux/debugobjects.h
@@ -41,6 +41,7 @@ struct debug_obj {
* struct debug_obj_descr - object type specific debug description structure
*
* @name: name of the object typee
+ * @flags: debug object flags
* @debug_hint: function returning address, which have associated
* kernel symbol, to allow identify the object
* @is_static_object: return true if the obj is static, otherwise return false
@@ -58,6 +59,7 @@ struct debug_obj {
*/
struct debug_obj_descr {
const char *name;
+ unsigned long flags;
void *(*debug_hint)(void *addr);
bool (*is_static_object)(void *addr);
bool (*fixup_init)(void *addr, enum debug_obj_state state);
@@ -67,6 +69,10 @@ struct debug_obj_descr {
bool (*fixup_assert_init)(void *addr, enum debug_obj_state state);
};
+enum debug_obj_flags {
+ ODEBUG_FLAG_NO_ALLOC = 0x1, /* Disallow debug object pre-allocation */
+};
+
#ifdef CONFIG_DEBUG_OBJECTS
extern void debug_object_init (void *addr, const struct debug_obj_descr *descr);
extern void
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 7f50c4480a4e..52bc77b41f48 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -694,7 +694,7 @@ static struct debug_obj *lookup_object_or_alloc(void *addr, struct debug_bucket
return NULL;
}
-static void debug_objects_fill_pool(void)
+static void debug_objects_fill_pool(bool no_alloc)
{
if (!static_branch_likely(&obj_cache_enabled))
return;
@@ -705,7 +705,7 @@ static void debug_objects_fill_pool(void)
/* Try reusing objects from obj_to_free_list */
fill_pool_from_freelist();
- if (likely(!pool_should_refill(&pool_global)))
+ if (likely(!pool_should_refill(&pool_global) || no_alloc))
return;
/*
@@ -734,7 +734,7 @@ __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack
struct debug_bucket *db;
unsigned long flags;
- debug_objects_fill_pool();
+ debug_objects_fill_pool(descr->flags & ODEBUG_FLAG_NO_ALLOC);
db = get_bucket((unsigned long) addr);
@@ -811,7 +811,7 @@ int debug_object_activate(void *addr, const struct debug_obj_descr *descr)
if (!debug_objects_enabled)
return 0;
- debug_objects_fill_pool();
+ debug_objects_fill_pool(descr->flags & ODEBUG_FLAG_NO_ALLOC);
db = get_bucket((unsigned long) addr);
@@ -1000,7 +1000,7 @@ void debug_object_assert_init(void *addr, const struct debug_obj_descr *descr)
if (!debug_objects_enabled)
return;
- debug_objects_fill_pool();
+ debug_objects_fill_pool(descr->flags & ODEBUG_FLAG_NO_ALLOC);
db = get_bucket((unsigned long) addr);
--
2.49.0
next prev parent reply other threads:[~2025-06-04 22:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-04 22:09 [PATCH 0/3] timers: Disable memory pre-allocation of timer debug objects Waiman Long
2025-06-04 22:09 ` Waiman Long [this message]
2025-06-04 22:09 ` [PATCH 2/3] debugobjects: Show the state of debug_objects_enabled Waiman Long
2025-06-05 22:51 ` kernel test robot
2025-06-04 22:09 ` [PATCH 3/3] timers: Disable memory pre-allocation of timer debug objects Waiman Long
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=20250604220926.870760-2-longman@redhat.com \
--to=longman@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®