Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1117905ybh; Thu, 16 Jul 2020 03:45:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypnwaC0LB6INf61Vrj7wbi9rLInIrEeIuDbyfRw0QNH7HR4HcByJbxAK8JttJv4yCBJ6bu X-Received: by 2002:a17:907:94ca:: with SMTP id dn10mr3058121ejc.348.1594896327815; Thu, 16 Jul 2020 03:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594896327; cv=none; d=google.com; s=arc-20160816; b=Tnym7RHCr6SGXLO61RE+/BbP3JE/OkX3ymLug0PuqYE/PelGxYks/35a4XeKGwxqVV fdWEorrDI4yRHhcm7SX+CKaEqeCyyJh2TbeWt9BhYLYUzf/a3zp+Na12Rbe2/y0pk2fh mVRcteDxBr78o2cWJxV+LRIjdYnVoYZz34JtWHT1xmeCREZU6rhhLi/HrUmJf4ppOe9+ kLB5Bx8QeJ0coEjPecj4O+SZgiYvByYm2ZP95wJgR17FLZStaDoH45UKIbMvr/y6OL0k Rwk8IVlUFNhYJFZ/EO5aPCSA703zKwuO5PmznE4D4xZD9Nza8G7IyXo6mSn4F6C8ZkTv eL1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WeVnkrLKJdMDTZQeJnN0DmxBwyLapXgeSLTbix6DuOc=; b=alLhutCxrU0V897ayRmjqxivgeVvGggQ4VOM1BfGhKDFkKTS6XsR/Ux/IfU3XKhFU6 O9NhMnqS7fib8ryVK8kfYtG+NWB6xkbnUb0jy2WDUakI/zymg4ShEnBfdH6OD03d+txM AHOa0FfzkJiDUxV6sCSbppksMtjf2En8MBkiBxzStMTsq29ZVIlJGnAqQrtz4VhzgsF+ lASKq77H90l0HpbgsdbKAp2KKExTJHpq4gMDdxaYuo5tK96kg/d64wFi2SzGJKKxTvxQ HZEuTi38rmmFaz+dVChlsZfT2h/mij6rYYrTMLGyNZUxUQ39MlwgaVzrtoGgIEkUyTeY qCWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wbHHfi8M; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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.45.04; Thu, 16 Jul 2020 03:45:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=wbHHfi8M; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727908AbgGPKo3 (ORCPT + 99 others); Thu, 16 Jul 2020 06:44:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbgGPKo2 (ORCPT ); Thu, 16 Jul 2020 06:44:28 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1227E2074B; Thu, 16 Jul 2020 10:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594896267; bh=0hj6bf/11UNfcoH3gx2faowO8OLAqFEQtxN4gfhnb3o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wbHHfi8M+sTXzKWGMJ1PMbNftI15CwTZ/8V9oUY2K+skYR3sGQYv90gA0OTqY36jQ IcK4sJzuehQlvsslQpLrNSlE3iuBdZrsGxmSuZxdpdKrt/Zhxw12YGVHqeYILEfbY9 yysFshj96lAxN4lMd2gQtIdP/LUE64sEeQolxzyc= Date: Thu, 16 Jul 2020 11:44:22 +0100 From: Will Deacon To: John Garry Cc: Robin Murphy , Qi Liu , mark.rutland@arm.com, linux-kernel@vger.kernel.org, linuxarm@huawei.com, zhangshaokun@hisilicon.com, wang.wanghaifeng@huawei.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] drivers/perf: Fix kernel panic when rmmod PMU modules during perf sampling Message-ID: <20200716104422.GF7036@willie-the-truck> References: <1594891165-8228-1-git-send-email-liuqi115@huawei.com> <20200716094144.GC6771@willie-the-truck> <20200716103058.GE7036@willie-the-truck> <66a8eb37-b91a-d228-4ea4-8601e5518b31@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <66a8eb37-b91a-d228-4ea4-8601e5518b31@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 16, 2020 at 11:36:10AM +0100, John Garry wrote: > 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. I guess we have to throw in some '.suppress_bind_attrs = true,' lines as well, then? I'll queue this as-is, but happy to take a follow-up if somebody can test it. Will