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 X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17777C4338F for ; Mon, 16 Aug 2021 07:31:59 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5193E61AAB for ; Mon, 16 Aug 2021 07:31:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5193E61AAB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Gp5T85gflz3cP1 for ; Mon, 16 Aug 2021 17:31:56 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=AMXyeqEu; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::630; helo=mail-pl1-x630.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=AMXyeqEu; dkim-atps=neutral Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Gp5R21P2dz30GM for ; Mon, 16 Aug 2021 17:30:06 +1000 (AEST) Received: by mail-pl1-x630.google.com with SMTP id a20so19843091plm.0 for ; Mon, 16 Aug 2021 00:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m1IbMUZr64tIxxt6maNEwfTRa+n09Ar1wO7efkCJ4Ew=; b=AMXyeqEuHNtBMscgwnyTA78joUrPfoa2pTunC9/AnRKvb8qv+zI0fw/KmGVbq26LIb Bp4NCnL0hgXHK5SpB8oOCsig9bkgdeZBTtWF7CZ+yLsuecLqJZS6yzzfFYktQiUhMgif y/Nb7FA1mSvwaN8Vh6ZNq/AyNvMfbdjxJje2ekMq9o5I1OWDhPa489e3RfJgeL6J/Xzk A7fJ7cVO1ww5w8X26wqnWskKYPuzS7tmeFiRfWJ8lwHfnwCyGhkHJ5chpiWdAqTbNBUL LZM7BA2USlMX0WU1wesVAaSG686ySgfJt4FVZXTsMqedV3A8CJINFnlOoOW/yGNcafsx nSvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m1IbMUZr64tIxxt6maNEwfTRa+n09Ar1wO7efkCJ4Ew=; b=lI5Dv4UdyLpMWapTEEIeavCAbyZPXJyYA2l9XrwpTqk7qC+jqna4alpno17zkOpFzq aapcp/KGTVnMYS+dYpxCZy7yRy5AEkOZKS9Wi8GEDCiNrxn+sIGJLMFUqlounmck6a4T 3Gn7ynFvDPFzF8RQ/HS57/4n6UEwild/bd6lJ7qefUd2Iq/M0tKMccUvUv7dIoqzJJCd XIbq0SdeJ5cALh0fdvKBTaSpGd7EQF0g1PCauvJN+aeVzUE1yx+3v9iqwVnJFXlcN/EP 2FhbyvviDzTbjrx3niW8TLJI0Xtr/yxUyvz7FIHRiMOOW1TvY86SVZ5LSzo4FmfF6jK3 jzvg== X-Gm-Message-State: AOAM530e6ijl0+8LXK8SxKRBtkKrE+X5Z6JLz/35OajYfCUDrkLpB6vQ 4bQApM/6MetrXo7QSDYSJ8e1SfpQDXU= X-Google-Smtp-Source: ABdhPJyfJ1YadIr6QV0wtXW8Imm31VJojJD/PoV3JIjnefR2GFvgF8H+w5d66lg0wvy/y78WcofvDw== X-Received: by 2002:a62:ee11:0:b029:3e0:88dc:193f with SMTP id e17-20020a62ee110000b02903e088dc193fmr14696710pfi.78.1629099003867; Mon, 16 Aug 2021 00:30:03 -0700 (PDT) Received: from bobo.ibm.com (203-219-120-52.tpgi.com.au. [203.219.120.52]) by smtp.gmail.com with ESMTPSA id e7sm10543887pfc.145.2021.08.16.00.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 00:30:03 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v1 2/4] powerpc/64s/perf: add power_pmu_running to query whether perf is being used Date: Mon, 16 Aug 2021 17:29:51 +1000 Message-Id: <20210816072953.1165964-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210816072953.1165964-1-npiggin@gmail.com> References: <20210816072953.1165964-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Athira Rajeev , Madhavan Srinivasan , Nicholas Piggin Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Interrupt handling code would like to know whether perf is enabled, to know whether it should enable MSR[EE] to improve PMI coverage. Cc: Madhavan Srinivasan Cc: Athira Rajeev Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/hw_irq.h | 2 ++ arch/powerpc/perf/core-book3s.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h index 21cc571ea9c2..2d5c0d3ccbb6 100644 --- a/arch/powerpc/include/asm/hw_irq.h +++ b/arch/powerpc/include/asm/hw_irq.h @@ -306,6 +306,8 @@ static inline bool lazy_irq_pending_nocheck(void) return __lazy_irq_pending(local_paca->irq_happened); } +bool power_pmu_running(void); + /* * This is called by asynchronous interrupts to conditionally * re-enable hard interrupts after having cleared the source diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index bb0ee716de91..76114a9afb2b 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -2380,6 +2380,19 @@ static void perf_event_interrupt(struct pt_regs *regs) perf_sample_event_took(sched_clock() - start_clock); } +bool power_pmu_running(void) +{ + struct cpu_hw_events *cpuhw; + + /* Could this simply test local_paca->pmcregs_in_use? */ + + if (!ppmu) + return false; + + cpuhw = this_cpu_ptr(&cpu_hw_events); + return cpuhw->n_events; +} + static int power_pmu_prepare_cpu(unsigned int cpu) { struct cpu_hw_events *cpuhw = &per_cpu(cpu_hw_events, cpu); -- 2.23.0