Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp770087pxk; Wed, 9 Sep 2020 19:52:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR5Cb0q7Cn5IXnOLaCDpnwTyD6IacMvpxjfo4e0xrXwytWNc7cBN0ENcexBbQh70byjBEv X-Received: by 2002:a50:9f22:: with SMTP id b31mr7237033edf.345.1599706374994; Wed, 09 Sep 2020 19:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599706374; cv=none; d=google.com; s=arc-20160816; b=O68plcXatJdqqqk2WmfoeV0ieUK8qPFaCUx99WB+AggxoDtEvn0auIIsST1jIjCo+I EhcPfA6WSdoa6THXNrfl3rf7PYf/0Szb9P84B/0V0m0zM4tBY47jsSoXfezAMB62ksJM MmzggDg6s578Fea+QN0RJSshfySx+NVTV/jEYUTNhf6iNJmd6LvY5y2ajiS4r3QhofzW oF1FGzvQh5Z+s7/SVJy05ga5I1eDuOkjnou/C+luuIqbJSFatnu3clJ5fdeJw9GuPEwQ xvTqSAgSbbi5aJn7BfCfm9/Xqun+JBYedAfCMis1mmv7EF5IT167DJIfKZHkJsVYsM6b vPAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=QJQOTeTVHeQk2Lc8CRwNu9NdRVyDZ7qS/l1V2jelAI8=; b=ghBnsIOFIAf29+I7nCokZ+XVCP70o8TzXBETuXSe+7LS2HIfO5LlmQjRgZdHFXNDA1 T57lFW4WUoHsyU/5Qs6Zq18y/T4+DAiTIl/TA69Iy0RBKjfJiFtRr/L1KgHyyNOhu0q6 CBgG8uYkvnJmbtBwo9bJAtXY1PFMVBC6/+XgYpCi53eTczD7e8ScZNxrte9NsMTC802w JouO3gWOCb6h/FvkPJSht0gd04TVYzWmdVhoVLadI3jI36NdH9KvA4I0El9Q7/dnBxOI pNPZS3dA7YjOal9RcZANCfvIXUW8vDrbV0bejledyK8NePsYevR7lW+PZwnOGLc8VW81 TzCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Us/bEkXq"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si2682813ejj.41.2020.09.09.19.52.31; Wed, 09 Sep 2020 19:52:54 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Us/bEkXq"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726440AbgIJCvo (ORCPT + 99 others); Wed, 9 Sep 2020 22:51:44 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44595 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730068AbgIJCuj (ORCPT ); Wed, 9 Sep 2020 22:50:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599706234; h=from:from: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=QJQOTeTVHeQk2Lc8CRwNu9NdRVyDZ7qS/l1V2jelAI8=; b=Us/bEkXqNKvmHsSj7u57ZoxJyLU6clnWgPZx6BCPjyUHA2c+kW5YLf/au4NpxwEcfans3+ ofqkPkFyLTHf35LpxQUvRYa1R5G4jlZMOiZZuwBvwet4Yvu1XXH0yhpIsUTWZrA1cjzujJ dQk2l0heUpOdNRPuG4DtCL/wMUjDxUY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-IKKAOBSFMvKLG1cL0f7GMw-1; Wed, 09 Sep 2020 22:50:30 -0400 X-MC-Unique: IKKAOBSFMvKLG1cL0f7GMw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 80EAD1007464; Thu, 10 Sep 2020 02:50:29 +0000 (UTC) Received: from llong.remote.csb (unknown [10.10.115.252]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D7797E175; Thu, 10 Sep 2020 02:50:28 +0000 (UTC) Subject: =?UTF-8?B?UmU6IOWbnuWkjTogW1BBVENIIHYzXSBkZWJ1Z29iamVjdHM6IGluc3Rh?= =?UTF-8?Q?ll_CPU_hotplug_callback?= To: "Zhang, Qiang" , "tglx@linutronix.de" , "mingo@kernel.org" , "elver@google.com" Cc: "linux-kernel@vger.kernel.org" References: <20200908062709.11441-1-qiang.zhang@windriver.com> <3bcdacd0-10c4-78c0-6e63-a73811a0ced6@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: Date: Wed, 9 Sep 2020 22:50:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/9/20 9:48 PM, Zhang, Qiang wrote: > > ________________________________________ > ??????: Waiman Long > ????ʱ??: 2020??9??9?? 2:23 > ?ռ???: Zhang, Qiang; tglx@linutronix.de; mingo@kernel.org; elver@google.com > ????: linux-kernel@vger.kernel.org > ????: Re: [PATCH v3] debugobjects: install CPU hotplug callback > > On 9/8/20 2:27 AM, qiang.zhang@windriver.com wrote: >> 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. >> >> v2->v3: >> In CPU hotplug callback func, add clear percpu pool "obj_free" operation. >> capitalize 'CPU', and use shorter preprocessor sequence. >> >> 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; >>> For pointer, it is better to use NULL for clarity. >>> Cheers, >>> Longman > Do you mean "->obj_free" variable ? this represents the number of free objects in percpu_pool . > You are right. I got confused. Sorry for the noise. Cheers, Longman