Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1108849ybh; Thu, 16 Jul 2020 03:27:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3iUtHPp18vvyiX0KI7FL9qYbbaZX91FRsU1U1XrQaQSrq8uABpm2LqDHzSWcBfiyXHwdK X-Received: by 2002:a17:907:1189:: with SMTP id uz9mr3154879ejb.478.1594895275681; Thu, 16 Jul 2020 03:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594895275; cv=none; d=google.com; s=arc-20160816; b=wADhlrN3W6b0nVAp3vmr+pna671OBO2hkuNKOqXx9/fVQRY9qc8hvGaoR3Y02bOYgU K/KDbeG9J+YpYIKtTSFqWJd0GSEyIoaH4yVPEQpIXYSw+2jOdCJKcTPnzpYAD/zIJS9v w6lobYIhcNzVIQhZhYh2JJw4ShdyZmiHOkiAuAsriMjIUvDqxanD9ZaiJDCS/2osDJUt R5FchdeNJyATs4+0fIo5cq/UVFFdYqga5xSIYRTmaidsDGHqxtHIrhl4aX9B6Ui6wNf6 Wc5ZVV3rbMCKhbbLEabqmQ9IJbz+qTkbndhblqfrQgJUkKkS+k3qxhmZNY5jsiUPM4Ab TBFA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=9ui+sZi9cdwuyFJcrog/bnPm5KobaK5u0BGXpasGSiw=; b=Qcm+ao/jPVWALDt+RUe20wc2prsfS0IMGpCOPQyXDD5JIq/TxC+hJuGuHrOIngm0SI OwcOwE+NZGv6QS7Irk+rQOuxhRnmBtbVunMcmEv6JD3eAgFLpdxSRrERxdMt7XTDhdVK GalMDU6E9eO07wSY6x7gjlDV1UgUeJwvPrOSf3bLNOYS1RCm5OZj6ZILcgal0iGWoRgC VvQAqWkTFULChumrkQOwIlIPSnBh/BMFr5zuubudo2ABmlSrcJd8bEKz5+tqXomUJiQn OAHEWhpuTJeBJFnUjmXf6Fg1saDW5KbRdBblDwydKkVzEWEncCvp6/d5XVvQ8nmfkn0c A/Qg== 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 a7si3049101eds.485.2020.07.16.03.27.33; Thu, 16 Jul 2020 03:27:55 -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 S1727849AbgGPK03 (ORCPT + 99 others); Thu, 16 Jul 2020 06:26:29 -0400 Received: from foss.arm.com ([217.140.110.172]:52830 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbgGPK02 (ORCPT ); Thu, 16 Jul 2020 06:26:28 -0400 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 315A91FB; Thu, 16 Jul 2020 03:26:28 -0700 (PDT) Received: from [10.57.35.46] (unknown [10.57.35.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BDA633F68F; Thu, 16 Jul 2020 03:26:26 -0700 (PDT) Subject: Re: [PATCH] drivers/perf: Fix kernel panic when rmmod PMU modules during perf sampling To: Will Deacon , Qi Liu Cc: mark.rutland@arm.com, john.garry@huawei.com, linux-kernel@vger.kernel.org, linuxarm@huawei.com, zhangshaokun@hisilicon.com, wang.wanghaifeng@huawei.com, linux-arm-kernel@lists.infradead.org References: <1594891165-8228-1-git-send-email-liuqi115@huawei.com> <20200716094144.GC6771@willie-the-truck> From: Robin Murphy Message-ID: Date: Thu, 16 Jul 2020 11:26:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200716094144.GC6771@willie-the-truck> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-07-16 10:41, Will Deacon wrote: > On Thu, Jul 16, 2020 at 05:19:25PM +0800, Qi Liu wrote: >> Kernel panic will also happen when users try to unbind PMU drivers with >> device. This unbind issue could be solved by another patch latter. >> >> drivers/perf/arm_smmuv3_pmu.c | 1 + >> drivers/perf/fsl_imx8_ddr_perf.c | 1 + >> drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 1 + >> drivers/perf/hisilicon/hisi_uncore_hha_pmu.c | 1 + >> drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c | 1 + >> 5 files changed, 5 insertions(+) >> >> diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c >> index 48e28ef..90caba56 100644 >> --- a/drivers/perf/arm_smmuv3_pmu.c >> +++ b/drivers/perf/arm_smmuv3_pmu.c >> @@ -742,6 +742,7 @@ static int smmu_pmu_probe(struct platform_device *pdev) >> platform_set_drvdata(pdev, smmu_pmu); >> >> smmu_pmu->pmu = (struct pmu) { >> + .module = THIS_MODULE, > > I thought platform_driver_register() did this automatically? For the platform device itself, yes, but this is for the PMU device - perf needs to take a reference to the module, otherwise the platform device can still be pulled out from under its feet. I can't remember if we ever discussed making perf_pmu_register() do the same trick as platform_device_register() and friends, but obviously it's a possibility. Robin.