Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527929pxf; Mon, 15 Mar 2021 11:33:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzthLE2IKqY8vsaWbTEwhybMyR2Ugc+L6LeuCpEUWRj7nKEK02g0UgLQjBUjBoQZntt4br5 X-Received: by 2002:a17:906:aed6:: with SMTP id me22mr25428272ejb.146.1615833198308; Mon, 15 Mar 2021 11:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833198; cv=none; d=google.com; s=arc-20160816; b=yLR7P3oCRfsasjct4ImKDqvgaYJULT5JXgtD8cdeJS1/iYGZpG7qzEyvI1va/8iWnS iq94E89ZQckVujdTSLXPYu5AB2EgiWY5GvwJA2qOYzl1ynjX3VdtuIoWY3SZgcgf61Lv ZCcNUlL8k8DsgfTJBZK0nRF56+hGbzHv2pT/ao92H9bdrrqQGrJyWOr1Sr08TNacDQ9a rehiEF3tsBqdGP0Uvzhatg2VSe37s1LfbQ0aKC9qqfio83haQJftH5MDg1vGrZsqDJmJ V3nyHwIwLYT7u//ANxeNSQtcHwUeVJcXQ1Cq0cYDx2lQ0gBKXvXyPSMupiXEhAViFj3l BeRA== 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=5pnlRwCikaEzfC4RPmkgBclEAyVpxk09zqlAvj7juKU=; b=gzo2QGD7X8oZ87D0Cv7gzdi4ZXM3+OEqNjVAh9KLHeofxRK3v+fWAcvsEx+dOtS5s9 eSRPM8BTkMG/sp1WthLetJFA1s806vzb2BfATW+mXdSsHJFsQ8zPNGOVS94G93S73Mgx hoMhv0/Qm/6wx+NwU0Jo/JU3STjud8k6Y/nqQOKr+ASJ/X+aYTF2tsVRPPKBpOvBdTJC mJhPkQ95zWWYxFbK367R9ix/zBvebaW93SJApEgPZQbDKAX/28F7Y9E5cC1dCLcxH6AD 50C2q/qQB9VhORfBXpcOMSA0/nLPIgnSWoeIWYzBT9UJ5ZIfwxf4nhVNMtIeucU5T63U LWWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nmeiKSZh; 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 q11si11723003ejr.604.2021.03.15.11.32.56; Mon, 15 Mar 2021 11:33:18 -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=nmeiKSZh; 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 S238259AbhCOOny (ORCPT + 99 others); Mon, 15 Mar 2021 10:43:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:49996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231387AbhCOODg (ORCPT ); Mon, 15 Mar 2021 10:03:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E05B64F0D; Mon, 15 Mar 2021 14:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817016; bh=F2XfBiiVRJnCI5oXCFxS44h7hKUw94JQWOPU9mOA1Uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmeiKSZhOqQ7oIwkJpAIM2D0cWyjB8gtf6OOBPuSOzaylEHfislQYOTlfGV0YSSqA BQKweNLCh1p8sCYbl5w3oOitX1CY3E4oBbiVoxMcbGSl13LaGL8z2y4IFrTbg32bau 3wGYVdTu6aOljb3C+AR2uvYfbSTqaucqEK5aY7Oc= 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.11 261/306] perf/x86/intel: Set PERF_ATTACH_SCHED_CB for large PEBS and LBR Date: Mon, 15 Mar 2021 14:55:24 +0100 Message-Id: <20210315135516.468851372@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 4faaef3a8f6c..d3f5cf70c1a0 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3578,8 +3578,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); @@ -3592,6 +3594,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