Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp920456rdg; Wed, 11 Oct 2023 09:03:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGl0qWmKAiitLW/BTrPqAA9WcGh2ICaFXhcvQ5jYBJYJyUolmi3oCQ+3EW30xJ6ngtoU+85 X-Received: by 2002:a05:6300:8089:b0:174:373b:4381 with SMTP id ap9-20020a056300808900b00174373b4381mr1009047pzc.49.1697040228719; Wed, 11 Oct 2023 09:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697040228; cv=none; d=google.com; s=arc-20160816; b=0xkYMgvZiGBDf0xdq3F0wvULOK6AQ3LxS+Hx3RHMbWl5ydtENlTLlWRlbc/SfKLtO6 PK/4nf0veYeNx/hSPvVMMxdzLJ2dEZ+cnXtnXyTtXnZB8RIouTtLBKzBCYVEmohVtpKk 1iuPqEyO1v2WnTKcktB+R5dRl73wD+Apc9a/EtAOHLrj1A4Np3mo5z1D2w/UQ4yePYTi ++lqHkwRivz47bcvLdtqEWqXX03U85PZewMUw/cYpDKd1a5/GOIZGjl/lU8wuf0vEUs9 eKhkHhupHpL2TpX0stv52KyM0ZwOMUWVvZjspVrc2tWmBVu4taGJsUIu7uqfAjFTJnt0 ugtg== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=dGiitx6oLcfNOpeBO542N0Ao8AYOcr4RZndsTriqqW4=; fh=hi1MBWmgNXeuCzT5C+dvP+hqGQhVt2i1sdqO8Wxm+50=; b=XyHkEoNiBK9Miwf3Meu7OeNT2SmQ4TjRkFR1qMNe1EgP4bLvEV5W/WdU2HhnLZ6FDk Oq7DDpU0jno/N+/x7AAJfhMJyUncgKR6Jahv8dclxUp1g9NO1eegIYxta4YmkonFYK2N /4NTVH88D3eboa9MLk/zL7CE/oVZl1UMzMOiXkB/ltnrCJiqdC2WA0M+OZuPxuQFPfE0 jFAdFBO3djXx8+zSTNnFy7396B/3FLZDvpqrkRRW3ok0QGDJoLTkQOHKSH8hd7N/Y9pw bEgSw/UZhA+WKyl+IDuVbg3FSLsOAeiWS+fK8XKb/KEBsAy5mXJunghyhkORl6FLbNoE 1zUg== 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:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id cn11-20020a056a020a8b00b005660335e26fsi60967pgb.485.2023.10.11.09.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 09:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 80F778255495; Wed, 11 Oct 2023 09:03:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346957AbjJKQDS (ORCPT + 99 others); Wed, 11 Oct 2023 12:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235111AbjJKQDR (ORCPT ); Wed, 11 Oct 2023 12:03:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3D648C4 for ; Wed, 11 Oct 2023 09:03:14 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0DDA214BF; Wed, 11 Oct 2023 09:03:54 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B514B3F7A6; Wed, 11 Oct 2023 09:03:11 -0700 (PDT) Message-ID: <8fe4484c-57ed-477a-8ac1-e73b4a9cb3da@arm.com> Date: Wed, 11 Oct 2023 17:03:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH drivers/perf: hisi:] drivers/perf: hisi: fix NULL pointer issue when uninstall hns3 pmu driver Content-Language: en-GB To: Jijie Shao , Yicong Yang , will@kernel.org, jonathan.cameron@huawei.com, mark.rutland@arm.com, yangyicong@hisilicon.com Cc: chenhao418@huawei.com, shenjian15@huawei.com, wangjie125@huawei.com, liuyonglong@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20231009105038.126040-1-shaojijie@huawei.com> <504cc838-d587-8bd0-601e-85f11b69c72b@huawei.com> <9579f762-24ce-0826-dc7b-2c79c969f192@huawei.com> From: Robin Murphy In-Reply-To: <9579f762-24ce-0826-dc7b-2c79c969f192@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 09:03:36 -0700 (PDT) X-Spam-Level: ** 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, Robin.