From patchwork Mon Sep 12 15:51:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 12973771 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 8BCA7C6FA82 for ; Mon, 12 Sep 2022 15:52:46 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=AZFeqLMgzU1zWTfkatMvgzW62IpOfNKwJ73cmpMqei8=; b=gQRM8R5x6oVrWG SwTVa8E1nGacj/tE05G2EJoj8m7BAQ2Ri3r/DtbeovS0C5MvGNCu3jfh1Ro8ktAYLNk/koJIQtJo7 2GwRS24NGdyObDzKmbniCsGfee8c4Wu0iSAr0r/28tSU70UtGC3aios66Xt11ovH/QVVHMINSW+8a tKHvc+gkE++pCbUj5QP1Rr9VPzOPMy4L8jnM3OooSLJc3Di+JqUMG6A9cRQ+mOvrtTfwOpnAeQbcV 7pNVXOgACt3ecnQ5itvIn+TMXxSh3EQ2BhcHCafgA5I5gh8Ib7IgIB7ppBFIhPlPDYdMuYXLTneBh sVx+U64FwDacgUxFUfHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oXlin-00BGHJ-PO; Mon, 12 Sep 2022 15:51:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oXlij-00BGDh-PO for linux-arm-kernel@lists.infradead.org; Mon, 12 Sep 2022 15:51:39 +0000 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 6B655106F; Mon, 12 Sep 2022 08:51:38 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.78.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 006923F73D; Mon, 12 Sep 2022 08:51:29 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Dietmar Eggemann , Valentin Schneider , Thomas Gleixner , Sebastian Andrzej Siewior , Pierre Gondois , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH v1 0/1] arm_pmu: acpi: Pre-allocate pmu structures Date: Mon, 12 Sep 2022 17:51:03 +0200 Message-Id: <20220912155105.1443303-1-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220912_085137_911556_781B5BF1 X-CRM114-Status: GOOD ( 10.90 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Sleeping inside arm_pmu_acpi_cpu_starting() while running a preemp_rt kernel was reported at [1], and a solution was suggested at [2]. It seems [2] doesn't work because of the following: """PREPARE: The callbacks are invoked on a control CPU before the hotplugged CPU is started up or after the hotplugged CPU has died.""" Indeed the 'prepare' callbacks are executed on the control CPU and this CPU cannot remotely read the cpuid (cf read_cpuid_id()) of the other CPUs. Another solution: 1. count the number of different PMU IRQs (#IRQs) 2. allocate #IRQs pmu structures. There is at most #IRQs PMUs 3. in arm_pmu_acpi_cpu_starting() subcalls, after checking the cpuid, decide to use or re-use a pre-allocated pmu structure. Thus the pre-allocated pmu struct can be seen as a pool and all the struct might not be used. 4. free the unused pmu structures when probing is suggested in this patch. Freeing the unused pmu structures (4.) could maybe be done in a CPUHP_AP_ONLINE_DYN hotplug callback instead, but only one CPU is needed to search/free unused pre-allocated pmu structures. This bug is the last remaining among the ones reported at [1]: - [SPLAT 2/3] irqchip/gic-v3-its: Sleeping spinlocks down gic_reserve_range() Fixed with [3]. - [SPLAT 3/3] gpio: dwapb: Sleeping spinlocks down IRQ mapping Fixed with [4]. [1] https://lore.kernel.org/all/20210810134127.1394269-2-valentin.schneider@arm.com [2] https://lore.kernel.org/all/87y299oyyq.ffs@tglx [3] https://lore.kernel.org/lkml/20211027151506.2085066-3-valentin.schneider@arm.com/ [4 ]https://lore.kernel.org/all/20220419012810.88417-1-schspa@gmail.com/ Pierre Gondois (1): arm_pmu: acpi: Pre-allocate pmu structures drivers/perf/arm_pmu.c | 17 +----- drivers/perf/arm_pmu_acpi.c | 114 ++++++++++++++++++++++++++++++----- include/linux/perf/arm_pmu.h | 1 - 3 files changed, 103 insertions(+), 29 deletions(-)