From patchwork Wed Mar 15 05:14:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 69966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2149858wrd; Tue, 14 Mar 2023 22:35:17 -0700 (PDT) X-Google-Smtp-Source: AK7set9bAxxMF+uWtWOhxnlSNF6btniUBo856R8S3eJ0KEzRYN8XahQ0ddAN24+f/S/3t6DF9Y/J X-Received: by 2002:a17:90a:73c6:b0:23d:15e7:e1a2 with SMTP id n6-20020a17090a73c600b0023d15e7e1a2mr8168023pjk.32.1678858517598; Tue, 14 Mar 2023 22:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678858517; cv=none; d=google.com; s=arc-20160816; b=TzI8UFDDzU1MDYvRaj0ytbzQLYJ/RP8vir6Eo5URfiFXBrYXRrIb8kmEgzGeFeF/b/ +iWCAnSbKjSBrTyIcFfwZljNizpNdrhtbfuCHEMNj8GuVq6MxQqNU6dhq5u5RMhuueJ/ 05V5/VuQ3QSkfnnS4pQjnq4XWVNduoGD7b9TX7CllotI23rHvFzmtwdcfWRdLegnJLIO y0tT8/wNhzwk981rNyRoti+uokDRiUF8QvVkqllPXW15JOSWKtWOi5pMZBM9hqfHa3WN d8W1szyRra/qLLWo0Iu6cn0jF9W0QIw5BSShwAz8PjWkTocsNksS2p1J/V9KSjvAHAGP gN8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=t01NXJQN680wjqFVU1PzgLBcJDqzA84Rf/5+e25Tpsc=; b=dukX/UsE8rvrNue3/pnPdWFi00FCKZ6hT/TiR5a+h+x8aAUUhlaGatuiTULa6SND13 krv492cE3DtSPtuO/diIz2pV6kjQAbpa8JbVe28HpPACp+zkbzGBxV0olyvKFayoVwhG g1qScYvxM9L5OXe3+tKlcplX3XDS7qX4MhrAxnU/dML8dz2mPpcAFGfNcKsulb8DdnK2 P42muBz+aNfr9HyG4g934VW/No99vdSek3rPi+P4M256T0k6Taq/8m/NJPZG5/Wws1xx 8eiChqZw9tzmbJ47CScfWqUPbS1TzveEgOPTBtVBaatcB6h/oa8TI04laTuA+Ldo0QU6 Uq+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a17090aa68400b0023d0131c21asi779317pjq.66.2023.03.14.22.35.02; Tue, 14 Mar 2023 22:35:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbjCOFRS (ORCPT + 99 others); Wed, 15 Mar 2023 01:17:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231511AbjCOFPr (ORCPT ); Wed, 15 Mar 2023 01:15:47 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1C6D539292; Tue, 14 Mar 2023 22:15:04 -0700 (PDT) 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 159C14B3; Tue, 14 Mar 2023 22:15:47 -0700 (PDT) Received: from a077893.blr.arm.com (unknown [10.162.41.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A07B43F67D; Tue, 14 Mar 2023 22:14:58 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com Cc: Anshuman Khandual , Mark Brown , James Clark , Rob Herring , Marc Zyngier , Suzuki Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org Subject: [PATCH V9 01/10] drivers: perf: arm_pmu: Add new sched_task() callback Date: Wed, 15 Mar 2023 10:44:35 +0530 Message-Id: <20230315051444.1683170-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230315051444.1683170-1-anshuman.khandual@arm.com> References: <20230315051444.1683170-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760410749352407363?= X-GMAIL-MSGID: =?utf-8?q?1760410749352407363?= This adds armpmu_sched_task(), as generic pmu's sched_task() override which in turn can utilize a new arm_pmu.sched_task() callback when available from the arm_pmu instance. This new callback will be used while enabling BRBE in ARMV8 PMU. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- drivers/perf/arm_pmu.c | 9 +++++++++ include/linux/perf/arm_pmu.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 15bd1e34a88e..aada47e3b126 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -517,6 +517,14 @@ static int armpmu_event_init(struct perf_event *event) return __hw_perf_event_init(event); } +static void armpmu_sched_task(struct perf_event_pmu_context *pmu_ctx, bool sched_in) +{ + struct arm_pmu *armpmu = to_arm_pmu(pmu_ctx->pmu); + + if (armpmu->sched_task) + armpmu->sched_task(pmu_ctx, sched_in); +} + static void armpmu_enable(struct pmu *pmu) { struct arm_pmu *armpmu = to_arm_pmu(pmu); @@ -858,6 +866,7 @@ struct arm_pmu *armpmu_alloc(void) } pmu->pmu = (struct pmu) { + .sched_task = armpmu_sched_task, .pmu_enable = armpmu_enable, .pmu_disable = armpmu_disable, .event_init = armpmu_event_init, diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 525b5d64e394..f7fbd162ca4c 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -100,6 +100,7 @@ struct arm_pmu { void (*stop)(struct arm_pmu *); void (*reset)(void *); int (*map_event)(struct perf_event *event); + void (*sched_task)(struct perf_event_pmu_context *pmu_ctx, bool sched_in); int num_events; bool secure_access; /* 32-bit ARM only */ #define ARMV8_PMUV3_MAX_COMMON_EVENTS 0x40