Commit 17784de6 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'core-debugobjects-2023-05-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull debugobjects fix from Thomas Gleixner:
 "A single fix for debugobjects:

  The recent fix to ensure atomicity of lookup and allocation
  inadvertently broke the pool refill mechanism, so that debugobject
  OOMs now in certain situations. The reason is that the functions which
  got updated no longer invoke debug_objecs_init(), which is now the
  only place to care about refilling the tracking object pool.

  Restore the original behaviour by adding explicit refill opportunities
  to those places"

* tag 'core-debugobjects-2023-05-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  debugobject: Ensure pool refill (again)
parents 6f69c981 0af462f1
...@@ -587,6 +587,16 @@ static struct debug_obj *lookup_object_or_alloc(void *addr, struct debug_bucket ...@@ -587,6 +587,16 @@ static struct debug_obj *lookup_object_or_alloc(void *addr, struct debug_bucket
return NULL; return NULL;
} }
static void debug_objects_fill_pool(void)
{
/*
* On RT enabled kernels the pool refill must happen in preemptible
* context:
*/
if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible())
fill_pool();
}
static void static void
__debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack) __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack)
{ {
...@@ -595,12 +605,7 @@ __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack ...@@ -595,12 +605,7 @@ __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack
struct debug_obj *obj; struct debug_obj *obj;
unsigned long flags; unsigned long flags;
/* debug_objects_fill_pool();
* On RT enabled kernels the pool refill must happen in preemptible
* context:
*/
if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible())
fill_pool();
db = get_bucket((unsigned long) addr); db = get_bucket((unsigned long) addr);
...@@ -685,6 +690,8 @@ int debug_object_activate(void *addr, const struct debug_obj_descr *descr) ...@@ -685,6 +690,8 @@ int debug_object_activate(void *addr, const struct debug_obj_descr *descr)
if (!debug_objects_enabled) if (!debug_objects_enabled)
return 0; return 0;
debug_objects_fill_pool();
db = get_bucket((unsigned long) addr); db = get_bucket((unsigned long) addr);
raw_spin_lock_irqsave(&db->lock, flags); raw_spin_lock_irqsave(&db->lock, flags);
...@@ -894,6 +901,8 @@ void debug_object_assert_init(void *addr, const struct debug_obj_descr *descr) ...@@ -894,6 +901,8 @@ void debug_object_assert_init(void *addr, const struct debug_obj_descr *descr)
if (!debug_objects_enabled) if (!debug_objects_enabled)
return; return;
debug_objects_fill_pool();
db = get_bucket((unsigned long) addr); db = get_bucket((unsigned long) addr);
raw_spin_lock_irqsave(&db->lock, flags); raw_spin_lock_irqsave(&db->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment