From patchwork Thu Jan 5 03:10:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 39286 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp94207wrt; Wed, 4 Jan 2023 19:13:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdkTXssH+evSYckIpkpfTRn6SGxeaIRqFxIuiqNzh700KnczC5FpEoqRkJGAMkM7+lkKna X-Received: by 2002:a05:6a20:b70a:b0:a7:9e22:8cc5 with SMTP id fg10-20020a056a20b70a00b000a79e228cc5mr51697082pzb.29.1672888410749; Wed, 04 Jan 2023 19:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672888410; cv=none; d=google.com; s=arc-20160816; b=seCBM954dIoMJrC9duWD74uoHdOVY+vEpYXuvuCB1UDBvd3tHWpFU5LTOdMbLxfBet 9lSfizkGpNDnALI7PzF1CBrQDd1JCGntnvdA/lGEOZxN4M46TZSHUEtBM77QEgTNI9jE 7Pv9Kt2ZWXyeHfeIXFoAhWIhnajXv4pZtcdO4ArcnIuWRCy7V7UOCwUn3JuJphl3UAyw /XDTkUanu6Wk+9N7ptG2dKvyQA+K7Y/0+SHwBrUtmmJ/D/fESW9KE0RrSDLEmbeQX+Ak as7qPjZND05/rDp2/2WGiMvz2PrqyNJs8h/IQcTEgl8ELYqQCXTBfcJ2pbDFrrzDYzk5 tFfw== 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=B2LWDpLw53ndXb/9lP2m+JuT0G7Ddr+kYIis+zJeTeZULw0L9/wloRBYNvM0XO4Yw5 8bg/YslUTRZhBsffyaySRY7B53u/sdj32V0Cvkghd8Fq5+e0SNqQPNpvAv3AC51BRBya ZOuiYOyFAyOm59wuVQLQE9jkRqONqdFuq1AAI0RTm1vD5FJCdxFzPGBcKpL4KPJ+BBqC wRcb4F9ecSkmf4rYRAo6s7EZZLJDrGKfyOEzth8zd6UPerQ1AOphWjmEmDSW9aQ+Q9rb UDKECu/AXK9hKboy165N8phzd4ZjNnYiQsPg9VDzdom4sa8N+EFe9g2wl2pxx3om2AKh KqNQ== 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 s123-20020a637781000000b004a3510effacsi8856772pgc.222.2023.01.04.19.13.14; Wed, 04 Jan 2023 19:13:30 -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 S229910AbjAEDLI (ORCPT + 99 others); Wed, 4 Jan 2023 22:11:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjAEDK5 (ORCPT ); Wed, 4 Jan 2023 22:10:57 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 200E3178B9 for ; Wed, 4 Jan 2023 19:10:56 -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 A240F15BF; Wed, 4 Jan 2023 19:11:37 -0800 (PST) Received: from a077893.blr.arm.com (unknown [10.162.43.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BADB93F663; Wed, 4 Jan 2023 19:10:53 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com Cc: Anshuman Khandual , Catalin Marinas , Will Deacon Subject: [PATCH V7 1/6] drivers: perf: arm_pmu: Add new sched_task() callback Date: Thu, 5 Jan 2023 08:40:34 +0530 Message-Id: <20230105031039.207972-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230105031039.207972-1-anshuman.khandual@arm.com> References: <20230105031039.207972-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?1754150638433927225?= X-GMAIL-MSGID: =?utf-8?q?1754150638433927225?= 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