Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8100560imu; Tue, 4 Dec 2018 03:01:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/WEiNswGPKGyXRg1y8q02wRTJTG2Z4gb6MPEXH+BaIshmQOYzLZIeXbapDXBhKUpx+4vILM X-Received: by 2002:a63:82c6:: with SMTP id w189mr15422543pgd.344.1543921297304; Tue, 04 Dec 2018 03:01:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921297; cv=none; d=google.com; s=arc-20160816; b=CUtsuYRqlzhwI6NDsyi2JsajcJR52u4nZJSJoeO6l8gqoje1PKkQsJzH+ZCTcgVxUC sAPyqyoOtjGeOUyuL6uFUe9+cLTAH7UOxkldrfT7wCoKQyeE88HFi/W96cBywr0Bafwi Bu2a+/B+U7bItHRHIKixO+ZxO8NZFP28cT/I80z9zytvyJYnYTRxDPxDhJddpbxwKxQG 96MEx7T8oO/ICTs088IcHYgG9A9McazOiy52MkkuIr0NdlXxmJEOKyzL3ojqKvPFoRrS aGG3uGqHHKYhZtM59e0FGYjblpB8M9++vdbp6DR20FwST5I0CNOBPuh9mI04iTP+vTqq 46xg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KP5qVOHUJseLEvlBzOgADZAb+oho/tKSEbQ/996CvxI=; b=JPYZbplcgf3OyYtmBYsE5t9zVE0nlg6i3fJdgF6skUtF0vZF8JS1OaUtNCWYO5NAqZ bhZd3qSDlvo6h76Hh6eU0XuS89Ys5Dh7/VB+19HvVFVJX3FC6j4yGPdOwc2Nz/E7YH8i wJxKlU+v91fDQ3J02CaHP3EjPW0ZW2ohtMDxL7r346B3lzJG6BL7cevjAWjTz8gmrmtM qQvUsq4jRrlk3mx90YbcSTIcB0krmlK+TCVemEPDUjIcrgpHf8rmPnh9Odtj7eMhfCEc zpv5m4hyML0EfOtZa/X2DMCADCoESUv/sTAA2YIVlxlFjyZnUj64Z0xR1Ei/OyBlml3h gM7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vGd1AWV0; 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 w10si13788854pgj.214.2018.12.04.03.01.21; Tue, 04 Dec 2018 03:01:37 -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; dkim=pass header.i=@kernel.org header.s=default header.b=vGd1AWV0; 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 S1726976AbeLDK6f (ORCPT + 99 others); Tue, 4 Dec 2018 05:58:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:43024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726972AbeLDK6c (ORCPT ); Tue, 4 Dec 2018 05:58:32 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8D262214D9; Tue, 4 Dec 2018 10:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921112; bh=Ll5cOk0Gj5ORkgcvi3Nx1o9tqJZe/Zfh7ge18pLOxc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vGd1AWV0k524lOk94w0xv+hOyAmQ1o33O0BeiaR9uG3xNAMbzRe4Bm+/FpdTGhbZG 0wEXDoAdGtqyIsniEwgn+E9if+mevowXGS/W/GryRpNORz8Y1cduhYOaVCGdaNTFNu m3p1k8RibwziSY/4MC+BSJjkM3qQrEH6LucNO4a4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Olsa , Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Peter Zijlstra , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar Subject: [PATCH 4.19 086/139] perf/x86/intel: Add generic branch tracing check to intel_pmu_has_bts() Date: Tue, 4 Dec 2018 11:49:27 +0100 Message-Id: <20181204103653.839947703@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiri Olsa commit 67266c1080ad56c31af72b9c18355fde8ccc124a upstream. Currently we check the branch tracing only by checking for the PERF_COUNT_HW_BRANCH_INSTRUCTIONS event of PERF_TYPE_HARDWARE type. But we can define the same event with the PERF_TYPE_RAW type. Changing the intel_pmu_has_bts() code to check on event's final hw config value, so both HW types are covered. Adding unlikely to intel_pmu_has_bts() condition calls, because it was used in the original code in intel_bts_constraints. Signed-off-by: Jiri Olsa Acked-by: Peter Zijlstra Cc: Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Link: http://lkml.kernel.org/r/20181121101612.16272-2-jolsa@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/intel/core.c | 17 +++-------------- arch/x86/events/perf_event.h | 13 +++++++++---- 2 files changed, 12 insertions(+), 18 deletions(-) --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2358,16 +2358,7 @@ done: static struct event_constraint * intel_bts_constraints(struct perf_event *event) { - struct hw_perf_event *hwc = &event->hw; - unsigned int hw_event, bts_event; - - if (event->attr.freq) - return NULL; - - hw_event = hwc->config & INTEL_ARCH_EVENT_MASK; - bts_event = x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS); - - if (unlikely(hw_event == bts_event && hwc->sample_period == 1)) + if (unlikely(intel_pmu_has_bts(event))) return &bts_constraint; return NULL; @@ -2989,10 +2980,8 @@ static unsigned long intel_pmu_large_peb static int intel_pmu_bts_config(struct perf_event *event) { struct perf_event_attr *attr = &event->attr; - struct hw_perf_event *hwc = &event->hw; - if (attr->config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS && - !attr->freq && hwc->sample_period == 1) { + if (unlikely(intel_pmu_has_bts(event))) { /* BTS is not supported by this architecture. */ if (!x86_pmu.bts_active) return -EOPNOTSUPP; @@ -3054,7 +3043,7 @@ static int intel_pmu_hw_config(struct pe /* * BTS is set up earlier in this path, so don't account twice */ - if (!intel_pmu_has_bts(event)) { + if (!unlikely(intel_pmu_has_bts(event))) { /* disallow lbr if conflicting events are present */ if (x86_add_exclusive(x86_lbr_exclusive_lbr)) return -EBUSY; --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -857,11 +857,16 @@ static inline int amd_pmu_init(void) static inline bool intel_pmu_has_bts(struct perf_event *event) { - if (event->attr.config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS && - !event->attr.freq && event->hw.sample_period == 1) - return true; + struct hw_perf_event *hwc = &event->hw; + unsigned int hw_event, bts_event; - return false; + if (event->attr.freq) + return false; + + hw_event = hwc->config & INTEL_ARCH_EVENT_MASK; + bts_event = x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS); + + return hw_event == bts_event && hwc->sample_period == 1; } int intel_pmu_save_and_restart(struct perf_event *event);