Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp277992rdg; Thu, 12 Oct 2023 05:39:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYH0TWNCQIc0+6/uBJNE42WNEakCns9rHCCwIO67ML4WbJ88a3Yn+oy8YSRwaTA+so+Ruc X-Received: by 2002:a17:902:f686:b0:1c5:ecfc:2650 with SMTP id l6-20020a170902f68600b001c5ecfc2650mr31068139plg.14.1697114349245; Thu, 12 Oct 2023 05:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697114349; cv=none; d=google.com; s=arc-20160816; b=nDRS/PsqBLY7eNpw0Q/RluqrE/lDCLmbywfmFrRjhP3XCQkuo4rVGdEKi3kotVzn47 ImD5epA1g1nLjVg1hwSMboWSN644msawA/ySyiog/2WxgNT/Z+P1Dao8npaZ33tRZDCl 2vhB6ku5MV/iRe+VyMC7GvBnmz5LnzPkNW36JPebU6VvaEV5+eB91vrLd1nrdztcLfT9 xJvtxBOlB9HfxqlTDDpZJ3ILWab24TSgCSg+4UcHLZjFKEl3MJPZVCcRX/RpNXkth5Rn Z30fgF83ZqUlFMv7edTkNf7DcTXg/XLeI9dWnzrVLlWoRrUyLZE5xPQYt42ODVREPNEO 2luw== 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=WqnQixfaP3UXNNGzZ+APDVrvl6clXgfcNWbMS/XPGRo=; fh=IdnaJmY7F8+GwlqYfgymFevm7FV4JpKiY2+peGzMsXk=; b=rbwwNRDuyWiUrVKPMz3Og8077zshcMLjjPPUJu+IUI0BBeePuL7CKgFBgAYOUQY19j +A+whn0Nu4/A/zN41f7z7IcKgcBU8tTs9FaF1cgWHLUt/uS5yh1emm8rTshgt7FK/WQB iST1KPbKhxeLYUV6G7ow1gMAMf6Xx96u8N38pOHTvtLlmx/UcvTT4ShD7rPye7wMAXiL R4DlAp7gTAxs5z2XaJYpSbcqbzSNWkmbu2vSPnRuoaPhEKqJfTPmkQpVtLJb700AK0JD rNcviehQyORINwgaYyji5vNWKENkfHF4a+fiT+utzLX+NF13Z+mTOrkYrKTjRd5nfi6P uElA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id n17-20020a170903111100b001c32d285db8si1744847plh.308.2023.10.12.05.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 05:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 41A80837B898; Thu, 12 Oct 2023 05:39:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378433AbjJLMjA (ORCPT + 99 others); Thu, 12 Oct 2023 08:39:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377488AbjJLMiv (ORCPT ); Thu, 12 Oct 2023 08:38:51 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57FBFC4 for ; Thu, 12 Oct 2023 05:38:49 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4S5pxM684rz1kv48; Thu, 12 Oct 2023 20:34:47 +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; Thu, 12 Oct 2023 20:38:46 +0800 CC: , , , , , Subject: Re: [PATCH drivers/perf: hisi:] drivers/perf: hisi: fix NULL pointer issue when uninstall hns3 pmu driver To: Robin Murphy , Jijie Shao , , , , References: <20231009105038.126040-1-shaojijie@huawei.com> <504cc838-d587-8bd0-601e-85f11b69c72b@huawei.com> <9579f762-24ce-0826-dc7b-2c79c969f192@huawei.com> <8fe4484c-57ed-477a-8ac1-e73b4a9cb3da@arm.com> From: Yicong Yang Message-ID: Date: Thu, 12 Oct 2023 20:38:46 +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: <8fe4484c-57ed-477a-8ac1-e73b4a9cb3da@arm.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 05:39:07 -0700 (PDT) Hi Robin, On 2023/10/12 0:03, Robin Murphy wrote: > On 11/10/2023 9:37 am, Jijie Shao wrote: >> >> on 2023/10/10 17:32, Yicong Yang wrote: >>> 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? >>> >> ok,I will send v2 to add more details. > > This shouldn't have anything to do with concurrency or shared interrupts or anything else. It's simply that we should clearly not attempt to migrate a PMU context (via invoking the hotplug callbacks) *after* the relevant PMU has already been unregistered, since that's liable to lead to some kind of use-after-free, and at best it's just a pointless waste of time anyway - if we've got to the point of unbinding the driver (or failing to probe at all), there should definitely not be any active events or other PMU state that needs updating. > Thanks for the clarification. I think this is the root reason of the problem met on the hns3 pmu. Thanks.