debugobjects: Remove redundant checks in fill_pool()
authorZhen Lei <thunder.leizhen@huawei.com>
Wed, 4 Sep 2024 13:39:41 +0000 (21:39 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 9 Sep 2024 14:40:26 +0000 (16:40 +0200)
commit63a4a9b52c3c7f86351710739011717a36652b72
tree63677b8b3a583314735b720d41ed26ed9b4c2047
parent684d28feb8546d1e9597aa363c3bfcf52fe250b7
debugobjects: Remove redundant checks in fill_pool()

fill_pool() checks locklessly at the beginning whether the pool has to be
refilled. After that it checks locklessly in a loop whether the free list
contains objects and repeats the refill check.

If both conditions are true, it acquires the pool lock and tries to move
objects from the free list to the pool repeating the same checks again.

There are two redundant issues with that:

      1) The repeated check for the fill condition
      2) The loop processing

The repeated check is pointless as it was just established that fill is
required. The condition has to be re-evaluated under the lock anyway.

The loop processing is not required either because there is practically
zero chance that a repeated attempt will succeed if the checks under the
lock terminate the moving of objects.

Remove the redundant check and replace the loop with a simple if condition.

[ tglx: Massaged change log ]

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240904133944.2124-4-thunder.leizhen@huawei.com
lib/debugobjects.c