All of lore.kernel.org
 help / color / mirror / Atom feed
* + debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch added to mm-nonmm-unstable branch
@ 2026-03-11 17:48 Andrew Morton
  2026-03-25 17:03 ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2026-03-11 17:48 UTC (permalink / raw)
  To: mm-commits, tglx, bblock, akpm


The patch titled
     Subject: debugobjects: allow to configure the amount of pre-allocated objects
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Benjamin Block <bblock@linux.ibm.com>
Subject: debugobjects: allow to configure the amount of pre-allocated objects
Date: Wed, 25 Feb 2026 17:05:08 +0100

To debug object operations a certain amount of metadata has to be kept per
object that is tracked.  During boot a static amount of pre- allocated
objects is set aside to be used for this task until such a time a dynamic
allocator can be used.  Once a dynamic allocator can be used an initial
amount of objects is pre-allocated to be used when needed.

So far the amount of such initially statically, and later dynamically
pre-allocated objects is set fixed at `64 * 16 = 1024`.  But depending on
the system this might not be enough during boot, when only the static
amount of pre-allocated objects is used; and once this happens ODEBUG
disables itself permanently.

On s390 it has been observed, that even with 16384 such pre-allocated
objects ODEBUG would still be disabled during boot.

Similarly to other debug features like KMEMLEAK add a Kconfig option
CONFIG_DEBUG_OBJECTS_POOL_SIZE_SHIFT that allows to increase the amount of
pre-allocated objects (in both the static and later dynamic cases).  Use
it as exponential, rather than linear value to allow for head-room to grow
into once set in a configuration.

The calculation is done as such:
    N_OBJECTS = 2^DEBUG_OBJECTS_POOL_SIZE_SHIFT * N_BATCH

By default it is set to 6, so the actual amount is unchanged, unless
the new options is changed:
    N_OBJECTS = 2^6 * 16
    N_OBJECTS = 1024

For the previously mentioned observations on s390 it was necessary to
increase the option to 11 in order to have enough space during boot.

Link: https://lkml.kernel.org/r/70f06193b3c3581802710ebcef74671e50c4c979.1772035270.git.bblock@linux.ibm.com
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Cc: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/Kconfig.debug  |   32 ++++++++++++++++++++++++++++++++
 lib/debugobjects.c |   15 +++++++++++++--
 2 files changed, 45 insertions(+), 2 deletions(-)

--- a/lib/debugobjects.c~debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects
+++ a/lib/debugobjects.c
@@ -22,11 +22,18 @@
 #define ODEBUG_HASH_BITS	14
 #define ODEBUG_HASH_SIZE	(1 << ODEBUG_HASH_BITS)
 
-/* Must be power of two */
+/*
+ * Must be power of two.
+ * Please change Kconfig help text of DEBUG_OBJECTS_POOL_SIZE_SHIFT when
+ * changed.
+ */
 #define ODEBUG_BATCH_SIZE	16
 
+#define ODEBUG_POOL_SHIFT	CONFIG_DEBUG_OBJECTS_POOL_SIZE_SHIFT
+static_assert(ODEBUG_POOL_SHIFT >= 0);
+
 /* Initial values. Must all be a multiple of batch size */
-#define ODEBUG_POOL_SIZE	(64 * ODEBUG_BATCH_SIZE)
+#define ODEBUG_POOL_SIZE	((1 << ODEBUG_POOL_SHIFT) * ODEBUG_BATCH_SIZE)
 #define ODEBUG_POOL_MIN_LEVEL	(ODEBUG_POOL_SIZE / 4)
 
 #define ODEBUG_POOL_PERCPU_SIZE	(8 * ODEBUG_BATCH_SIZE)
@@ -586,6 +593,10 @@ static void debug_objects_oom(void)
 	struct debug_bucket *db = obj_hash;
 	HLIST_HEAD(freelist);
 
