Received: by 10.213.65.68 with SMTP id h4csp1707828imn; Thu, 5 Apr 2018 02:19:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx48PoZWxbd/IeFhEOfclHgbgqmnHKCsKGI4JZGd2rV54HVtNVKBVOyA/ACr02NpYxvN7Tb73 X-Received: by 2002:a17:902:22a:: with SMTP id 39-v6mr22370799plc.128.1522919997520; Thu, 05 Apr 2018 02:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522919997; cv=none; d=google.com; s=arc-20160816; b=raobo/n5gOptxIAfFiP7G0XdIl3cENOu4JdVpEJkwXdqKL1wNIbVfAGS3+yfDz5qk3 chCLbEsS9YR5HbRaP3T6dcVZZfcqcsH0f0pgLTCQOOcdiHdw1IvVAk+1FnexDkTWAROx L6XsFCgkrMronPoAWjwgsCUbuFKNJqfOUFWHNR1N0kW2oS2coziVju75hReBI6aO1brz pah1ry6PYrxTb2UbApy8q3drr5K1utz4pEShvFw2Pzmwz5jxG8RCLxwjoE2pnzIvlO4G 2c7aLScRINGfBFlVrOVsq4IcP6wqqxs7zGpyBAL2lcjmummWVQjg66cwlOfqa1/NG2v8 bfEg== 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=G7Q331l7VbQB/Dm149fdcCpG0b6hE1yEyOihsPpPX1s=; b=lUiyYxZjTGVDauE+ZqcT/w9Klovj/NWpWdXnRLp5zeSyWjt2ZjAzgJ9P7fPdpOCOGF lbccQYjAB4zRmhhd4ClkkZhTnGSqTDIH+qJzci+KBe6tXaRLJR4yYeFA742e4jRAQx+e 6i4lX2Xd72ZIkU7CzSTiUVwGzEkn+s6UR77ccByKZepN+Y5w4EPrsLgf0fQKkHQyTCg2 urfMwV9AJKi/zDpEuy/EpGzkiuA7kybVE2DzELvZSKH+rpKXOHj0Ka7pIwq/jPmq0NoE EiSq9HubB/Ae64B1rZjCUcgJmd6uf+bOwQmdkz8F9uakBJ5/1sPIaWyD9rzfe79JKUjP 9xCA== 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 t18si5761184pfj.217.2018.04.05.02.19.43; Thu, 05 Apr 2018 02:19:57 -0700 (PDT) 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 S1751906AbeDEJS1 (ORCPT + 99 others); Thu, 5 Apr 2018 05:18:27 -0400 Received: from terminus.zytor.com ([198.137.202.136]:53659 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751414AbeDEJSZ (ORCPT ); Thu, 5 Apr 2018 05:18:25 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w359I0qa117959; Thu, 5 Apr 2018 02:18:00 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w359I0OY117956; Thu, 5 Apr 2018 02:18:00 -0700 Date: Thu, 5 Apr 2018 02:18:00 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Stephane Eranian Message-ID: Cc: linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, tglx@linutronix.de, vincent.weaver@maine.edu, namhyung@kernel.org, mingo@kernel.org, acme@redhat.com, peterz@infradead.org, hpa@zytor.com, torvalds@linux-foundation.org, eranian@google.com, jolsa@redhat.com Reply-To: torvalds@linux-foundation.org, hpa@zytor.com, peterz@infradead.org, jolsa@redhat.com, eranian@google.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, acme@redhat.com, mingo@kernel.org, namhyung@kernel.org, vincent.weaver@maine.edu, tglx@linutronix.de In-Reply-To: <1522909791-32498-1-git-send-email-eranian@google.com> References: <1522909791-32498-1-git-send-email-eranian@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/x86/intel: Move regs->flags EXACT bit init Git-Commit-ID: d1e7e602cd64cf61f87dbf30df07c24df9eb1d99 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: d1e7e602cd64cf61f87dbf30df07c24df9eb1d99 Gitweb: https://git.kernel.org/tip/d1e7e602cd64cf61f87dbf30df07c24df9eb1d99 Author: Stephane Eranian AuthorDate: Wed, 4 Apr 2018 23:29:51 -0700 Committer: Ingo Molnar CommitDate: Thu, 5 Apr 2018 09:28:40 +0200 perf/x86/intel: Move regs->flags EXACT bit init This patch removes a redundant store on regs->flags introduced by commit: 71eb9ee9596d ("perf/x86/intel: Fix linear IP of PEBS real_ip on Haswell and later CPUs") We were clearing the PERF_EFLAGS_EXACT but it was overwritten by regs->flags = pebs->flags later on. The PERF_EFLAGS_EXACT is a software flag using bit 3 of regs->flags. X86 marks this bit as Reserved. To make sure this bit is zero before we do any IP processing, we clear it explicitly. Patch also removes the following assignment: regs->flags = pebs->flags | (regs->flags & PERF_EFLAGS_VM); Because there is no regs->flags to preserve anymore because set_linear_ip() is not called until later. Signed-off-by: Stephane Eranian Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Vince Weaver Cc: kan.liang@intel.com Link: http://lkml.kernel.org/r/1522909791-32498-1-git-send-email-eranian@google.com [ Improve capitalization, punctuation and clarity of comments. ] Signed-off-by: Ingo Molnar --- arch/x86/events/intel/ds.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index da6780122786..8a10a045b57b 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1153,7 +1153,6 @@ static void setup_pebs_sample_data(struct perf_event *event, if (pebs == NULL) return; - regs->flags &= ~PERF_EFLAGS_EXACT; sample_type = event->attr.sample_type; dsrc = sample_type & PERF_SAMPLE_DATA_SRC; @@ -1197,7 +1196,13 @@ static void setup_pebs_sample_data(struct perf_event *event, * and PMI. */ *regs = *iregs; - regs->flags = pebs->flags; + + /* + * Initialize regs_>flags from PEBS, + * Clear exact bit (which uses x86 EFLAGS Reserved bit 3), + * i.e., do not rely on it being zero: + */ + regs->flags = pebs->flags & ~PERF_EFLAGS_EXACT; if (sample_type & PERF_SAMPLE_REGS_INTR) { regs->ax = pebs->ax; @@ -1217,10 +1222,6 @@ static void setup_pebs_sample_data(struct perf_event *event, regs->sp = pebs->sp; } - /* - * Preserve PERF_EFLAGS_VM from set_linear_ip(). - */ - regs->flags = pebs->flags | (regs->flags & PERF_EFLAGS_VM); #ifndef CONFIG_X86_32 regs->r8 = pebs->r8; regs->r9 = pebs->r9; @@ -1234,20 +1235,33 @@ static void setup_pebs_sample_data(struct perf_event *event, } if (event->attr.precise_ip > 1) { - /* Haswell and later have the eventing IP, so use it: */ + /* + * Haswell and later processors have an 'eventing IP' + * (real IP) which fixes the off-by-1 skid in hardware. + * Use it when precise_ip >= 2 : + */ if (x86_pmu.intel_cap.pebs_format >= 2) { set_linear_ip(regs, pebs->real_ip); regs->flags |= PERF_EFLAGS_EXACT; } else { - /* Otherwise use PEBS off-by-1 IP: */ + /* Otherwise, use PEBS off-by-1 IP: */ set_linear_ip(regs, pebs->ip); - /* ... and try to fix it up using the LBR entries: */ + /* + * With precise_ip >= 2, try to fix up the off-by-1 IP + * using the LBR. If successful, the fixup function + * corrects regs->ip and calls set_linear_ip() on regs: + */ if (intel_pmu_pebs_fixup_ip(regs)) regs->flags |= PERF_EFLAGS_EXACT; } - } else + } else { + /* + * When precise_ip == 1, return the PEBS off-by-1 IP, + * no fixup attempted: + */ set_linear_ip(regs, pebs->ip); + } if ((sample_type & (PERF_SAMPLE_ADDR | PERF_SAMPLE_PHYS_ADDR)) &&