From patchwork Mon Jan 23 12:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 47135 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1593565wrn; Mon, 23 Jan 2023 05:00:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXv5bBLcWhNn4KI3veBGVY14Mpio3iy91cVFX0elYZr2iS9Ir+4X+CdqOcvyD+Rq6Hgbl/hY X-Received: by 2002:a05:6a21:8cc3:b0:b8:7d27:2cbd with SMTP id ta3-20020a056a218cc300b000b87d272cbdmr24086428pzb.43.1674478847539; Mon, 23 Jan 2023 05:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674478847; cv=none; d=google.com; s=arc-20160816; b=I/iLxiuUDS8B5zyrV67N3pQ+MxrO4YYx3n4jrzVy4BK8J1BEWUDP0n1DwUJc4sUdNz xii60ma16+sCVSLwj2ouXPsEpJtvl9ClI8w6tnHNzfVEnUZuCbrPAWM8Ed8otUQeMsEo AGASSIIFF/HaDqkNwcHrKb3O2NmjVeUirhBAz8JfwTjmTfU/Qy2q1keRfaX4IpTRsZ+F 2p4vBK70m6o37UW7aPAYdnN1hdWhKEo6r4GDHWC6orFNtu5oX+KI7G3Cp9KMEX6u8PRN r0qSas6sPP0ZVphboOTKEpI/s/UwTaC5O7PkeB6C3GXiJOq4e1bup1yx/MX7wn6rgixA Y/nw== 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=xs5VWTSXKGFiiwYEvM57LxHeWTIQYdmA93tFzUfr8dE=; b=tHlIhtAb5jSS20YpUZ8c0zuLOTXgoCI+K5Qrwk3EMYrcxKg1dl0RoLAQlNj8Eea2xw mu7GQ05wSkfDliwBt8wWysfANsOKaUc5EaTNWi2nt70MIm2/Kp+g/zns5s30bkdIDux2 XA+fQpuDv5HTdKevHAy/hs/gsBp+H71JodmKS0fVu3sapUjgmckr/R8FrOykzNv/RObW sQiqc1pIjjJJeE99afeAPYdYP7ZDQKOlWfAWnFZNxgvzWQvLnSCics44VucrLFVbRy68 zsSoHeUfBzo2byqmgZAg9xuteSVNflOZOO8ILMh969NqwDqMVb7PMRC0KMWWqAckOysC xuBw== 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 6-20020a630d46000000b00478d123064esi49542992pgn.401.2023.01.23.05.00.34; Mon, 23 Jan 2023 05:00:47 -0800 (PST) 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 S231613AbjAWNAT (ORCPT + 99 others); Mon, 23 Jan 2023 08:00:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbjAWNAS (ORCPT ); Mon, 23 Jan 2023 08:00:18 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F31810E9; Mon, 23 Jan 2023 05:00:16 -0800 (PST) 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 D4662143D; Mon, 23 Jan 2023 05:00:57 -0800 (PST) Received: from a077893.arm.com (unknown [10.163.50.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E36FC3F64C; Mon, 23 Jan 2023 05:00:10 -0800 (PST) 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 V8 1/6] drivers: perf: arm_pmu: Add new sched_task() callback Date: Mon, 23 Jan 2023 18:29:51 +0530 Message-Id: <20230123125956.1350336-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230123125956.1350336-1-anshuman.khandual@arm.com> References: <20230123125956.1350336-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?1755818332039944633?= X-GMAIL-MSGID: =?utf-8?q?1755818332039944633?= 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 9b593f985805..14a3ed3bdb0b 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); @@ -873,6 +881,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 ef914a600087..2a9d07cee927 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -101,6 +101,7 @@ struct arm_pmu { void (*reset)(void *); int (*map_event)(struct perf_event *event); bool (*filter)(struct pmu *pmu, int cpu); + 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