+	/*
+	 * Please change Kconfig help text of DEBUG_OBJECTS_POOL_SIZE_SHIFT
+	 * when changed.
+	 */
 	pr_warn("Out of memory. ODEBUG disabled\n");
 
 	for (int i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
--- a/lib/Kconfig.debug~debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects
+++ a/lib/Kconfig.debug
@@ -812,6 +812,38 @@ config DEBUG_OBJECTS_PERCPU_COUNTER
 	  percpu counter routines to track the life time of percpu counter
 	  objects and validate the percpu counter operations.
 
+config DEBUG_OBJECTS_POOL_SIZE_SHIFT
+	int "Metadata objects pool size"
+	depends on DEBUG_OBJECTS
+	range 0 21
+	default 6
+	help
+	  To debug object operations a certain amount of metadata has to be
+	  kept per object that is tracked. During boot a static amount of pre-
+	  allocated objects is set aside to be used for this task until such a
+	  time a dynamic allocator can be used. Once a dynamic allocator can be
+	  used an initial amount of objects is pre-allocated to be used when
+	  needed.
+
+	  This option sets the amount of both: the amount of initially
+	  statically allocated objects; and later the amount of dynamically
+	  pre-allocated objects. It is used as exponent to the power of 2,
+	  multiplied by the batch size used to set how many objects are move
+	  between pools at once.
+
+	  For example, when left at the default of 6:
+	      N_OBJECTS = 2^DEBUG_OBJECTS_POOL_SIZE_SHIFT * N_BATCH
+	      N_OBJECTS = 2^6 * 16
+	      N_OBJECTS = 1024
+	  By increasing the option by 1, you double the amount of objects.
+
+	  An indication that you need to increase this option is that during
+	  boot you see messages like this:
+	      ODEBUG: Out of memory. ODEBUG disabled
+
+	  If in doubt, leave the default.
+
+
 config DEBUG_OBJECTS_ENABLE_DEFAULT
 	int "debug_objects bootup default value (0-1)"
 	range 0 1
_

Patches currently in -mm which might be from bblock@linux.ibm.com are

debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: + debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch added to mm-nonmm-unstable branch
  2026-03-11 17:48 + debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch added to mm-nonmm-unstable branch Andrew Morton
@ 2026-03-25 17:03 ` Thomas Gleixner
  2026-03-25 18:55   ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2026-03-25 17:03 UTC (permalink / raw)
  To: Andrew Morton, mm-commits, bblock, akpm

Andrew!

On Wed, Mar 11 2026 at 10:48, Andrew Morton wrote:
> The patch titled
>      Subject: debugobjects: allow to configure the amount of pre-allocated objects
> has been added to the -mm mm-nonmm-unstable branch.  Its filename is
>      debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch

Can you please drop this. The underlying problem is not explained at
all and the question I asked vs. deferred page init is not answered.

Thanks

        tglx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: + debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch added to mm-nonmm-unstable branch
  2026-03-25 17:03 ` Thomas Gleixner
@ 2026-03-25 18:55   ` Andrew Morton
  2026-03-26  9:46     ` Benjamin Block
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2026-03-25 18:55 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: mm-commits, bblock

On Wed, 25 Mar 2026 18:03:55 +0100 Thomas Gleixner <tglx@kernel.org> wrote:

> Andrew!
> 
> On Wed, Mar 11 2026 at 10:48, Andrew Morton wrote:
> > The patch titled
> >      Subject: debugobjects: allow to configure the amount of pre-allocated objects
> > has been added to the -mm mm-nonmm-unstable branch.  Its filename is
> >      debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch
> 
> Can you please drop this. The underlying problem is not explained at
> all and the question I asked vs. deferred page init is not answered.
> 

Yep, no probs, I agree that this isn't the one.

Benjamin, please do pursue this - the issue is real and has been around
for a long time!


btw, I was retaining this in mm.git in a permaparked state, with a
note-to-self.  So I had no plan to upstream it until everything is
sorted, or a replacement is available.  I do hold onto things for too
long, to get them more testing and to keep myself a bit focussed on the
issue.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: + debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch added to mm-nonmm-unstable branch
  2026-03-25 18:55   ` Andrew Morton
@ 2026-03-26  9:46     ` Benjamin Block
  2026-03-26 12:00       ` Thomas Gleixner
  2026-03-26 17:15       ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Benjamin Block @ 2026-03-26  9:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Thomas Gleixner, mm-commits

On Wed, Mar 25, 2026 at 11:55:27AM -0700, Andrew Morton wrote:
> On Wed, 25 Mar 2026 18:03:55 +0100 Thomas Gleixner <tglx@kernel.org> wrote:
> 
> > Andrew!
> > 
> > On Wed, Mar 11 2026 at 10:48, Andrew Morton wrote:
> > > The patch titled
> > >      Subject: debugobjects: allow to configure the amount of pre-allocated objects
> > > has been added to the -mm mm-nonmm-unstable branch.  Its filename is
> > >      debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch
> > 
> > Can you please drop this. The underlying problem is not explained at
> > all and the question I asked vs. deferred page init is not answered.
> > 
> 
> Yep, no probs, I agree that this isn't the one.
> 
> Benjamin, please do pursue this - the issue is real and has been around
> for a long time!

I'll get back to you both; I was out for a couple of days :)

-- 
Best Regards, Benjamin Block        /        Linux on IBM Z Kernel Development
IBM Deutschland Research & Development GmbH    /   https://www.ibm.com/privacy
Vors. Aufs.-R.: Wolfgang Wendt         /        Geschäftsführung: David Faller
Sitz der Ges.: Ehningen     /     Registergericht: AmtsG Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: + debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch added to mm-nonmm-unstable branch
  2026-03-26  9:46     ` Benjamin Block
@ 2026-03-26 12:00       ` Thomas Gleixner
  2026-03-26 17:15       ` Andrew Morton
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Gleixner @ 2026-03-26 12:00 UTC (permalink / raw)
  To: Benjamin Block, Andrew Morton; +Cc: mm-commits

On Thu, Mar 26 2026 at 10:46, Benjamin Block wrote:
> On Wed, Mar 25, 2026 at 11:55:27AM -0700, Andrew Morton wrote:
>> On Wed, 25 Mar 2026 18:03:55 +0100 Thomas Gleixner <tglx@kernel.org> wrote:
>> > Can you please drop this. The underlying problem is not explained at
>> > all and the question I asked vs. deferred page init is not answered.
>> > 
>> 
>> Yep, no probs, I agree that this isn't the one.
>> 
>> Benjamin, please do pursue this - the issue is real and has been around
>> for a long time!
>
> I'll get back to you both; I was out for a couple of days :)

No problem

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: + debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch added to mm-nonmm-unstable branch
  2026-03-26  9:46     ` Benjamin Block
  2026-03-26 12:00       ` Thomas Gleixner
@ 2026-03-26 17:15       ` Andrew Morton
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2026-03-26 17:15 UTC (permalink / raw)
  To: Benjamin Block; +Cc: Thomas Gleixner, mm-commits

On Thu, 26 Mar 2026 10:46:26 +0100 Benjamin Block <bblock@linux.ibm.com> wrote:

> On Wed, Mar 25, 2026 at 11:55:27AM -0700, Andrew Morton wrote:
> > On Wed, 25 Mar 2026 18:03:55 +0100 Thomas Gleixner <tglx@kernel.org> wrote:
> > 
> > > Andrew!
> > > 
> > > On Wed, Mar 11 2026 at 10:48, Andrew Morton wrote:
> > > > The patch titled
> > > >      Subject: debugobjects: allow to configure the amount of pre-allocated objects
> > > > has been added to the -mm mm-nonmm-unstable branch.  Its filename is
> > > >      debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch
> > > 
> > > Can you please drop this. The underlying problem is not explained at
> > > all and the question I asked vs. deferred page init is not answered.
> > > 
> > 
> > Yep, no probs, I agree that this isn't the one.
> > 
> > Benjamin, please do pursue this - the issue is real and has been around
> > for a long time!
> 
> I'll get back to you both; I was out for a couple of days :)

Thanks.  It's been this way for a very long time, so there's no hurry
at all.  And we can backport any fix into -stable kernels if the issue
is determined to be serious enough.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-26 17:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 17:48 + debugobjects-allow-to-configure-the-amount-of-pre-allocated-objects.patch added to mm-nonmm-unstable branch Andrew Morton
2026-03-25 17:03 ` Thomas Gleixner
2026-03-25 18:55   ` Andrew Morton
2026-03-26  9:46     ` Benjamin Block
2026-03-26 12:00       ` Thomas Gleixner
2026-03-26 17:15       ` Andrew Morton

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.