Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1638986imj; Thu, 14 Feb 2019 09:33:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IbBKGKgPyk4Kp6xgoL3whR27Zqv2FjSzPeGUTiuXiFvtgdSqBxhW1yHC/g8+8AEnYTlgOrl X-Received: by 2002:a62:b15:: with SMTP id t21mr5398454pfi.136.1550165591544; Thu, 14 Feb 2019 09:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550165591; cv=none; d=google.com; s=arc-20160816; b=Ihzx296sTkcJIzABfq7jVZOxYslDj2qb/ZNLkMGU2nrCYKO+dgojR9onyO8ASBpGue nIVioftWinzbBDZ/SF2nk5DdKc7il5VdrVWcxj8zhJPdHE0qYMfEPtgiOEjGf7TRQk9z cUY64e30PeXaI6cvdP86PO74xlvpi/wUr5j63UOkJZIdhmKkuXwdeatXYi3+k1bmBakS i883VsmfpmKQUgxXGiAmbkRc9pi7zz3D96HyaT/3zwLKPINwigtv4CYND9lAxhMKueHc ny4pMrKD2cVtxdA1jDwUaWj1vki8MhMf9XDDaZnuj+ZK5cE2yrb+f5Tp47+Sr21oSrGF jh7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=cXzSiMa7+uhotq0ypTIO/lbRTjTsBg9yyagbj6IZTXo=; b=py2PYbIMlpiM09cN22dY/VDUxmLrhAzQiIXtfThJiHTiKq8sCJ8knIegj3+4uTEmVA 5u6QNR61pZWaYDKOGAxUsCAsZQkwBNdYFPnyJ0By1/29O1dVZ30on3J9pZ9Wig5THyLs OUolRV+BHoUlMQFPfHSyrZ/gmtb+JouFSBwmMrAOjCP3pUlu6itXcIHj/fxhNtXQl6SO nQpRia65IewgdDEPCpqE3zt7BA4aj8zaR96tDsnPuKjKANIJe/Lpf/wqDjANw5YKror4 9EBvPW0s7MCkomdnAPcr2wu9SD4BgyUG/6nhXmFQKLaDnjXosusoSYBKhxB78Uu4z+11 8AmA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bh10si2865118plb.208.2019.02.14.09.32.55; Thu, 14 Feb 2019 09:33:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732619AbfBNJnl (ORCPT + 99 others); Thu, 14 Feb 2019 04:43:41 -0500 Received: from mga09.intel.com ([134.134.136.24]:32216 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436822AbfBNJnG (ORCPT ); Thu, 14 Feb 2019 04:43:06 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2019 01:43:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,368,1544515200"; d="scan'208";a="124411800" Received: from devel-ww.sh.intel.com ([10.239.48.128]) by fmsmga008.fm.intel.com with ESMTP; 14 Feb 2019 01:43:03 -0800 From: Wei Wang To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, ak@linux.intel.com, peterz@infradead.org Cc: kan.liang@intel.com, mingo@redhat.com, rkrcmar@redhat.com, like.xu@intel.com, wei.w.wang@intel.com, jannh@google.com, arei.gonglei@huawei.com, jmattson@google.com Subject: [PATCH v5 09/12] perf/x86: save/restore LBR_SELECT on vCPU switching Date: Thu, 14 Feb 2019 17:06:11 +0800 Message-Id: <1550135174-5423-10-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550135174-5423-1-git-send-email-wei.w.wang@intel.com> References: <1550135174-5423-1-git-send-email-wei.w.wang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The vCPU lbr event relies on the host to save/restore all the lbr related MSRs. So add the LBR_SELECT save/restore to the related functions for the vCPU case. Signed-off-by: Wei Wang Cc: Peter Zijlstra Cc: Andi Kleen --- arch/x86/events/intel/lbr.c | 7 +++++++ arch/x86/events/perf_event.h | 1 + 2 files changed, 8 insertions(+) diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index 7951b22..740c097 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c @@ -383,6 +383,9 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx) wrmsrl(x86_pmu.lbr_tos, tos); task_ctx->lbr_stack_state = LBR_NONE; + + if (cpuc->vcpu_lbr) + wrmsrl(MSR_LBR_SELECT, task_ctx->lbr_sel); } static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx) @@ -409,6 +412,10 @@ static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx) if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO) rdmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]); } + + if (cpuc->vcpu_lbr) + rdmsrl(MSR_LBR_SELECT, task_ctx->lbr_sel); + task_ctx->valid_lbrs = i; task_ctx->tos = tos; task_ctx->lbr_stack_state = LBR_VALID; diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index bbea559..ccd0215 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -653,6 +653,7 @@ struct x86_perf_task_context { u64 lbr_from[MAX_LBR_ENTRIES]; u64 lbr_to[MAX_LBR_ENTRIES]; u64 lbr_info[MAX_LBR_ENTRIES]; + u64 lbr_sel; int tos; int valid_lbrs; int lbr_callstack_users; -- 2.7.4