mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhen Lei <thunder.leizhen@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	<linux-kernel@vger.kernel.org>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Subject: [PATCH v2 4/6] debugobjects: Don't start fill if there are remaining nodes locally
Date: Wed, 4 Sep 2024 21:39:42 +0800	[thread overview]
Message-ID: <20240904133944.2124-5-thunder.leizhen@huawei.com> (raw)
In-Reply-To: <20240904133944.2124-1-thunder.leizhen@huawei.com>

If the conditions for starting fill are met, it means that all cores that
call fill() later are blocked until the first core completes the fill
operation. But obviously, for a core that has free nodes locally, it does
not need to be blocked(see below for why). This is good in stress
situations.

1. In the case of no nesting, a core uses only one node at a time. As long
   as there is a local node, there is no need to use the free node in
   obj_pool.
2. In the case of nesting depth is one, nodes in obj_pool need to be used
   only when there is only one local node.
   #define ODEBUG_POOL_PERCPU_SIZE      64
   #define ODEBUG_BATCH_SIZE            16
   Assume that when nested, the probability of percpu_obj_pool having each
   number of nodes is the same. The probability of only one node is less
   than 1/17=6%. Assuming the probability of nesting is 5%, that's a
   pretty high estimate. Then the probability of using obj_pool is
   6% * 5% = 0.3%. In other words, a 333-core environment produces only
   one core to compete for obj_pool.
   #define ODEBUG_POOL_MIN_LEVEL        256
   #define ODEBUG_BATCH_SIZE            16
   But we can tolerate "256 / (16 + 1)" = 15 cores competing at the same
   time.
3. In the case of nesting depth more than one, the probability is lower
   and negligible.
   Nesting Depth=2: "2/17 * 5% * 5%" = 0.03%
   Nesting Depth=3: "3/17 * 5% * 5% * 5%" = 0.002%

However, to ensure sufficient reliability, obj_pool is not filled only
when there are more than two local nodes, reduce the probability of
problems to the impossible.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 lib/debugobjects.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 7a8ccc94cb037ba..4f64b5d4329c27d 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -131,6 +131,16 @@ static void fill_pool(void)
 	struct debug_obj *obj;
 	unsigned long flags;
 
+	/*
+	 * The upper-layer function uses only one node at a time. If there are
+	 * more than two local nodes, it means that even if nesting occurs, it
+	 * doesn't matter. The probability of nesting depth >= 2 is extremely
+	 * low, and the number of global free nodes guarded by
+	 * debug_objects_pool_min_level is adequate.
+	 */
+	if (likely(obj_cache) && this_cpu_read(percpu_obj_pool.obj_free) >= 2)
+		return;
+
 	if (likely(READ_ONCE(obj_pool_free) >= debug_objects_pool_min_level))
 		return;
 
-- 
2.34.1


  parent reply	other threads:[~2024-09-04 13:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 13:39 [PATCH v2 0/6] debugobjects: Do some minor optimizations, fixes and cleaups Zhen Lei
2024-09-04 13:39 ` [PATCH v2 1/6] debugobjects: Fix the compilation attributes of some global variables Zhen Lei
2024-09-09 14:59   ` [tip: core/debugobjects] " tip-bot2 for Zhen Lei
2024-09-04 13:39 ` [PATCH v2 2/6] debugobjects: Fix the misuse of global variables in fill_pool() Zhen Lei
2024-09-09 14:59   ` [tip: core/debugobjects] debugobjects: Fix conditions " tip-bot2 for Zhen Lei
2024-09-04 13:39 ` [PATCH v2 3/6] debugobjects: Remove redundant checks " Zhen Lei
2024-09-09 14:59   ` [tip: core/debugobjects] " tip-bot2 for Zhen Lei
2024-09-04 13:39 ` Zhen Lei [this message]
2024-09-05  3:11   ` [PATCH v2 4/6] debugobjects: Don't start fill if there are remaining nodes locally Leizhen (ThunderTown)
2024-09-05  3:45     ` Leizhen (ThunderTown)
2024-09-05  7:04       ` Leizhen (ThunderTown)
2024-09-09  9:22       ` Thomas Gleixner
2024-09-09 11:03         ` Leizhen (ThunderTown)
2024-09-09 12:10         ` Thomas Gleixner
2024-09-09 13:51           ` Leizhen (ThunderTown)
2024-09-09 14:35             ` Thomas Gleixner
2024-09-09 14:41               ` Thomas Gleixner
2024-09-10  6:13               ` Leizhen (ThunderTown)
2024-09-10 15:29             ` Leizhen (ThunderTown)
2024-09-11  1:21               ` Leizhen (ThunderTown)
2024-09-04 13:39 ` [PATCH v2 5/6] debugobjects: Use hlist_splice_init() to reduce lock conflicts Zhen Lei
2024-09-04 13:39 ` [PATCH v2 6/6] debugobjects: Delete a piece of redundant code Zhen Lei

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=20240904133944.2124-5-thunder.leizhen@huawei.com \
    --to=thunder.leizhen@huawei.com \
    --cc=akpm@linux-foundation.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®