From patchwork Tue Jul 11 08:24:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 118330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp334500vqm; Tue, 11 Jul 2023 01:54:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlF7B9aaQ9KT86a6Toegevt8XQgBmLKD7BsahLMwbG7rwBVzAZPL8X3D3fWHC+r4WRUvsKNF X-Received: by 2002:a17:906:101a:b0:994:673:8b00 with SMTP id 26-20020a170906101a00b0099406738b00mr4828615ejm.12.1689065672669; Tue, 11 Jul 2023 01:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689065672; cv=none; d=google.com; s=arc-20160816; b=K5mY4t7s3+pi2MlX61QwZDLSTk4Q/xsMJAcLBf9QEEXb2PpYwfmY+ux4cH4/5UnUfd SE1AGRPxBNRTMyIWBNnnn/0UVSR8zzVJp4xzuX1R7WLKEbfxK7OCdmd0x1mO3gpicZ5+ DALmWcWoOvABJU4gh3QKgRbhclRopfK1SvNSWaU9GJxZAF/+9h9bVVNTpEsQLiSB8oko N/G+koxaRfkIi2Q2H/v0TgZJMBonlWtKKoYBD4UQnP6IZGFwqQrOU88jIAA6ZI0ezHjn GnR/4M7aygt0mC4HRS0TZqkAin7XjfkoD7S6Teh8NnpvHrJn0RgPD5rrimmpx+p2AOwr Pbbw== 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=/Mpa2cNZbtMlDRNvsu0vhgj+3dSVygIdmCi5oMT8SyQ=; fh=uKDf5R1eKBEpFB2sP5rwFdsisg1sKNqEQFf4Rrsmuig=; b=OUXjUsMD9VQ0Qek86bo/DxAD2bjmA2RbK5QN5hxZPnk/EtOO6DRpiognsWKs314wBX jHhvOyTuKDiAIOpv7UgnctBKKFe+3411xs0pd/2MNeVyodkwMDgoxwj2SfvrIL+AUwXp TLLzGbeRWd1FSrRV8hVeZ8DU232ZD8rXkAifiTEiWeLrDvde2TBhjIaAzy/iuXJ+StOu 5AhS2mF251udT//0UmiUsXnydkjd+8ik6Kb7bQEMKz30RxeItRjWMgAT6Z6o0SCicGk6 BR/azUU72ADNjKsA9Wf/jCBrowLo/OnrqjCa4jlsNQq71z45nOQqW+kgRjiKldudJUVA oZzA== 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 lc9-20020a170906f90900b0098678728b52si1457488ejb.123.2023.07.11.01.54.08; Tue, 11 Jul 2023 01:54:32 -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 S231348AbjGKIZZ (ORCPT + 99 others); Tue, 11 Jul 2023 04:25:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231251AbjGKIZS (ORCPT ); Tue, 11 Jul 2023 04:25:18 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F14F5E6A; Tue, 11 Jul 2023 01:25:15 -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 C0093D75; Tue, 11 Jul 2023 01:25:57 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.47.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9C4E23F740; Tue, 11 Jul 2023 01:25:10 -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 V13 - RESEND 01/10] drivers: perf: arm_pmu: Add new sched_task() callback Date: Tue, 11 Jul 2023 13:54:46 +0530 Message-Id: <20230711082455.215983-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230711082455.215983-1-anshuman.khandual@arm.com> References: <20230711082455.215983-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1771113726607986652 X-GMAIL-MSGID: 1771113726607986652 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 Acked-by: Mark Rutland 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 f6ccb2cd4dfc..c0475a96c2a0 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -519,6 +519,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); @@ -865,6 +873,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 a0801f68762b..3d3bd944d630 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -102,6 +102,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