From patchwork Wed May 31 04:04:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 101221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2630222vqr; Tue, 30 May 2023 21:26:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4sqKmiGtru9mK4ne+QW9ArQyPgDAOH+8KHcHXGf4VP+pfDS2DA2DQH7TAtBxlMh8jMO5IG X-Received: by 2002:a0d:f3c6:0:b0:568:a870:314f with SMTP id c189-20020a0df3c6000000b00568a870314fmr4970530ywf.30.1685507183564; Tue, 30 May 2023 21:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685507183; cv=none; d=google.com; s=arc-20160816; b=Y+lJyYe3sPclcl/ZAOqLp4LVsHYVdg/BpKRoT+KTsLdB6OwxuKds05PUuKoCjiZFkD z8UgdUcR0vLYp17GJMJZW9ZirX5wOj32fqV4tLpLJzNci2GZEsMYjjJ2XqyRqIQpFCKq tNFzVzRP3AlM/7/tdsoXbtnaQ/yKm3omRmloMwEsEYimeCapsAhrtEf2QQNMAXgXRkLt kzPC7gDas1iDtctgTQn1EFqcMRewk/X6UW/Ri0nyvTWUwGWli+OF3Fd1Xtzn0ie38oI5 dy/yvEJyHTZZmH72eBeQuKqObQhyU1Y13pXoyklE7wpvsSUOwG4oLZQrmgDBK+s0HZSk ym8g== 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=IPTSnlkPjTSGS6O7j/v1RRpRTPcMzBWksWREu64LHFQ=; b=01ptjpUrlFzp7C/aoSNKE0mTkO7tuo+Hm12sbGi28gql8tNy4ZZ55YlX9dIjsX/2E9 UmTFhq8EMnpAGWNkf3M6L/GHHCM5BnBbwUJgjRt4rhV0id+dAkWKSVdgtQTTahbdZtUg 1R7GCpgAwnbsy52whXrgL1/yEwnfSYAv/2UiOSNyB3jV5SPML6l4L4LF014VmCN0IX2Q C9AJTyL+458+FfogVcdlL+UPlLsxU7jMJ+yuCBXnUYDHOHdpfnhd2xNsP1+3c/Owfueu KrOV5oTNVtf1QC1YN6x240Wz7XHzlVIys7LpwfFpBSGmY014ennqw2jR3+tUr09s9S1l Lwgg== 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 w28-20020aa7955c000000b0064d3e651979si633336pfq.233.2023.05.30.21.26.11; Tue, 30 May 2023 21:26:23 -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 S234223AbjEaEFJ (ORCPT + 99 others); Wed, 31 May 2023 00:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233995AbjEaEFD (ORCPT ); Wed, 31 May 2023 00:05:03 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C04211F; Tue, 30 May 2023 21:05:02 -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 3811D15DB; Tue, 30 May 2023 21:05:47 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.73.163]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9BF413F6C4; Tue, 30 May 2023 21:04:55 -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 V11 01/10] drivers: perf: arm_pmu: Add new sched_task() callback Date: Wed, 31 May 2023 09:34:19 +0530 Message-Id: <20230531040428.501523-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230531040428.501523-1-anshuman.khandual@arm.com> References: <20230531040428.501523-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,T_SCC_BODY_TEXT_LINE 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?1767382380053104399?= X-GMAIL-MSGID: =?utf-8?q?1767382380053104399?= 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 Tested-by: James Clark Signed-off-by: Anshuman Khandual Acked-by: Mark Rutland --- 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