Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4048242ybg; Fri, 25 Oct 2019 12:34:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqydoF1EtBMjfybhMFcG679m/jyoU/YiNgvan/Bv3zt9AhlSKucn7rYz/3o79lNVUgC5nr4+ X-Received: by 2002:a17:906:e0b:: with SMTP id l11mr5061133eji.245.1572032042622; Fri, 25 Oct 2019 12:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572032042; cv=none; d=google.com; s=arc-20160816; b=zXZhDZuI0Sl3NP/AeQ/yQdD3K/j+db+w214opYWoCppRQg7gGlJ/uWppfXr+K1cgDV p03IcLAJWkDgWuND6QecxDfpWrutG9kQC3rDr/bLV2vdPQhak27TZKDf3IfBE4/jW2oB r0aSFMScD2ysuiyX3PMiusc5tqKhDbgA4bL4MgXjm/iUQCfS6/IrD4npyG3aOge2Jce2 Yjsw6226yZ0phx7ox90WKjc3boFxSd4pjSrYn7E9PaxSrBi17/ZL32ebgCr1qwLNzwEN aRyew8POKX837MKqVrvNQozBCs1GakCKyC040lBOjz3cySz59BiDCdDpmXhLdTaSeGwe nZFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject; bh=FQ+SG5gVVB+LTQeLHE5pDh5ZYzSt6Mq4wj1hDR7t6Fs=; b=ko/PMXpBciR5SjmwmBcNZKx2NMaekUIrPUFrNmyB6J1AY09MsXJcz8jEfrUC3nmso7 AZFaFevaFpS85FHlHA3atrRRcyEhratdnj0XxaQQVes78uTLBqXHZfr6mtShdgdFETiH ze1qWhmcxA/dPHwCYYFm5GwUzu0lN/bDRZoT4JB3zn9oAl/gE3x+nEGbFTNmCPT+0Ny9 i4YpDFTg7x62M/wwj3m9L0qQCK20ecp0cfPu+BPKyhiVap2abDCeseNheYvHCDRh3Biv FWQ4EF9EVVzJ/bt2B4rnccqe5TjwTqunAX1IqDkS3hSb+cgPL5vdfxJ5qcu9yJdvXfxU x2Jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si1745793eju.387.2019.10.25.12.33.39; Fri, 25 Oct 2019 12:34:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438186AbfJYI6O (ORCPT + 99 others); Fri, 25 Oct 2019 04:58:14 -0400 Received: from mga06.intel.com ([134.134.136.31]:14208 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfJYI6O (ORCPT ); Fri, 25 Oct 2019 04:58:14 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 01:58:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,228,1569308400"; d="scan'208";a="204500111" Received: from linux.intel.com ([10.54.29.200]) by FMSMGA003.fm.intel.com with ESMTP; 25 Oct 2019 01:58:13 -0700 Received: from [10.125.252.238] (abudanko-mobl.ccr.corp.intel.com [10.125.252.238]) by linux.intel.com (Postfix) with ESMTP id 14322580104; Fri, 25 Oct 2019 01:58:09 -0700 (PDT) Subject: [PATCH v5 1/4] perf/core,x86: introduce swap_task_ctx() method at struct pmu From: Alexey Budankov To: Peter Zijlstra Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , Kan Liang , Stephane Eranian , Ian Rogers , Song Liu , linux-kernel References: <6fa20503-b5ad-16c7-260e-5243509176bc@linux.intel.com> Organization: Intel Corp. Message-ID: <6750143f-f237-35a4-396e-0cc5c8a1fbd4@linux.intel.com> Date: Fri, 25 Oct 2019 11:58:08 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <6fa20503-b5ad-16c7-260e-5243509176bc@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Declare swap_task_ctx() methods at the generic and x86 specific pmu types to bridge calls to platform specific pmu code on optimized context switch path between equivalent task perf event contexts. Signed-off-by: Alexey Budankov --- arch/x86/events/perf_event.h | 8 ++++++++ include/linux/perf_event.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index ecacfbf4ebc1..5384317eaa16 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -682,6 +682,14 @@ struct x86_pmu { */ atomic_t lbr_exclusive[x86_lbr_exclusive_max]; + /* + * perf task context (i.e. struct perf_event_context::task_ctx_data) + * switch helper to bridge calls from perf/core to perf/x86. + * See struct pmu::swap_task_ctx() usage for examples; + */ + void (*swap_task_ctx)(struct perf_event_context *prev, + struct perf_event_context *next); + /* * AMD bits */ diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 587ae4d002f5..7887e4a3d487 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -410,6 +410,15 @@ struct pmu { */ size_t task_ctx_size; + /* + * PMU specific parts of task perf event context (i.e. ctx->task_ctx_data) + * can be synchronized using this function. See Intel LBR callstack support + * implementation and Perf core context switch handling callbacks for usage + * examples. + */ + void (*swap_task_ctx) (struct perf_event_context *prev, + struct perf_event_context *next); + /* optional */ /* * Set up pmu-private data structures for an AUX area -- 2.20.1