[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <172900658629.1442.13518605210102205088.tip-bot2@tip-bot2>
Date: Tue, 15 Oct 2024 15:36:26 -0000
From: "tip-bot2 for Thomas Gleixner" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Thomas Gleixner <tglx@...utronix.de>,
Zhen Lei <thunder.leizhen@...wei.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: core/debugobjects] debugobjects: Reuse put_objects() on OOM
The following commit has been merged into the core/debugobjects branch of tip:
Commit-ID: 49968cf18154d6391e84c68520149232057ca62c
Gitweb: https://git.kernel.org/tip/49968cf18154d6391e84c68520149232057ca62c
Author: Thomas Gleixner <tglx@...utronix.de>
AuthorDate: Mon, 07 Oct 2024 18:49:58 +02:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Tue, 15 Oct 2024 17:30:31 +02:00
debugobjects: Reuse put_objects() on OOM
Reuse the helper function instead of having a open coded copy.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Reviewed-by: Zhen Lei <thunder.leizhen@...wei.com>
Link: https://lore.kernel.org/all/20241007164913.326834268@linutronix.de
---
lib/debugobjects.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index a3d4c54..2c866d0 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -429,7 +429,6 @@ static void free_object(struct debug_obj *obj)
}
}
-#ifdef CONFIG_HOTPLUG_CPU
static void put_objects(struct hlist_head *list)
{
struct hlist_node *tmp;
@@ -445,6 +444,7 @@ static void put_objects(struct hlist_head *list)
}
}
+#ifdef CONFIG_HOTPLUG_CPU
static int object_cpu_offline(unsigned int cpu)
{
/* Remote access is safe as the CPU is dead already */
@@ -456,31 +456,19 @@ static int object_cpu_offline(unsigned int cpu)
}
#endif
-/*
- * We run out of memory. That means we probably have tons of objects
- * allocated.
- */
+/* Out of memory. Free all objects from hash */
static void debug_objects_oom(void)
{
struct debug_bucket *db = obj_hash;
- struct hlist_node *tmp;
HLIST_HEAD(freelist);
- struct debug_obj *obj;
- unsigned long flags;
- int i;
pr_warn("Out of memory. ODEBUG disabled\n");
- for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
- raw_spin_lock_irqsave(&db->lock, flags);
- hlist_move_list(&db->list, &freelist);
- raw_spin_unlock_irqrestore(&db->lock, flags);
+ for (int i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
+ scoped_guard(raw_spinlock_irqsave, &db->lock)
+ hlist_move_list(&db->list, &freelist);
- /* Now free them */
- hlist_for_each_entry_safe(obj, tmp, &freelist, node) {
- hlist_del(&obj->node);
- free_object(obj);
- }
+ put_objects(&freelist);
}
}
Powered by blists - more mailing lists