Received: by 10.223.185.116 with SMTP id b49csp2699290wrg; Mon, 12 Feb 2018 14:24:39 -0800 (PST) X-Google-Smtp-Source: AH8x227bQ+GvPVdn014VQX9eLS0GDH6jm7oRsAj6s8QExlew5/K9r5kvMcd4BuMV2WV1mWcxn20G X-Received: by 10.98.153.2 with SMTP id d2mr13178830pfe.44.1518474279706; Mon, 12 Feb 2018 14:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518474279; cv=none; d=google.com; s=arc-20160816; b=hEuroYhC8Po/d8yxbwpo/RAYXrnlE1TD4Bs8sIJbsy6cyIwVt7tL51Ve/8Lnm9Uga1 rB7OhVFBeyeJNas8Vxx9NkqOv+u17IwOXGITAwdlzO4TlpkBkYH3PBGm1+JwaO6qqez6 msiqEK0ALLy449e/7LjXMnyp1TUsDRspbeR1bJq4OPyTPn64GVStpUAQeSUnKIKyNNii lGCGtfoaEqjxHLHl5QgAGMRFYcB+fGmK6JEwcbwYDrAucS7HL8LX9QYpN0+2nQMxNrBu eRfePPkASevmTFUDVE/0YTmyyH++mbon6nohzuj0Z1uczEBESYA6Z1vCSY4DPzU+Bs1V pq8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=BrWMsPa+G9fX/Ejl60dMfKF8cThI5p1VwkIlEkM2w4k=; b=YV2/9e4jTI9kF3hKVgFVoqg6z+1hzPc+LBHVBK76BD6wDGIJu1kQYyBpd20agnDdq+ xVfhferb3cMIttMo5AcJeLdegr53HfXJu4W8JEZL5v7de5Xu630/oeK98Kz+LPSlx7AZ 5rriLzdzkEJ3BLUsRHtwIKQ3yYTzCrRCLSSSvXM8KekDEWU80x5Br8iZyQUo07N2wnDG oJ+mHXqwS5vBU2XO0qf1p1mXVBCA77m8t7s477rtjwfYPz3Do8Hvy5jvdI4x1beQPPh3 A3Oce6EkiDEO7DLLDqPAZz1WwEt3DcZ1W6jN+/s5cJEjw7ydMOxKxhZkbbdKvA8XR2LN bzgg== 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 f7si581843pfa.168.2018.02.12.14.24.25; Mon, 12 Feb 2018 14:24:39 -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 S932856AbeBLWWV (ORCPT + 99 others); Mon, 12 Feb 2018 17:22:21 -0500 Received: from mga07.intel.com ([134.134.136.100]:64302 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932730AbeBLWVv (ORCPT ); Mon, 12 Feb 2018 17:21:51 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2018 14:21:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,504,1511856000"; d="scan'208";a="29490600" Received: from otc-lr-04.jf.intel.com ([10.54.39.128]) by fmsmga004.fm.intel.com with ESMTP; 12 Feb 2018 14:21:49 -0800 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: acme@kernel.org, tglx@linutronix.de, jolsa@redhat.com, eranian@google.com, ak@linux.intel.com, Kan Liang Subject: [PATCH V4 3/5] perf/x86/intel/ds: Introduce read function for auto-reload event Date: Mon, 12 Feb 2018 14:20:33 -0800 Message-Id: <1518474035-21006-4-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518474035-21006-1-git-send-email-kan.liang@linux.intel.com> References: <1518474035-21006-1-git-send-email-kan.liang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang There is no way to get exact auto-reload times and value which needed for event update unless flush the PEBS buffer. Introduce intel_pmu_auto_reload_read() to drain the PEBS buffer for auto reload event. To prevent the race, the drain_pebs() only be called when the PMU is disabled. Signed-off-by: Kan Liang --- 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 f519ebc..406f3ba 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1303,6 +1303,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 805400b..f4720a9 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -923,6 +923,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); -- 2.7.4