Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp185681pxa; Wed, 26 Aug 2020 22:12:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxOWIqe3WhqgfHcXSHIoh1fXce50E9M6g+uNwImDy6fntsa6j+l2su0peDOGnFBlzVEkH7 X-Received: by 2002:a17:906:b157:: with SMTP id bt23mr20287284ejb.354.1598505122359; Wed, 26 Aug 2020 22:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598505122; cv=none; d=google.com; s=arc-20160816; b=MLKzfA3Y3mgh+nrq4Y4hDFt2fLZMkrJQwWfgn51+IVkamv4YAckYmFRLPc13T8tHVn o6JQA9warn6EgwXcemcT7Fja8oV3YQVo//rENnQXAPgWDPpxQI1CH4OIBWAHulAlxEFv H//aeWnyvTu50yFCsz/a67kAGobKocHyo3tbhzDI5I0JgYHH/4kcXAHpVVk5xv69rcjj E4sVPbKQoAhOsZfDDahJZQEPQrXKFT2bdRWt1p2hbJ0Mr92Xdi72i4Fk+nK02LesBwbM LSUZdcm5mfY4UGHIF2Oe4VHZ3MB1LC8DRUctOKSRF/cdTAXNSqNenEYkOJ+IQBlEDM26 KHjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ROZwRXIFOs1QD1eo2rMFtf6+a7vFN+u4QFcAQsQPY8g=; b=dVEbEtcxLecuPypLqLbpPrJC3VLBvdxTNePAxCza8z3KqQw7vktYK4ChWxyoL+SCEW 7v3VWTPaD3P7qYdGJH+7FNqb4cNQT0k6b06wpzKySuLuqyxup2o4LknYdDmlVgKsBv06 KG1oW+c/SvdAK0d8Rso4EB7LYWuHI89pTTJU+jJIHyLrNcbVLtLbQ1pbGDmbccpouKeA lYmMdkRQfkJVEpj+/wYLVroq/28ZqWJ+UsXSDxelO+s0QOk1kVpWLBUwXKO7AwLvvgPR qBWa2iJQNGftFgWmCcGIpj67IxB8w1Dgm9Jo8A21jFJrkinNBJ17XgGuOVN7EKxrUgvE dcGw== 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 dn2si758800ejc.28.2020.08.26.22.11.38; Wed, 26 Aug 2020 22:12:02 -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 S1726200AbgH0FH4 (ORCPT + 99 others); Thu, 27 Aug 2020 01:07:56 -0400 Received: from mail5.windriver.com ([192.103.53.11]:51936 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbgH0FH4 (ORCPT ); Thu, 27 Aug 2020 01:07:56 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id 07R56DIM011495 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 26 Aug 2020 22:06:33 -0700 Received: from pek-qzhang2-d1.wrs.com (128.224.162.183) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.487.0; Wed, 26 Aug 2020 22:06:16 -0700 From: To: , , CC: Subject: [PATCH v2] debugobjects: install cpu hotplug callback Date: Thu, 27 Aug 2020 13:06:14 +0800 Message-ID: <20200827050614.15100-1-qiang.zhang@windriver.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org 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 --- v1->v2: Modify submission information. include/linux/cpuhotplug.h | 1 + lib/debugobjects.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index a2710e654b64..2e77db655cfa 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..50e21ed0519e 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,23 @@ static void free_object(struct debug_obj *obj) } } +#if defined(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); + } + + return 0; +} +#endif + /* * We run out of memory. That means we probably have tons of objects * allocated. @@ -1367,6 +1385,11 @@ void __init debug_objects_mem_init(void) } else debug_objects_selftest(); +#if defined(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