Received: by 10.223.176.5 with SMTP id f5csp3085488wra; Mon, 29 Jan 2018 08:32:58 -0800 (PST) X-Google-Smtp-Source: AH8x226rOtULJV0MJgKJng53ZPY+ZEHdoa+7MI9sZPl+/QLck8N9ZFhPOHFksQ/nJRSm3zs0afzt X-Received: by 10.99.127.24 with SMTP id a24mr21712023pgd.225.1517243578707; Mon, 29 Jan 2018 08:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517243578; cv=none; d=google.com; s=arc-20160816; b=IR2HcAYgTgFMrOjB04a/86tXfMvzENgIYhCUP4o6LtUZ4D51+Aq0iSGzWExQC1UOr6 BlURcwIc5ItDq9zzyM0PE4RP+lfOvvZ6ha032NOtA+ZErff/SnL0KPrxMA5y5f2fJ9WH rsUZb/Mtm9ezeq33fOBfFUWVJbdVNgLGp+SembycUeoQINP6iKjClemdJAVLG+QRSrHr 9ZiAQOCNxXiLJfyfpci0V2tptYK+I7jpCKmMCBEG/+HocvoC9c4Kx/bPvpivYI/h1lLf KQBfpHPrYBaKG61Kvgy6xLFD0yTQOUGCjfLo/M/n3BE/zCdmBt0ScwhkuqhPXx6sBbZR XRjw== 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=dftUjdwm5jSu6q4e9yQECaR/xOvMD2XHV1wGcQVRHZ8=; b=nq08PZJRMh+cod64VPmd8uSh+4FXEtgYhytKJFQu9lNSAZQxYQRxsBNldHG/JSIxqV sPHbG0sWxzY//fJ0k6ee9l+RB4xnmQhbiO/art9kbQ08sptOLOBgV/oOXBpASzU/zoD9 /97OQXjgfBTLHL99N4++PwwydJmhjbeJ7iYIQem2zZYyPXMHt6lMYBs0vtET2CuVEeaE 2m2fGFXaHlxWyvffsQPiWW6VAk4Xx6A0vV3em4uOg2UiRuavakvGGxGIWxC+lMmqSesp FjXm5jS9R8IxhMleRSVli9IaWm3TMI/hAqRQ2r9ePTzEAWus72oQcK0+WUwzjBsYS13/ J22Q== 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 u6-v6si1432475pld.31.2018.01.29.08.32.44; Mon, 29 Jan 2018 08:32:58 -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 S1751668AbeA2Qb4 (ORCPT + 99 others); Mon, 29 Jan 2018 11:31:56 -0500 Received: from mga09.intel.com ([134.134.136.24]:11475 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751264AbeA2Qak (ORCPT ); Mon, 29 Jan 2018 11:30:40 -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 orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2018 08:30:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,431,1511856000"; d="scan'208";a="25629348" Received: from otc-lr-04.jf.intel.com ([10.54.39.128]) by fmsmga004.fm.intel.com with ESMTP; 29 Jan 2018 08:30:39 -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 V3 3/5] perf/x86/intel/ds: introduce read function for large pebs Date: Mon, 29 Jan 2018 08:29:31 -0800 Message-Id: <1517243373-355481-4-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517243373-355481-1-git-send-email-kan.liang@linux.intel.com> References: <1517243373-355481-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 When the PEBS interrupt threshold is larger than one, 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_large_pebs_read() to drain the PEBS buffer in event read when large PEBS is enabled. To prevent the race, the drain_pebs() only be called when the PMU is disabled. Unconditionally call x86_perf_event_update() for large pebs. - It is easily to call pmu::read() twice in a short period. There could be no samples in the PEBS buffer. x86_perf_event_update() is needed to update the count. - There is no harmful to call x86_perf_event_update() for other cases. - It's safe. Don't need to worry about the auto-reload. Because the PMU is disabled. Signed-off-by: Kan Liang --- arch/x86/events/intel/ds.c | 16 ++++++++++++++++ arch/x86/events/perf_event.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 6533426..1c11fa2 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1303,6 +1303,22 @@ get_next_pebs_record_by_bit(void *base, void *top, int bit) return NULL; } +int intel_pmu_large_pebs_read(struct perf_event *event) +{ + struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); + + /* Check if the event has large pebs */ + if (!pebs_needs_sched_cb(cpuc)) + return 0; + + perf_pmu_disable(event->pmu); + intel_pmu_drain_pebs_buffer(); + x86_perf_event_update(event); + perf_pmu_enable(event->pmu); + + return 1; +} + /* * Specific intel_pmu_save_and_restart() for auto-reload. * It only be called from drain_pebs(). diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index 805400b..7d3cd32 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); +int intel_pmu_large_pebs_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