Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1724732ybg; Sat, 19 Oct 2019 01:08:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqywchKSocna1nU50OVXD8mT1+Vne/37nw4agfPsEGWc+DnoPmeYjO4SMdjT+cIAlCLkvnO/ X-Received: by 2002:a17:906:5907:: with SMTP id h7mr12332601ejq.328.1571472496586; Sat, 19 Oct 2019 01:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571472496; cv=none; d=google.com; s=arc-20160816; b=t/XRWCZR9QdNc9N850CIPnC6jYOfi2MpSpjHHU6KfOV5aZtXlVi5u4d6II4LIF8vXB pgHOiEZwOfJJ5Jr6XhivD9GSU8xjzffkmzCPFQp9HwiSZ8lrlYNryJCABgOkXNimz6JS YBUoR/XWrFUAWXBERZ5OvicIZIL5R8K/Ca1K8oBgll9u2gE6U076+8yy4xVTcLxmH2PR YXetJXcbIPICk/AxEqRlthvctIednkf4sv5A3N7xZnzdkCGLwhtGzsaHRVzhNlTldmQU ckR/3nLRvZMYMRxFtuXfjIg7APWjiwcCU8pGsh9Q1TqzP68SuBYtWdiecUB4MM6VkiHQ WFNA== 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=HJdpait8C8jG/kOm1v0/rtBc57aQWWouwy1uCCmLPHM3nF8YGLylOSgPdQ4dUvbFmP yMTLVcF9XiR1EGAvI1jM6/0fugl8UFsLSpNJ6n3Af1+GHnt7TaE8dDUjwYWPA3E60muH s3zldYvaMbZnT4rtbzIYHoqeKbmjvu4EaVfgYVFO9sCNMBheGx3KeP++3kvnEbRs+Jbi IC1IIVAhporCuFbFVJydGqDCNqNil5+HB/cMzbpb0tp2GU3trkG+CY1nK90MfH8rhCcp 3qZoNweYgQCnHGrLf7IlFrmD98DPZV/vwss6NQVsPhgCUkjyKdlJO7C8fe3liIRbjL29 00kQ== 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 w11si4826957eji.160.2019.10.19.01.07.53; Sat, 19 Oct 2019 01:08:16 -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 S2390655AbfJRJmv (ORCPT + 99 others); Fri, 18 Oct 2019 05:42:51 -0400 Received: from mga09.intel.com ([134.134.136.24]:31367 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388364AbfJRJmu (ORCPT ); Fri, 18 Oct 2019 05:42:50 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Oct 2019 02:42:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,311,1566889200"; d="scan'208";a="196161827" Received: from linux.intel.com ([10.54.29.200]) by fmsmga007.fm.intel.com with ESMTP; 18 Oct 2019 02:42:48 -0700 Received: from [10.125.252.194] (abudanko-mobl.ccr.corp.intel.com [10.125.252.194]) by linux.intel.com (Postfix) with ESMTP id 4660C5802F0; Fri, 18 Oct 2019 02:42:45 -0700 (PDT) Subject: [PATCH v3 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: <0b20a07f-d074-d3da-7551-c9a4a94fe8e3@linux.intel.com> Organization: Intel Corp. Message-ID: Date: Fri, 18 Oct 2019 12:42:44 +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: <0b20a07f-d074-d3da-7551-c9a4a94fe8e3@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