From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A1DAC4727C for ; Thu, 1 Oct 2020 14:40:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E515720B1F for ; Thu, 1 Oct 2020 14:40:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Qkh4Mvpf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dXi6KmkM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732490AbgJAOkX (ORCPT ); Thu, 1 Oct 2020 10:40:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732020AbgJAOkU (ORCPT ); Thu, 1 Oct 2020 10:40:20 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32CCAC0613D0; Thu, 1 Oct 2020 07:40:20 -0700 (PDT) Date: Thu, 01 Oct 2020 14:40:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1601563218; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nIhVe2PlDvHXb45EEPzCb0UF4TEaWgDVSbYXDqQKqF8=; b=Qkh4MvpfzgquP9x3LmWFy3VYnxMO+yqupenn5gUrUwmokvK+ZYEy8tuR6WILy/X0Kjtjsu UyWQ8cs6j9ulpCtAEUzutesz8JDBA7FN57XEwtWqkh95Dc4QObWFyK53OKPUJv14SGfMpd t54eENyeZ9+spLbg8seqHpPjGRNDBLLrbzNPd5gRtTo1l5pRr4mk76E8Km3TvbEsKP0nl1 W3EmFSwukJIi52C6HiqwA4X8y452nVZb8s7tPy7kWb2v3UjVlQJk+5ZV/iGSsUdlUTkdyn 8IAJIPcHwFFqIUi7mGu7NSIkaHcno+GqoC/LwKIlY3966om65il2CaUztLaX2Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1601563218; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nIhVe2PlDvHXb45EEPzCb0UF4TEaWgDVSbYXDqQKqF8=; b=dXi6KmkMf3aejlvQMYz/pDOTqB1PkIYyOQKyKK1PFmWPx+4X0AHaoqz73pA9CNRh9ngEnE JNaHoIv2utZxT5Cg== From: "tip-bot2 for Zqiang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/debugobjects] debugobjects: Free per CPU pool after CPU unplug Cc: Zqiang , Thomas Gleixner , Waiman Long , x86 , LKML In-Reply-To: <20200908062709.11441-1-qiang.zhang@windriver.com> References: <20200908062709.11441-1-qiang.zhang@windriver.com> MIME-Version: 1.0 Message-ID: <160156321691.7002.8346589408007234423.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the core/debugobjects branch of tip: Commit-ID: 88451f2cd3cec2abc30debdf129422d2699d1eba Gitweb: https://git.kernel.org/tip/88451f2cd3cec2abc30debdf129422d2699d1eba Author: Zqiang AuthorDate: Tue, 08 Sep 2020 14:27:09 +08:00 Committer: Thomas Gleixner CommitterDate: Thu, 01 Oct 2020 16:13:54 +02:00 debugobjects: Free per CPU pool after CPU unplug If a CPU is offlined the debug objects per CPU pool is not cleaned up. If the CPU is never onlined again then the objects in the pool are wasted. Add a CPU hotplug callback which is invoked after the CPU is dead to free the pool. [ tglx: Massaged changelog and added comment about remote access safety ] Signed-off-by: Zqiang Signed-off-by: Thomas Gleixner Cc: Waiman Long Link: https://lore.kernel.org/r/20200908062709.11441-1-qiang.zhang@windriver.com --- include/linux/cpuhotplug.h | 1 + lib/debugobjects.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index bf9181c..6f524bb 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -36,6 +36,7 @@ enum cpuhp_state { CPUHP_X86_MCE_DEAD, CPUHP_VIRT_NET_DEAD, CPUHP_SLUB_DEAD, + CPUHP_DEBUG_OBJ_DEAD, CPUHP_MM_WRITEBACK_DEAD, CPUHP_MM_VMSTAT_DEAD, CPUHP_SOFTIRQ_DEAD, diff --git a/lib/debugobjects.c b/lib/debugobjects.c index e2a3171..9e14ae0 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -19,6 +19,7 @@ #include #include #include +#include #define ODEBUG_HASH_BITS 14 #define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS) @@ -433,6 +434,25 @@ static void free_object(struct debug_obj *obj) } } +#ifdef CONFIG_HOTPLUG_CPU +static int object_cpu_offline(unsigned int cpu) +{ + struct debug_percpu_free *percpu_pool; + struct hlist_node *tmp; + struct debug_obj *obj; + + /* Remote access is safe as the CPU is dead already */ + percpu_pool = per_cpu_ptr(&percpu_obj_pool, cpu); + hlist_for_each_entry_safe(obj, tmp, &percpu_pool->free_objs, node) { + hlist_del(&obj->node); + kmem_cache_free(obj_cache, obj); + } + percpu_pool->obj_free = 0; + + return 0; +} +#endif + /* * We run out of memory. That means we probably have tons of objects * allocated. @@ -1367,6 +1387,11 @@ void __init debug_objects_mem_init(void) } else debug_objects_selftest(); +#ifdef CONFIG_HOTPLUG_CPU + cpuhp_setup_state_nocalls(CPUHP_DEBUG_OBJ_DEAD, "object:offline", NULL, + object_cpu_offline); +#endif + /* * Increase the thresholds for allocating and freeing objects * according to the number of possible CPUs available in the system.