Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5196094ybg; Mon, 21 Oct 2019 23:00:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgR5L9E1Eg5IdU858Uf3YTAynZqNWDGB6n+LBuEFbAp58KyFaEROw7b5b7BBDkMynUIe0+ X-Received: by 2002:a50:ed01:: with SMTP id j1mr29282850eds.111.1571724020223; Mon, 21 Oct 2019 23:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571724020; cv=none; d=google.com; s=arc-20160816; b=ZV9w/Pk9Rd+W5x9fdthTx7DIRLgAh+IGpu6ugdlxJ6YmfiDm+bINYmUkXwb84Fsi0r 0UfEeP5lGSjcORGED4JWLIHHFcgRaOdQ4H3laxliBLy14PKub+EgKcglD1g9XZfyJ1y4 PnYZfCi/fBhacRfgw9I+iRkAB+gCSLqHrKcPHOb6+gldlegngQ3HUPO9czQNdqW/6JrJ /hQixU19+h1ZKOYwWRJcPkTmt9CDmaZ2do7fTQjO0d6jlMAZRId22Qb5y5pmX2W+qiqh fcvwAXPtFV/cYOFDDRyuOY+d0uJqH+y+Ivkd5gyAzu0hFTzvI9OZum++9OYpz8jLCVvJ e0/g== 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=uo/Twk6m89T3KXbsLlPqZuUURINwY1NMmFdH6ZsHv1A=; b=lEw4BXUFzOSFI8bLNw8a9o1p8oP5A1j/8Sc8wfjOs4YBzzbj+Zv0QqWRU2Stqt8Fl9 4NJUeLG4ElOy3D6NWr6R1SgH9zczn3pSu7F8uD4Fw/MGm9//EDf8D9f7ETHIoSys/24f ynvyNGBU819A4MiUo5cVhReVtJHB5HvwpGz1oh0PcJl7qyRFDPA5DixJqtR2f0+QpN53 6q+RkSolqjx4enlhdHrWX7M9Vbu23Qwcj7z/9tIGekJ9PHN/bT1xbfOZ3GDfU6GxNqlZ Qh9knVV1V0hVlKXJDzF3FHysxOkxrZkKVkdu8rezE9hiXA4ng27gMEarM2pXyIJUwzx1 o4mQ== 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 o8si7282011edi.34.2019.10.21.22.59.57; Mon, 21 Oct 2019 23:00:20 -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 S2387821AbfJVF6p (ORCPT + 99 others); Tue, 22 Oct 2019 01:58:45 -0400 Received: from mga17.intel.com ([192.55.52.151]:54848 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387640AbfJVF6p (ORCPT ); Tue, 22 Oct 2019 01:58:45 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Oct 2019 22:58:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,326,1566889200"; d="scan'208";a="227579918" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP; 21 Oct 2019 22:58:43 -0700 Received: from [10.249.230.171] (abudanko-mobl.ccr.corp.intel.com [10.249.230.171]) by linux.intel.com (Postfix) with ESMTP id 2837E580499; Mon, 21 Oct 2019 22:58:40 -0700 (PDT) Subject: [PATCH v4 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: Organization: Intel Corp. Message-ID: <2c7c4e50-e857-13b3-7036-5d8f76179469@linux.intel.com> Date: Tue, 22 Oct 2019 08:58:39 +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 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 --- Changes in v4: - marked sync_task_ctx() as the optional in code comments; - renamed params of sync_task_ctx() to prev and next; --- 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..be78f2765f74 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 *prev, + struct x86_perf_task_context *next); + /* * AMD bits */ diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 587ae4d002f5..4b96b4a5ac03 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -410,6 +410,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 *prev, void *next); /* optional */ /* * Set up pmu-private data structures for an AUX area -- 2.20.1