From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DED83C4332F for ; Mon, 7 Nov 2022 19:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LMj1id5P7Jstdx+dth9v5xr37TcLMDD4W2C0cbWEKyY=; b=mgIWCdL0/sFuqq VwPPTo6VeVnAVLt1BYq3q4nuySfmmbSraVvo9SJIOg6R2k4oWrTL4LK9nR9HFknOT6UX34BAVMUGU XUfdOS6o3Db9bfvfHHpHpQdba/d+kKgeJkNZJHo0RVWTFrtIJqp3PmWmRMvVSo8ktabLvhOcBy/bE vIkauPKyLIV1+hEPWOcvsay0GTnu44hR+wOBaNXB1LdL88qb/GrAvLcQbsRO+OODbCU74XN/cCN9Y UOrT716P8+CuMJjUA0vJ8XyVT7ulQIkrMHnstXC7TiDMjk3qYj0cJ4XML94H+PsP5s5zMuPC2lnQx yFuVNV4c80BCWUMxmnOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1os7XK-00HUEv-OP; Mon, 07 Nov 2022 19:11:59 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1os7Vo-00HT3R-ER for linux-arm-kernel@lists.infradead.org; Mon, 07 Nov 2022 19:10:26 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 950CB6124D; Mon, 7 Nov 2022 19:10:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E87A8C433D6; Mon, 7 Nov 2022 19:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667848223; bh=MOpxY7vKpkwXCycCleREKmkcHu7Y/TAh0DW87lelNg4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ac1OJaiFBh8JDOchjlQbPJwsKmvbuZYnDGPTg8ddSvH2Fi3MSwLFQwjdS5/J31qd0 08riqIJouBJkIDUSoa6GFuGt24XYK+Zq3ZI1YD6ZgQAh032dUKXKVAHoj1sa0dkVI7 ll/HvVpYh7jm9DzzLST8CYKjMoWy3bbqbhtdurFry01nlw0RxP9+6HghOiyObOqeAJ RVm+uBYZtxP0Qg1N3//HH3y1LybVW7c7azVzQIG7lY/PPjvZa6nLS/6cdrjoS9KAQk pdCkqu8vHJlc+LpxkJzn40Ec/mvCkemguWPYPKXM4/VjHVwTO/g32pui4kRPSBsSZs 4HrnqvMRMz/bA== Date: Mon, 7 Nov 2022 19:10:18 +0000 From: Will Deacon To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, pierre.gondois@arm.com, valentin.schneider@arm.com, vschneid@redhat.com Subject: Re: [PATCH 3/3] arm_pmu: rework ACPI probing Message-ID: <20221107191017.GA21991@willie-the-truck> References: <20220930111844.1522365-1-mark.rutland@arm.com> <20220930111844.1522365-4-mark.rutland@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220930111844.1522365-4-mark.rutland@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221107_111024_595259_5858AD80 X-CRM114-Status: GOOD ( 34.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 30, 2022 at 12:18:44PM +0100, Mark Rutland wrote: > The current ACPI PMU probing logic tries to associate PMUs with CPUs > when the CPU is first brought online, in order to handle late hotplug, > though PMUs are only registered during early boot, and so for late > hotplugged CPUs this can only associate the CPU with an existing PMU. > > We tried to be clever and the have the arm_pmu_acpi_cpu_starting() > callback allocate a struct arm_pmu when no matching instance is found, > in order to avoid duplication of logic. However, as above this doesn't > do anything useful for late hotplugged CPUs, and this requires us to > allocate memory in an atomic context, which is especially problematic > for PREEMPT_RT, as reported by Valentin and Pierre. > > This patch reworks the probing to detect PMUs for all online CPUs in the > arm_pmu_acpi_probe() function, which is more aligned with how DT probing > works. The arm_pmu_acpi_cpu_starting() callback only tries to associate > CPUs with an existing arm_pmu instance, avoiding the problem of > allocating in atomic context. > > Note that as we didn't previously register PMUs for late-hotplugged > CPUs, this change doesn't result in a loss of existing functionality, > though we will now warn when we cannot associate a CPU with a PMU. > > This change allows us to pull the hotplug callback registration into the > arm_pmu_acpi_probe() function, as we no longer need the callbacks to be > invoked shortly after probing the boot CPUs, and can register it without > invoking the calls. > > For the moment the arm_pmu_acpi_init() initcall remains to register the > SPE PMU, though in future this should probably be moved elsewhere (e.g. > the arm64 ACPI init code), since this doesn't need to be tied to the > regular CPU PMU code. > > Signed-off-by: Mark Rutland > Reported-by: Valentin Schneider > Link: https://lore.kernel.org/r/20210810134127.1394269-2-valentin.schneider@arm.com/ > Reported-by: Pierre Gondois > Link: https://lore.kernel.org/linux-arm-kernel/20220912155105.1443303-1-pierre.gondois@arm.com/ > Cc: Pierre Gondois > Cc: Valentin Schneider > Cc: Will Deacon > --- > drivers/perf/arm_pmu.c | 17 ++----- > drivers/perf/arm_pmu_acpi.c | 95 +++++++++++++++++++----------------- > include/linux/perf/arm_pmu.h | 1 - > 3 files changed, 52 insertions(+), 61 deletions(-) [...] > @@ -320,13 +320,26 @@ int arm_pmu_acpi_probe(armpmu_init_fn init_fn) > * For the moment, as with the platform/DT case, we need at least one > * of a PMU's CPUs to be online at probe time. > */ > - for_each_possible_cpu(cpu) { > + for_each_online_cpu(cpu) { > struct arm_pmu *pmu = per_cpu(probed_pmus, cpu); > + unsigned long cpuid; > char *base_name; > > - if (!pmu || pmu->name) > + /* If we've already probed this CPU, we have nothing to do */ > + if (pmu) > continue; > > + pmu = armpmu_alloc(); > + if (!pmu) { > + pr_warn("Unable to allocate PMU for CPU%d\n", > + cpu); > + } > + > + cpuid = per_cpu(cpu_data, cpu).reg_midr; > + pmu->acpi_cpuid = cpuid; I've queued this, but if armpmu_alloc() fails we now deference NULL here whereas we should probably propagate the error. Please can you send a fix on top of for-next/acpi? Thanks, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel