Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8127877imu; Tue, 4 Dec 2018 03:29:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/VXkQ6rArUbZwYdBHUfkpPi3MaQWbhcEi2KJQ1eVjO6UoXIA4pjUlSvFf46YU3g87P/LigC X-Received: by 2002:a63:101d:: with SMTP id f29mr16619516pgl.38.1543922975531; Tue, 04 Dec 2018 03:29:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543922975; cv=none; d=google.com; s=arc-20160816; b=UDnpiBA/KqPhdf+0+RLxUqqCu6pt2JHYZoqsdB68XG7SiXDsUYx1XHHWhPn8aihpQU fefzLQGBIxNBspOUy3JNZ0J1YIX/b5Ixm/c0t9SyMVFBO1VUYPO/bS290s0T+BAq+LXo dp67z/xlMp6ehFmVXchKDdLpeegq0cg+rWqsq6vSfkHPNIb6iDoEW+8tdx0zatIkh9rr NmUJTvfNT7zcHPVjUQOojs76DkIE6PbxiKIlPk2lJg/Yr0vxZqsG8jb4IST+fbuqClvt U661vzBR6lqcsnYb5vaI7GBRGY4UYam0D8NhdusgxJVgcJAY+ps9+wwTLGGECebMy7+E h5Yw== 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=8sdBtIZUQrXEiBRlgcDe6PK5rWR+HublTWSh/YR348g=; b=kk+dku1hVfnwELGB1hsx66Z2f86REfmEUpoUVh95s8QCMbU5p4TT7TanN76Gb+ltkE 2YISlaCmMtRjPoM03momEt8C3Ff8kbwU/pokqzezvjj4/gAkb2NfcqRoy8E687503hhV I+7Hsp9aqtuS1X+5aEc9G6wLH9tr6b7CvcaJf+uoPKSuviTK4DA9bALTFyvCoswEX1AT T6+FNfatGdqati8K61MKwmKceT3N9HMA9JnWb8oPtmCl6dVUymyYhkn5ogUqM0UPG4yv 9LGGVzUgykVCxmu7ba1LbKyf5Rswr97C5HuT9HYDC4UnlGAUDHXnAHqFNNpxZsRVe15r mO5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nxWuO2jl; 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 k20si17767107pfb.215.2018.12.04.03.29.20; Tue, 04 Dec 2018 03:29:35 -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=nxWuO2jl; 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 S1727087AbeLDL2p (ORCPT + 99 others); Tue, 4 Dec 2018 06:28:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:42970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726959AbeLDK6b (ORCPT ); Tue, 4 Dec 2018 05:58:31 -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 1F00D2146D; Tue, 4 Dec 2018 10:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921109; bh=skZPc2xcFMAES89gf9SqJUeVxgy9+hFjnJ+bUYwtpTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nxWuO2jlpw1Z9RwzBVvjfQw/07Q2lPEZAL4EfExS78ajBkwtM68uk8tqsuSUSgDMm n/GIbNp73mR472/4ZH02OFEDkA3h1O0Eafh1oHo/0FBxKz1MJoCVBvazfLfF7OBCbT vPbIJ027sdQEj5RSZRQGAYSs+yIPvHyAdMpZn76w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Zijlstra , Jiri Olsa , Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar Subject: [PATCH 4.19 085/139] perf/x86/intel: Move branch tracing setup to the Intel-specific source file Date: Tue, 4 Dec 2018 11:49:26 +0100 Message-Id: <20181204103653.776658177@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 ed6101bbf6266ee83e620b19faa7c6ad56bb41ab upstream. Moving branch tracing setup to Intel core object into separate intel_pmu_bts_config function, because it's Intel specific. Suggested-by: Peter Zijlstra 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: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Link: http://lkml.kernel.org/r/20181121101612.16272-1-jolsa@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/core.c | 20 -------------------- arch/x86/events/intel/core.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 21 deletions(-) --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -438,26 +438,6 @@ int x86_setup_perfctr(struct perf_event if (config == -1LL) return -EINVAL; - /* - * Branch tracing: - */ - if (attr->config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS && - !attr->freq && hwc->sample_period == 1) { - /* BTS is not supported by this architecture. */ - if (!x86_pmu.bts_active) - return -EOPNOTSUPP; - - /* BTS is currently only allowed for user-mode. */ - if (!attr->exclude_kernel) - return -EOPNOTSUPP; - - /* disallow bts if conflicting events are present */ - if (x86_add_exclusive(x86_lbr_exclusive_lbr)) - return -EBUSY; - - event->destroy = hw_perf_lbr_event_destroy; - } - hwc->config |= config; return 0; --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2986,6 +2986,41 @@ static unsigned long intel_pmu_large_peb return flags; } +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) { + /* BTS is not supported by this architecture. */ + if (!x86_pmu.bts_active) + return -EOPNOTSUPP; + + /* BTS is currently only allowed for user-mode. */ + if (!attr->exclude_kernel) + return -EOPNOTSUPP; + + /* disallow bts if conflicting events are present */ + if (x86_add_exclusive(x86_lbr_exclusive_lbr)) + return -EBUSY; + + event->destroy = hw_perf_lbr_event_destroy; + } + + return 0; +} + +static int core_pmu_hw_config(struct perf_event *event) +{ + int ret = x86_pmu_hw_config(event); + + if (ret) + return ret; + + return intel_pmu_bts_config(event); +} + static int intel_pmu_hw_config(struct perf_event *event) { int ret = x86_pmu_hw_config(event); @@ -2993,6 +3028,10 @@ static int intel_pmu_hw_config(struct pe if (ret) return ret; + ret = intel_pmu_bts_config(event); + if (ret) + return ret; + if (event->attr.precise_ip) { if (!event->attr.freq) { event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD; @@ -3478,7 +3517,7 @@ static __initconst const struct x86_pmu .enable_all = core_pmu_enable_all, .enable = core_pmu_enable_event, .disable = x86_pmu_disable_event, - .hw_config = x86_pmu_hw_config, + .hw_config = core_pmu_hw_config, .schedule_events = x86_schedule_events, .eventsel = MSR_ARCH_PERFMON_EVENTSEL0, .perfctr = MSR_ARCH_PERFMON_PERFCTR0,