Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp200396pxk; Wed, 23 Sep 2020 00:14:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7Avq/kxHDW984cJtx2OW0bOuC8q0f4Acuy022llIEbaWas5a3IPQMT92tU9R9TIJNwHSH X-Received: by 2002:a17:906:71cc:: with SMTP id i12mr8778269ejk.507.1600845295606; Wed, 23 Sep 2020 00:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600845295; cv=none; d=google.com; s=arc-20160816; b=qFTHq3xFM33XiL62jgC2GhVT+l9LiyAMVisUid67VynANdi8GYVcmGkhC6alIa2Lsy +pV011RIMdwfePHP1kV6Aplpky+r3Ak3P4LIXsV+AWPCGg+S0UJAa0pyIKrEhQ8ZE+qQ 4PdEUbjO2ak7C5u6LxsmC46Nr1uJNy1sXzFHbP9DKgcdqOcjisYrUmkFebOEAvLrM2Vt eaGU1d7S7340K/DTDQ+snYmddd06dea3AF8GIEp5DzVPnug9EvJbUSOWpQ1aAvP887TI +/9SFF4tq5+mNx2ecErtDBX0SaRItMTJBls1/RMS6KEoibstobXfY5y029BvGAGrOpGY KQ0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=c/ww5c0bsyE8Yx74TqvFyRvBhyBxOLgGPp4xDwOjV+g=; b=A2qB6zgQDg6BLYVnlFU31NBdPfIy4vNwpzjDkNYWztj9YJQuZs0mLq/yHhpYBBfjMG 5p41b0FD+cJs4fMhfUZtu2rv5487wmi4Xur9TgQ4xG96RNxARUDcLzdoECmVETImguVZ jbQZTbH2xX/wqkcMu/J0e4Kl+f9f53bSf9lKlmkRhUf8wgtcJqSM8FW1LmHW54W7+cOe CCeWeecCWXmLAqpRzLqIvsOIJzcd+QxQ53m6bNxDDTolcrGqk/PSnmyCWqI65qsobw1y Ab9lyJkYRr3sY/EUcG7ipXMORTB2fWmtpej6xoboDGctWm21/xOdZobLVC0uiRd450qq DgfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si12511259ejl.266.2020.09.23.00.14.31; Wed, 23 Sep 2020 00:14:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726666AbgIWHLW (ORCPT + 99 others); Wed, 23 Sep 2020 03:11:22 -0400 Received: from mail.windriver.com ([147.11.1.11]:35224 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbgIWHLV (ORCPT ); Wed, 23 Sep 2020 03:11:21 -0400 X-Greylist: delayed 13282 seconds by postgrey-1.27 at vger.kernel.org; Wed, 23 Sep 2020 03:11:21 EDT Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail.windriver.com (8.15.2/8.15.2) with ESMTPS id 08N3TKuW012686 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 22 Sep 2020 20:29:20 -0700 (PDT) Received: from pek-qzhang2-d1.wrs.com (128.224.162.183) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.487.0; Tue, 22 Sep 2020 20:29:07 -0700 From: To: , , , , , CC: Subject: [PATCH v4] debugobjects: install CPU hotplug callback Date: Wed, 23 Sep 2020 11:29:05 +0800 Message-ID: <20200923032905.20738-1-qiang.zhang@windriver.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zqiang Due to CPU hotplug, it may never be online after it's offline, some objects in percpu pool is never free. in order to avoid this happening, install CPU hotplug callback, call this callback func to free objects in percpu pool when CPU going offline. Signed-off-by: Zqiang Acked-by: Waiman Long Cc: Andrew Morton Cc: "Joel Fernandes (Google)" Cc: Qian Cai --- v1->v2: Modify submission information. v2->v3: In CPU hotplug callback func, add clear percpu pool "obj_free" operation. capitalize 'CPU', and use shorter preprocessor sequence. v3->v4: Add Cc and Acked-by tags include/linux/cpuhotplug.h | 1 + lib/debugobjects.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 3215023d4852..0c39d57e5342 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 fe4557955d97..bb69a02c3e7b 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,24 @@ 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; + + 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 +1386,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. -- 2.17.1