Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1114595ybh; Thu, 16 Jul 2020 03:38:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztH1mKHud0ZXwJjj3qOkkYfCwwNA64aE6vboDcExuSmy7MBna9TdzJW4lY4aoSbiUSPdd+ X-Received: by 2002:a17:907:10d4:: with SMTP id rv20mr3211076ejb.413.1594895912995; Thu, 16 Jul 2020 03:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594895912; cv=none; d=google.com; s=arc-20160816; b=FMmdbp/61pAVcz0jpqjgXPyyN4z2xEMp4psue26ubcub7GOnsgNbAMpNWkHYg9I9/P jHOIVe9V+XA/KU1DcURbckkwT/HleVUiorK9ZB9evKSMD5/pODkFVKNG2kkFiFRti6j4 xBtCdXUcULqMMUleANXJ0/eNw8cBdgvqp2noTmcCu4ZJ5lYX2NDivfmnfsO72h9NjEEB ypwsnO1OcbdEW128nxshKIk2+j6JgTPPbxxP2hCP9x9ucfHetVCRvIx4LeQDSC48XbNx GToqNzBNGzIY6gmJmpxE/RSRNDsi4fC5U+HLT1qHeWW0MH9ixvStt8mCJ0XNEIzyjuLK Xi+A== 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=xyL6KD/qsjsaG9qexWv53vMaItUkkeEkMC9jm+9glQQ=; b=F5ooyCcw+6oYSNKfKnVTtf1JJiyM3Xoi2uj9LiHmetJcGAcYBhcbS0IVtMX971wQjB aMUHQakWzegK4qzFTdptTJ9oBHzDxtU7dFBkEMVZWEYN8318UAqS9Goae8rT2VePTAwP CDIqIdAFM7asgBGlJvOMULt8LS/g8xlB/Q80ccbhP4Su1S/rE53zf+NFajFHNmdpL0pX RYhjkDOgu75quRXnTumqyhKZHry5K7OwhAv9XiQ10h55+K0OCUqeQvwIiqxQEczUI7pk iBbcO5+X0vKFLSR8aD8jqXh8iFqjHprbWmXB+iRGNwZm1uwcd4027DaYwie9vxtqklSr WVcw== 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 q26si2826198ejc.433.2020.07.16.03.38.10; Thu, 16 Jul 2020 03:38:32 -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 S1727924AbgGPKiA (ORCPT + 99 others); Thu, 16 Jul 2020 06:38:00 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2488 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726894AbgGPKiA (ORCPT ); Thu, 16 Jul 2020 06:38:00 -0400 Received: from lhreml724-chm.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id E3D58E3A008D52B700C1; Thu, 16 Jul 2020 11:37:58 +0100 (IST) Received: from [127.0.0.1] (10.210.168.254) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Thu, 16 Jul 2020 11:37:57 +0100 Subject: Re: [PATCH] drivers/perf: Fix kernel panic when rmmod PMU modules during perf sampling To: Will Deacon , Robin Murphy CC: Qi Liu , , , , , , References: <1594891165-8228-1-git-send-email-liuqi115@huawei.com> <20200716094144.GC6771@willie-the-truck> <20200716103058.GE7036@willie-the-truck> From: John Garry Message-ID: <66a8eb37-b91a-d228-4ea4-8601e5518b31@huawei.com> Date: Thu, 16 Jul 2020 11:36:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20200716103058.GE7036@willie-the-truck> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.210.168.254] X-ClientProxiedBy: lhreml714-chm.china.huawei.com (10.201.108.65) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/07/2020 11:30, Will Deacon wrote: > On Thu, Jul 16, 2020 at 11:26:25AM +0100, Robin Murphy wrote: >> 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. > Urgh, gross. > >> 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. > Yeah, but I suppose this patch is the right thing to do for now. I'll queue > it as a fix. > Please also note what Qi Liu wrote about being able to unbind the driver and cause the same issue. I don't know if you can about that issue also.