Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp6754rdg; Tue, 10 Oct 2023 02:33:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGM7kbexJQsulGvUZVTLc4ML0xndWaH0Y0pJTtcLqNxz0Lp8DabOryakp7MD5YSrRamEa0P X-Received: by 2002:a17:902:e5cb:b0:1c8:78b5:2ceb with SMTP id u11-20020a170902e5cb00b001c878b52cebmr18635160plf.40.1696930399305; Tue, 10 Oct 2023 02:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696930399; cv=none; d=google.com; s=arc-20160816; b=IEanGXzSLgfFU1wdkPTvayfufnBET8uqLHThbtE2IOHhmBAYbxebfipVxI5wq04AJK 0PNP3WuTSYYD4xkqEiVvrWuuqZSAjgfLWnvFd6xh1Ewd24r4YA+Zd5Uns0bt/mgh5hDC WLorhTNhz9dK4vhUILXLLEhudUh76RdaWY3/BPVz/wuEIy4x6FVReP35wcla0E2kD0C9 A2S/bm3oFDkABz3qZAQsMhi2Sy4Q7xcsBjz41HwMZnDdXjHUM17MXL+e/+mrzEy1VLKE gvZ1bU0vy2aGRkAjqZ3FWdYsS3jFEIfb/SPOxgZt0N7hjgmp0s11qygnTc3h1rgABh5E K4/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject :cc; bh=5AAQeA8TY+HHFkTyuzSzGazbNvAlMJNxuh7nOkC6DVU=; fh=gp/aV49FLMWPTHMd1b4qW7C/yVuF2Yygx6DOiR9Q5L0=; b=dmYdSf4wK90G1ryRnf+AupIhDe9738t65rS60Z5Dm5eSwvi/tzYoU7PHar3DbNNC6L pKAAWsswsQezbASJp55OrxpuBhTPTqOM28YA3gAhIP+d7A5cLYMa8eONd65k95fEfwFq 4EJWFo42VtM00TCntZLsmPDvzwaD63lil8GzYfchQmb8vdfzKFt63mX/1VrkdneDSPWA apwHvzXloGATLmIvEC1hCicMefy3CdH6h69GMhkbwipuU+0oV6DJFlqoikUrzxZgK9Af ll9+yOVUhlLdjFeKWBhz7Is6fdbDtgmvTdCMOZacLbpHiHKVGgjcWHTM4jKH+p41HZ2P kIEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id p7-20020a170902e74700b001c3411c9b83si12499004plf.454.2023.10.10.02.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 02:33:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 25E9780CF507; Tue, 10 Oct 2023 02:32:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230171AbjJJJcJ (ORCPT + 99 others); Tue, 10 Oct 2023 05:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjJJJcI (ORCPT ); Tue, 10 Oct 2023 05:32:08 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24CBC93 for ; Tue, 10 Oct 2023 02:32:06 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S4Vt76ML3ztT2L; Tue, 10 Oct 2023 17:27:27 +0800 (CST) Received: from [10.67.121.177] (10.67.121.177) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 10 Oct 2023 17:32:03 +0800 CC: , , , , , Subject: Re: [PATCH drivers/perf: hisi:] drivers/perf: hisi: fix NULL pointer issue when uninstall hns3 pmu driver To: Jijie Shao , , , , References: <20231009105038.126040-1-shaojijie@huawei.com> From: Yicong Yang Message-ID: <504cc838-d587-8bd0-601e-85f11b69c72b@huawei.com> Date: Tue, 10 Oct 2023 17:32:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20231009105038.126040-1-shaojijie@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.177] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 10 Oct 2023 02:32:28 -0700 (PDT) Hi Jijie, On 2023/10/9 18:50, Jijie Shao wrote: > From: Hao Chen > > When uninstall hns3 pmu driver, it will call cpuhp_state_remove_instance() > and then callback function hns3_pmu_offline_cpu() is called, it may cause > NULL pointer call trace when other driver is installing or uninstalling > concurrently. > More information about the calltrace you've met and how to reproduce this? I'm not sure why other drivers are involved. > As John Garry's opinion, cpuhp_state_remove_instance() is used for shared > interrupt, and using cpuhp_state_remove_instance_nocalls() is fine for PCIe > or HNS3 pmu. > I'm a bit confused here. We need to update the using CPU and migrate the perf context as well as the interrupt affinity in cpuhp::teardown() callback, so it make sense to not call this on driver detachment. But I cannot figure out why this is related to the shared interrupt, more details? > So, replace cpuhp_state_remove_instance() with > cpuhp_state_remove_instance_nocalls() to fix this problem. > > Fixes: 66637ab137b4 ("drivers/perf: hisi: add driver for HNS3 PMU") > Signed-off-by: Hao Chen > Signed-off-by: Jijie Shao > --- > drivers/perf/hisilicon/hns3_pmu.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/perf/hisilicon/hns3_pmu.c b/drivers/perf/hisilicon/hns3_pmu.c > index e0457d84af6b..16869bf5bf4c 100644 > --- a/drivers/perf/hisilicon/hns3_pmu.c > +++ b/drivers/perf/hisilicon/hns3_pmu.c > @@ -1556,8 +1556,8 @@ static int hns3_pmu_init_pmu(struct pci_dev *pdev, struct hns3_pmu *hns3_pmu) > ret = perf_pmu_register(&hns3_pmu->pmu, hns3_pmu->pmu.name, -1); > if (ret) { > pci_err(pdev, "failed to register perf PMU, ret = %d.\n", ret); > - cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE, > - &hns3_pmu->node); > + cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE, > + &hns3_pmu->node); > } > > return ret; > @@ -1568,8 +1568,8 @@ static void hns3_pmu_uninit_pmu(struct pci_dev *pdev) > struct hns3_pmu *hns3_pmu = pci_get_drvdata(pdev); > > perf_pmu_unregister(&hns3_pmu->pmu); > - cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE, > - &hns3_pmu->node); > + cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HNS3_PMU_ONLINE, > + &hns3_pmu->node); > } Thanks.