Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7298745ybp; Wed, 16 Oct 2019 06:49:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHWLGiAnZhT9Y6Ln0A7TODTOTjOGfNlk4F4K5Zu8T5Xde6Kldoj4xWdtnHznN0UlyBH8z+ X-Received: by 2002:a05:6402:1b91:: with SMTP id cc17mr38743094edb.180.1571233765307; Wed, 16 Oct 2019 06:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571233765; cv=none; d=google.com; s=arc-20160816; b=0qFmyhRDqjGa3iWMN5SiYhbOEVcOfvI+dKTuzJljq5d75/YngacOf7vgw0LftfQEQm 3wRFXpOHOq31HmpltlXpxOidpGMhIvhBNE14bOCon626WRWv/OVEpX2UE0Es3Y5xHxZd 3pjgnZlS+cdNElUctt3thbMkRCMu+pQ2geEdHLXkp0g6D9e6nt0LTsl/yAWwm8gWEB0K Nq8FkNzKIZ4B5u0t0CtsPIba+CvlSQPtW9ZiGQT6dXYkoBqyYCIfx548Wf/l5v+7IfB8 AJzJ7PM5378TXC9SU+Ht90u9vL/6vmEHYrcsOU2HQS8SdAF90fAehEAUCVfk587CDFGZ VHuQ== 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=brzEdAKa0x3IDElfYlRm18MxDjJ07nRc823SBrutUBQ=; b=OuLt16vtlvy8Q7Q6E6MhTMttzvHP/RPH9Jx+8rjGASB8hVkJ7WnSWZLCwA4i3r1It4 5J0akaG0Po7j8H0gIJiInIvX8oICHEgYHJmi+Wqs0QaFm6r+jn0zbVG3KEnVipgks25W sNnb5fzep2Mwx31R0Gwjmh/3jtDB07S3oYxxr7SzlBDumu5QYZOHQSyi73YbfQz+j1uL 4AzE0aOALP1qkidS2EIgiSTLDGRF5mGmbrC23K4wmTMCmUH7ScxkgNwcmkYKZ5SxZfro ViJ6U7eP92EjFr5c/K+qv0JaJYr7LlKyWiHgn3xZp1X3mw9DLMs5HA7onQNKqK1j5a/r r+qQ== 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 me23si15106729ejb.344.2019.10.16.06.49.01; Wed, 16 Oct 2019 06:49:25 -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 S2392071AbfJPJs4 (ORCPT + 99 others); Wed, 16 Oct 2019 05:48:56 -0400 Received: from mga05.intel.com ([192.55.52.43]:49636 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389173AbfJPJs4 (ORCPT ); Wed, 16 Oct 2019 05:48:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 02:48:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,303,1566889200"; d="scan'208";a="207858159" Received: from linux.intel.com ([10.54.29.200]) by orsmga002.jf.intel.com with ESMTP; 16 Oct 2019 02:48:54 -0700 Received: from [10.125.252.157] (abudanko-mobl.ccr.corp.intel.com [10.125.252.157]) by linux.intel.com (Postfix) with ESMTP id 133815803C5; Wed, 16 Oct 2019 02:48:51 -0700 (PDT) Subject: [PATCH v2 1/4] perf/core,x86: introduce sync_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: <5964c7e9-ab6f-c0d0-3dca-31196606e337@linux.intel.com> Organization: Intel Corp. Message-ID: <5b95f1f5-8706-448f-5a19-b6cd955aca14@linux.intel.com> Date: Wed, 16 Oct 2019 12:48:51 +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: <5964c7e9-ab6f-c0d0-3dca-31196606e337@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 sync_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 | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index ecacfbf4ebc1..a25e6d7eb87b 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::sync_task_ctx() usage + * for examples; + */ + void (*sync_task_ctx)(struct x86_perf_task_context *one, + struct x86_perf_task_context *another); + /* * AMD bits */ diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 61448c19a132..60bf17af69f0 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -409,6 +409,13 @@ 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 (*sync_task_ctx) (void *one, void *another); /* * Set up pmu-private data structures for an AUX area -- 2.20.1