Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp446009ybg; Wed, 23 Oct 2019 00:12:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZTmOg0bxr/3A9JAi8moiWZaJJbegDVVeuK85UkEuN5/vOP/D5MIvHZZndhX3+DjafFsub X-Received: by 2002:a17:906:556:: with SMTP id k22mr31242396eja.66.1571814762997; Wed, 23 Oct 2019 00:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571814762; cv=none; d=google.com; s=arc-20160816; b=Q08c9Z+9uGmB37s8/wx+lo82+m0cfRA9CgRBwiwGQ4DoxtZFOnpaWBqkWcqnc/pjds TUxFja6p2Gw3ehiEcAaRIjvojS9WGaf1kz8Hr9SRXU1kh26QHn1sqTksa6Ts+3lJCoBc HEE32WDnEJUA/g+LFeB0LCw98kKyR1mqSPaRgHuzr63lHZCTXqr3KB3M3GTZ3+trBsMj CHSS4pXqsX/nY4MpsLQ23eF0L8NS62CGFqo/52+DGDzq5U2gFgAqfVSiAs5kYbji1rSa OpcygizoTEMZ4i7xTzUsn4xgWAj6Oypvc9b5jmoNUWCLUb5p9axvxPQbJjLswJzeJwjK NS8g== 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=hq71AZyd4dAFbj2qvK7LQ4MrI35ikGiLLcGnu5sm265gWJbomn5RBiVjOGU9avOWtN UJjlNFEYGUmmL9CKIkseBS5g1ei4KagrJRBU8xPVx5iS184YqRFMZpPVX4fYNATCC7g3 6oVGMJqwJXdBv1OEyMGFsGoRXcKCKvCXCEmZlzTWsuCdUjYmaVZ1a4l5KY8uluc5S8Rx XWL7T2D9+idAnP/r1M9PfO/Iklb+lyNukvBFRXcMuYJaONts42RnoqpSABgTiU0KvEq0 Q3HF4FK8gIS5mCXJck/MQklVuweMZETQOsvTRhj6DtVO8Cl7Nc8zy8eNaAASmEnlSOdC MuMw== 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 b50si14549340ede.28.2019.10.23.00.12.18; Wed, 23 Oct 2019 00:12:42 -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 S2389741AbfJWHLK (ORCPT + 99 others); Wed, 23 Oct 2019 03:11:10 -0400 Received: from mga09.intel.com ([134.134.136.24]:58107 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389733AbfJWHLK (ORCPT ); Wed, 23 Oct 2019 03:11:10 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2019 00:11:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,219,1569308400"; d="scan'208";a="201047833" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 23 Oct 2019 00:11:09 -0700 Received: from [10.249.230.188] (abudanko-mobl.ccr.corp.intel.com [10.249.230.188]) by linux.intel.com (Postfix) with ESMTP id 282BE58048F; Wed, 23 Oct 2019 00:11:05 -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: Organization: Intel Corp. Message-ID: <9a0aa84a-f062-9b64-3133-373658550c4b@linux.intel.com> Date: Wed, 23 Oct 2019 10:11:04 +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: 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