Received: by 10.213.65.68 with SMTP id h4csp3229283imn; Tue, 3 Apr 2018 00:49:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ng7senN1liFCbU7qWqI5cPY8iFVcr22gkYdKJNkHpf4UiFk95PYLT7ggnM8ea/B4Sz9c3 X-Received: by 10.99.124.16 with SMTP id x16mr4247330pgc.201.1522741746509; Tue, 03 Apr 2018 00:49:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522741746; cv=none; d=google.com; s=arc-20160816; b=p0PNjNtGBELG81HKMeLbKhmqZ47XzKj4b4JfwLM+qTM22F7wYmkkJQB/n9xH3qaCBT jhCMB0otfSdUK/V4DXJXJ641eLntvAvkFVVKHmEGji/WUPDQjgMR+HJrc7OfyoMuNHcV QtKaIL+RjRGg8Ofu9xrkWMU2eLmeTP+0xhYlD4YSQo/mGHxoSkPXa58t/H+VK9nQGo/j QiLKPwf0tpgkau5oemQJ9ATbrBaQ87WoJNehPhOo6tjkpTqAx7yG5WZB5ebdsOOSnkMb 6xD6dFf+3t82k1FRBsIKE6+iGIwn8sNuzAtinzCjpjuGZjyi3LzNg2OLufljMidncSlM 4pGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=VzQtuVD7r1ayW5HKXa1ZoAYqaDxf4qIX9eAt2sbvh3s=; b=CxRyXwRjN9IqKlFeYovSj+HZ4he693TOlbGftNjyYqrSbvwbvQMmO/rgSCzbDCojEp okjrppLqdvKFEusdkMQFoDvLtw0rOtlmLa6oXyb0nIraIxb1SUyBuAS+3odJIBHYvjlo mx7AazxWsj0uVCjXiAxuG2tB4eCaRs8GXx95YnXe+o9DfPywt6pyrpyykrOS21dZx0dk 0AkGWFUGZAsOubF8Rs56xEl2BuRrov/OZyVipZv/HEsuyEI/SkM3KscymKB++c4hwb8O q/mou5o7Dpwr5Zhg/HFImDN8OK5IHNDDpOZvI1gLDBN/dDupkV+JBqiFZQxCOA5YQIm8 r9ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Mg8r1Xnn; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az2-v6si2170985plb.263.2018.04.03.00.48.51; Tue, 03 Apr 2018 00:49:06 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=Mg8r1Xnn; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754825AbeDCHrm (ORCPT + 99 others); Tue, 3 Apr 2018 03:47:42 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43202 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753267AbeDCHrk (ORCPT ); Tue, 3 Apr 2018 03:47:40 -0400 Received: by mail-pl0-f66.google.com with SMTP id c21-v6so4144800plz.10 for ; Tue, 03 Apr 2018 00:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VzQtuVD7r1ayW5HKXa1ZoAYqaDxf4qIX9eAt2sbvh3s=; b=Mg8r1XnnAOwxwuMawgJGKKW9zYCdCPUrIop1QNweIxWf69VZQHnrN7pvU2azWLL1VT uP49Cb3Jyy+0sk7NzjKauAWj1t39cWbVjmnrkqC2A52wEx1FxWQs3DM0eWhIiUViZqE5 F7pJ0I9rAszmz1RdAPSJ0bqAJ8VMcNvXTJQWWAasFqg42QQUUflv/DfnJHfmIug3yB5D c1E2qLPoTYvf4tMh/1jyIDCs0dv0xoBrpZearrkb6449zOAm+72AOAPx5KphoKzmpuSS TWgYeIlEEomwqDxlsJDy3k/EMA91IdZQQXXTosyFwmiDD5nCeULJHSFJcwmmulZ101ah etyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VzQtuVD7r1ayW5HKXa1ZoAYqaDxf4qIX9eAt2sbvh3s=; b=Upnfv/r+MAY6/AstEhln58JY3g5rFumhhYLqgs+jNrR2TjR8ePR/5kZYxSUinHytOc T9uqM1B2XUPoJLO9lmXqaNWZvI6wh6ffVAk0VYFZPznLyNITNIjdKj8Ac8DxNcKX+7tZ Ki9H5c1d4/cU/1lY2Tqiawlt5Wl93szBh0mOvS8/xY9GVhafVASX7jC3p5Y3MNxr28U+ soTSzWNFCoCZGQkCYRsZkK6abw6G+L80F00JsZ4/tNuhQ/kOGGanVw48tUJWYYL9It8i xU6iOuynx9+Bn/jCft7x/g4T8oJyS7EYzP4qV5F8KdqqKerc37WV63x3ggezVGGd0LLJ a2yQ== X-Gm-Message-State: AElRT7G/I/UU9v4Qv0KsRuhFuH9oLC78IktEFikJMmZYSDzKS0BTo1CS q+hrfZ9EEgd0095DH00XGz8b8MJHZZE= X-Received: by 10.99.109.139 with SMTP id i133mr8061093pgc.194.1522741659907; Tue, 03 Apr 2018 00:47:39 -0700 (PDT) Received: from localhost (c-67-169-55-77.hsd1.ca.comcast.net. [67.169.55.77]) by smtp.gmail.com with ESMTPSA id y191sm4624767pgd.63.2018.04.03.00.47.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Apr 2018 00:47:39 -0700 (PDT) From: Stephane Eranian To: linux-kernel@vger.kernel.org Cc: acme@redhat.com, peterz@infradead.org, mingo@elte.hu, ak@linux.intel.com, kan.liang@intel.com, jolsa@redhat.com Subject: [PATCH] perf/x86/intel: move regs->flags EXACT bit init Date: Tue, 3 Apr 2018 00:47:29 -0700 Message-Id: <1522741649-13904-1-git-send-email-eranian@google.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Patch also clarifies comment for intel_pmu_pebs_fixup_ip(). Signed-off-by: Stephane Eranian --- arch/x86/events/intel/ds.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index da6780122786..41b44a4fff51 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 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,15 +1235,19 @@ 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 have the eventing IP, so use it */ 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: */ + /* + * ... and try to fix it up using the LBR entries + * if successful, regs->ip modified and regs patch + * via set_linear_ip() + */ if (intel_pmu_pebs_fixup_ip(regs)) regs->flags |= PERF_EFLAGS_EXACT; } -- 2.7.4