Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527975pxf; Mon, 15 Mar 2021 11:33:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI9zpFnVaZJBggQWp+qEpZNTZrKuXTVtEadyl00hl5FaQV7EMX3VBIyYMLYLCuUqJlczJE X-Received: by 2002:a17:906:948d:: with SMTP id t13mr24407370ejx.402.1615833201996; Mon, 15 Mar 2021 11:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833201; cv=none; d=google.com; s=arc-20160816; b=zMWgLc5Ty7MK4EZG4+bFolsJcrUZm/l3fHwBeI/RfjiyZHJmLJn7UKmHZSZWapon1k Y0X0LYzjuMHhuocbQBnRZZ1SZwqTCyPv8UAWWibLW2OPjxLaA9WRhia9IjeD/z4hBrcx Bv1M0p1ilNsxUNbzWY4nYazM0CrXxhRCtCj2GrhLY/MTTdSw/zu6Q5GN2e2OTJf+lGi7 myTCHUfWPHqMaO7Vl9NW/K/m74RxINFr6O6m9apyIfp9NM0tuQPKEgbOmJAmBm3njuD/ 8Jfv3DC+axlnYgmbNQWmjtQbKd9Ka65NcRn+hrNt6Yh2pAh2/z9I+e6fdOFVmrF+guAb 0o0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Icw9bd98IUSPJFh4jC1MWGY7tjlLWAs0oct69VouPF4=; b=nQpmrXqDVSIm6yCMmbPFNXuZ6uCq0Zbf39bCFLozkeHLk8lXCK50v5vUIlf21RXvtO 1H/F8L+Nrgu5Vs0Z5dqziCn3Q6caug/sBa/EpTQX4d0H2L8miWvehBVhVOHPtLYrvteo 2Fwn0aaZr/kj3jVaKUzK7fSWzlKvycmS/KK0T3g7Ozq3J5qO/P7EgnnzI9kNEFmzi6gW 0KJhZMmZ66qX/mWgwfFI/wi8/VUyDX52WK7HJr99Gys4OrDvJ9JelEmdwkjzF89BVa9w 7vI1wuqQOsV2Pfrk/McG3eLp49aL6J7osDzquoIAgZnfpEBke8jIadz9c32WULwDuasW pGDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J8n+XMDM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si11887635edx.470.2021.03.15.11.32.59; Mon, 15 Mar 2021 11:33:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J8n+XMDM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238478AbhCOOoQ (ORCPT + 99 others); Mon, 15 Mar 2021 10:44:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:50480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234518AbhCOODt (ORCPT ); Mon, 15 Mar 2021 10:03:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5710364EFE; Mon, 15 Mar 2021 14:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817028; bh=Tb7EzyvXMTHPSn2g/ehgOzm2842FZaoNE6EZOmT0yx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J8n+XMDMP+gjICr5aOZYhI9veD07nuLTJ/10jywF2vNt3GZ4/S8A+gMNHQcwx3HVw f5/TkKPs397sPRbEnoRZo3e+F5ytU+qJ+5Nrlm9y3RfKuPAwboAWdhaKTZB7osmPlj ISLtmJvt3SfZS3Ts2APzODnNKyg9fqlq1gwKzZRU= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kan Liang , "Peter Zijlstra (Intel)" , Ingo Molnar , Sasha Levin Subject: [PATCH 5.10 254/290] perf/x86/intel: Set PERF_ATTACH_SCHED_CB for large PEBS and LBR Date: Mon, 15 Mar 2021 14:55:47 +0100 Message-Id: <20210315135550.600253881@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Kan Liang [ Upstream commit afbef30149587ad46f4780b1e0cc5e219745ce90 ] To supply a PID/TID for large PEBS, it requires flushing the PEBS buffer in a context switch. For normal LBRs, a context switch can flip the address space and LBR entries are not tagged with an identifier, we need to wipe the LBR, even for per-cpu events. For LBR callstack, save/restore the stack is required during a context switch. Set PERF_ATTACH_SCHED_CB for the event with large PEBS & LBR. Fixes: 9c964efa4330 ("perf/x86/intel: Drain the PEBS buffer during context switches") Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lkml.kernel.org/r/20201130193842.10569-2-kan.liang@linux.intel.com Signed-off-by: Sasha Levin --- arch/x86/events/intel/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index aaa7bffdb20f..4b05c876f9f6 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3565,8 +3565,10 @@ static int intel_pmu_hw_config(struct perf_event *event) if (!(event->attr.freq || (event->attr.wakeup_events && !event->attr.watermark))) { event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD; if (!(event->attr.sample_type & - ~intel_pmu_large_pebs_flags(event))) + ~intel_pmu_large_pebs_flags(event))) { event->hw.flags |= PERF_X86_EVENT_LARGE_PEBS; + event->attach_state |= PERF_ATTACH_SCHED_CB; + } } if (x86_pmu.pebs_aliases) x86_pmu.pebs_aliases(event); @@ -3579,6 +3581,7 @@ static int intel_pmu_hw_config(struct perf_event *event) ret = intel_pmu_setup_lbr_filter(event); if (ret) return ret; + event->attach_state |= PERF_ATTACH_SCHED_CB; /* * BTS is set up earlier in this path, so don't account twice -- 2.30.1