From patchwork Wed May 17 02:24:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 95002 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp837412vqo; Tue, 16 May 2023 19:50:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Yf4Em2M+XVYNYJDFIQzMNQ5vZ+ZH9ggNXRFkTPSA4aywhNBlscm1cnPYm3HahEX/OhgQO X-Received: by 2002:a05:6a20:549c:b0:102:6b0:a648 with SMTP id i28-20020a056a20549c00b0010206b0a648mr30574769pzk.4.1684291804122; Tue, 16 May 2023 19:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684291804; cv=none; d=google.com; s=arc-20160816; b=NMRZMkl/Kd40qWSF6vgO2wZd8gk+h06uvoBCfeNXJSQZnv2VnliXLGuo5FB9th10Al 3nJKl1CdQI36TKNaNzw/IqUi0iy8zsM+yYHVXNDriIyKpKZtChpwn9ZUc6mS5tJOYOPE vlGuchwdV6g1hiyh2WpaH4ncb8HwMmw/NTXIoLy2fEc8ga3EKYuCEaTZ7rFwPHriS+hv tsz7ZPEpurU0QEnvDpO1QRzTVMLam+6DE9z5X472MJ2Y6hLzDznZyE6aeykSsuRt/ZK/ 2a6NSoclD29TDQsntjVlz92W4XQeHczns0SXEcdL5d8fBw+6VK571GVwofLISKkzmSvy jJsA== 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=gFEBdpKKSssZ/xQhBjdn3bJCL9NFhO3R0DjMR44p5tM0obU7WrLxCfinTmrDnPYM/w D4YalwENW5Ca3DixzzWdfLLoZDGmz0FOygIODPFl7e1B6rfQOAAydm4yJ5mVB0ebmQFl QGKeoCG3S4MymWkRmirDEeE+oGmZq49OiXy6Kyysm9aRv53jV9DqK8wtntqdr0WA3Wgx 2ZeC4jGlNYxTH+Qgrrfx+pM7sTuO58kC8D2kiab1sF4BaRms4qiQLqVjJteyNJB6qUUC 65BpUyUGCmSwrpd4vzb/pPkQ+OgNlRhEGZqw8Syk83TlsS0w3ffmbaYqdz8WMDXXaWMx mElw== 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 i133-20020a636d8b000000b005305ab8540asi17208016pgc.294.2023.05.16.19.49.51; Tue, 16 May 2023 19:50:04 -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 S231944AbjEQCYc (ORCPT + 99 others); Tue, 16 May 2023 22:24:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbjEQCY3 (ORCPT ); Tue, 16 May 2023 22:24:29 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 371BB448A; Tue, 16 May 2023 19:24:28 -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 A97D12F4; Tue, 16 May 2023 19:25:12 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.70.237]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B16713F793; Tue, 16 May 2023 19:24:22 -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 V10 01/10] drivers: perf: arm_pmu: Add new sched_task() callback Date: Wed, 17 May 2023 07:54:01 +0530 Message-Id: <20230517022410.722287-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517022410.722287-1-anshuman.khandual@arm.com> References: <20230517022410.722287-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?1766107962793894634?= X-GMAIL-MSGID: =?utf-8?q?1766107962793894634?= 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