Received: by 10.223.185.111 with SMTP id b44csp76230wrg; Fri, 9 Mar 2018 01:13:20 -0800 (PST) X-Google-Smtp-Source: AG47ELvtz4oMyN2bwyKIF0a+gjJcmeHCA3MSa6fDxCiL87R7f4ZJGv//zbIvD2kh8qY908UtzhQb X-Received: by 2002:a17:902:b704:: with SMTP id d4-v6mr27536434pls.406.1520586800534; Fri, 09 Mar 2018 01:13:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520586800; cv=none; d=google.com; s=arc-20160816; b=kkfqmAtfpZxyZjQn93X5BnwhABCrEIUlJHyY1RNHffoATILmd7COG6bWxj6UZv5BkX M+NRvdVaB1Xe1o8WBnhAlSiqKlIEdV4zocSfnGvVtaEpa+7pQJGvC/qtFw3vc1disfP1 QAPA/i0p43gNK3SvSVblN4+t47SWZqmOJJJU9U6sjYktxiUdjPtGZMXtVNvAiI63NeFM lin8YOw97uCEIG8mAZCIeRkQmJesIz9pnVtl5hXmuE8G1h6pymcFV0HqTG+mEnTYPeyY TLne1kRqfq2yBII1wUG06X3a++soJsOHwBwFGFj1053KaIDQcOFLFUr2mffWzHEk6W/u 1TNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=6t58M+h9XNCin136YcX+awCEyYqS+NbCFyaRiERRWx8=; b=QlfrNAKmWxBQXVGjXgGpo+Vat82BsnsDGT/eLJB7oaFXSt79+JxDkVmtML97J2TwTB 3OYCch0PArWsPh7gs8hUmT1jh6QRY10wFsVQREms9qHM3WAFXkE73PDAzluiTr2RRk2G A4KYn7VFRqvezmjWGhZaA7t9FWzjOBPTO/BxQCjGVD7tnN8ByzGq5tRoXL5taxO/aoQ9 s7IN2DYOAEjpH/Yc7Gg0z4draYDAQV1B6ShP2GZD20z1y0GhVEZsX/Iv4MiFw4BToXry Z0MpEid096ZKJ2zXdeDyN8MhQE98KIwwvv7ywzbgrwtPUM3ucBOs/if9dKb723nH1mSV vP/g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si533273pll.681.2018.03.09.01.13.05; Fri, 09 Mar 2018 01:13:20 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751729AbeCIJLH (ORCPT + 99 others); Fri, 9 Mar 2018 04:11:07 -0500 Received: from terminus.zytor.com ([198.137.202.136]:51379 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbeCIJLE (ORCPT ); Fri, 9 Mar 2018 04:11:04 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w2999gBh031881; Fri, 9 Mar 2018 01:09:42 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w2999f8U031878; Fri, 9 Mar 2018 01:09:41 -0800 Date: Fri, 9 Mar 2018 01:09:41 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Kan Liang Message-ID: Cc: mingo@kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de, jolsa@redhat.com, kan.liang@linux.intel.com, linux-kernel@vger.kernel.org, vincent.weaver@maine.edu, hpa@zytor.com, alexander.shishkin@linux.intel.com, eranian@google.com, acme@redhat.com, peterz@infradead.org Reply-To: kan.liang@linux.intel.com, jolsa@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, torvalds@linux-foundation.org, alexander.shishkin@linux.intel.com, peterz@infradead.org, acme@redhat.com, eranian@google.com, hpa@zytor.com, vincent.weaver@maine.edu In-Reply-To: <1518474035-21006-4-git-send-email-kan.liang@linux.intel.com> References: <1518474035-21006-4-git-send-email-kan.liang@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/x86/intel/ds: Introduce ->read() function for auto-reload events and flush the PEBS buffer there Git-Commit-ID: 5bee2cc69d986e20808c93c46f7b6aef51edd827 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 5bee2cc69d986e20808c93c46f7b6aef51edd827 Gitweb: https://git.kernel.org/tip/5bee2cc69d986e20808c93c46f7b6aef51edd827 Author: Kan Liang AuthorDate: Mon, 12 Feb 2018 14:20:33 -0800 Committer: Ingo Molnar CommitDate: Fri, 9 Mar 2018 08:22:21 +0100 perf/x86/intel/ds: Introduce ->read() function for auto-reload events and flush the PEBS buffer there There is no way to get exact auto-reload times and values which are needed for event updates unless we flush the PEBS buffer. Introduce intel_pmu_auto_reload_read() to drain the PEBS buffer for auto reload event. To prevent races with the hardware, we can only call drain_pebs() when the PMU is disabled. Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: acme@kernel.org Link: http://lkml.kernel.org/r/1518474035-21006-4-git-send-email-kan.liang@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/events/intel/ds.c | 9 +++++++++ arch/x86/events/perf_event.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index f39a4df3a7bd..73844025adaf 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1306,6 +1306,15 @@ get_next_pebs_record_by_bit(void *base, void *top, int bit) return NULL; } +void intel_pmu_auto_reload_read(struct perf_event *event) +{ + WARN_ON(!(event->hw.flags & PERF_X86_EVENT_AUTO_RELOAD)); + + perf_pmu_disable(event->pmu); + intel_pmu_drain_pebs_buffer(); + perf_pmu_enable(event->pmu); +} + /* * Special variant of intel_pmu_save_and_restart() for auto-reload. */ diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index d445f0026989..91643472f385 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -924,6 +924,8 @@ void intel_pmu_pebs_disable_all(void); void intel_pmu_pebs_sched_task(struct perf_event_context *ctx, bool sched_in); +void intel_pmu_auto_reload_read(struct perf_event *event); + void intel_ds_init(void); void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in);