From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AE961F8F12; Wed, 6 Nov 2024 13:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730898293; cv=none; b=QuWjgBZ3pLl8WzJdYy5zPerI1TDDWviNuz6I1b41U1g3Nm0Pu2H8nhNa0WqewHqyvR3cyLoAHyUAaaOuowxJwYXRcENuT+Xb3WSKFcgUt8cMJuSyP7RemNGNiSosV5f74lyUQxjhDGaPo8suHqmZlr0BYRh4IscKbTO94W0zypk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730898293; c=relaxed/simple; bh=LKua+wULvQp+/i3fDfWwzddSVHUmHb1Z2NIBSHhJwk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OxTyLmX7VKKYsEd3lN72BsUomeu//qahdqta/Gas44/jeQ791UGFtSy6XqGP/LHUFOKGzMwz2zI1w7kVPXnE0X94eqNRgQeFE4/C/dIARFTwMWvCQwM4/4SirTAo0xSzxogDsufFBjCYGXIQtPqlDD9H9vecnq8YybCfDi68FG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SN8FAKxD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="SN8FAKxD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8857CC4CECD; Wed, 6 Nov 2024 13:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730898292; bh=LKua+wULvQp+/i3fDfWwzddSVHUmHb1Z2NIBSHhJwk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SN8FAKxDmssJCsu8SkhCSCqkJWEVXmVd52ZBfKEGBhosbqQ58FgtqA+rOxYX//9xP ZWB3+K4cBaY0xGY9HjiejRqA6hNGateXaPbvWyhCvMnyC9KEavMx27YZlJQxc1Ri4l 4pIajVi8SAhmjfQHVuyIU9uMA4FUkj78TNsezly0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhen Lei , Thomas Gleixner Subject: [PATCH 5.4 152/462] debugobjects: Fix conditions in fill_pool() Date: Wed, 6 Nov 2024 13:00:45 +0100 Message-ID: <20241106120335.268230035@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120331.497003148@linuxfoundation.org> References: <20241106120331.497003148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhen Lei commit 684d28feb8546d1e9597aa363c3bfcf52fe250b7 upstream. fill_pool() uses 'obj_pool_min_free' to decide whether objects should be handed back to the kmem cache. But 'obj_pool_min_free' records the lowest historical value of the number of objects in the object pool and not the minimum number of objects which should be kept in the pool. Use 'debug_objects_pool_min_level' instead, which holds the minimum number which was scaled to the number of CPUs at boot time. [ tglx: Massage change log ] Fixes: d26bf5056fc0 ("debugobjects: Reduce number of pool_lock acquisitions in fill_pool()") Fixes: 36c4ead6f6df ("debugobjects: Add global free list and the counter") Signed-off-by: Zhen Lei Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20240904133944.2124-3-thunder.leizhen@huawei.com Signed-off-by: Greg Kroah-Hartman --- lib/debugobjects.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -143,13 +143,14 @@ static void fill_pool(void) * READ_ONCE()s pair with the WRITE_ONCE()s in pool_lock critical * sections. */ - while (READ_ONCE(obj_nr_tofree) && (READ_ONCE(obj_pool_free) < obj_pool_min_free)) { + while (READ_ONCE(obj_nr_tofree) && + READ_ONCE(obj_pool_free) < debug_objects_pool_min_level) { raw_spin_lock_irqsave(&pool_lock, flags); /* * Recheck with the lock held as the worker thread might have * won the race and freed the global free list already. */ - while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) { + while (obj_nr_tofree && (obj_pool_free < debug_objects_pool_min_level)) { obj = hlist_entry(obj_to_free.first, typeof(*obj), node); hlist_del(&obj->node); WRITE_ONCE(obj_nr_tofree, obj_nr_tofree - 1);