Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4055613ima; Mon, 4 Feb 2019 09:26:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IbI81qzDm7QTaATcuVh12tchcBummqIXjzTwn6KQ8+pM3De+mQe/FlfQkllGxT/7bGMx3Z2 X-Received: by 2002:a63:231a:: with SMTP id j26mr400725pgj.185.1549301212130; Mon, 04 Feb 2019 09:26:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549301212; cv=none; d=google.com; s=arc-20160816; b=Zs5Kq5UyHcV+NneZDWT1Sr0Z63VgBwUC7SmdbBiJBExkabKoD7BV0EopHd1cQ6237Y JJHu5VB4812fmPkJ3Wp5tlTCXdtyxSqFb+DKfVTsHazcZ/3kU56GWjHW0TqJcxLCb9A+ 7gtbpwwOaZ6IWicf9niECYtDRc6O0uaObXZiXXePacQilBs6ixSbB055MZwGaIipLcm+ jDxiLKzytsKwwcJuf12QqjxsCVPLFDZlbngHYAqLaurFWtxLZyduoDOZ2oj1+HEkiUWW CanJeXzUrRScWmCJMiepTTrw0PUJ9tlI3YJr+qMPv1lq834xNbfuLExE9FrJxqmAmqzi d1Lg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=q+ThPgD9kdp5xsuhrURe722rgfTDkkGGOe9O8X8fd7I=; b=FTpliq3WvuC87+wSbbIA0RMzOc/pMriiF+c1SOqvcPl0uauyhPgbGLMwVgJq9UhMG8 WGjnrYmUw2bTj/J2Dn0pCdAJcViN6dl3m34hUdbPACyAEZZ0v/vEmmhlhw5VOBVnW/a+ voG5pJ1sxoUMjRsMgRcdZp4oMYwm52lUTjqV6PAoXNcxElYRfJA9oHWADKaXjJDjDFtk ZD+Ug7rD6l9en0051eVxf3/AsOVwXoFgzhUXYR6u9dvR/pyadEvJsBZmzDZTVSNY2zFG pXJNg12LKyiRzPbOG0zDa+PsTu0JIKhUn7BazDz9Yw4y7MZisIy+NgCaUhIBCVv1NRBj 3vrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si489852pgr.345.2019.02.04.09.26.35; Mon, 04 Feb 2019 09:26:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730632AbfBDRJv (ORCPT + 99 others); Mon, 4 Feb 2019 12:09:51 -0500 Received: from foss.arm.com ([217.140.101.70]:58702 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730494AbfBDRJt (ORCPT ); Mon, 4 Feb 2019 12:09:49 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D24151684; Mon, 4 Feb 2019 09:09:48 -0800 (PST) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 593A23F589; Mon, 4 Feb 2019 09:09:47 -0800 (PST) From: Robin Murphy To: will.deacon@arm.com, mark.rutland@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com, peterz@infradead.org, tglx@linutronix.de, bigeasy@linutronix.de Subject: [PATCH 5/5] perf/arm_dsu: Fix CPU hotplug races Date: Mon, 4 Feb 2019 17:09:08 +0000 Message-Id: X-Mailer: git-send-email 2.20.1.dirty In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Like other system PMUs which associate themselves with an arbitrary CPU for housekeeping purposes, arm_dsu has a race between registering the hotplug notifier and registering the PMU device, such that the hotplug niotifier can potentially fire and attempt to migrate the PMU context before the latter is valid. This is easily resolved by inhibiting hotplug until both the notifier and PMU device are successfully set up. For the same reason, also suppress any synchronous notifier calls in the cleanup path if PMU registration fails. Signed-off-by: Robin Murphy --- drivers/perf/arm_dsu_pmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c index 660cb8ac886a..cfaca06b964a 100644 --- a/drivers/perf/arm_dsu_pmu.c +++ b/drivers/perf/arm_dsu_pmu.c @@ -717,7 +717,8 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) dsu_pmu->irq = irq; platform_set_drvdata(pdev, dsu_pmu); - rc = cpuhp_state_add_instance(dsu_pmu_cpuhp_state, + cpus_read_lock(); + rc = cpuhp_state_add_instance_cpuslocked(dsu_pmu_cpuhp_state, &dsu_pmu->cpuhp_node); if (rc) return rc; @@ -738,9 +739,10 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) }; rc = perf_pmu_register(&dsu_pmu->pmu, name, -1); + cpus_read_unlock(); if (rc) { - cpuhp_state_remove_instance(dsu_pmu_cpuhp_state, - &dsu_pmu->cpuhp_node); + cpuhp_state_remove_instance_nocalls(dsu_pmu_cpuhp_state, + &dsu_pmu->cpuhp_node); irq_set_affinity_hint(dsu_pmu->irq, NULL); } -- 2.20.1.dirty