Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp650553ybx; Wed, 30 Oct 2019 02:51:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwm3H2hr+3iTcu7FFc7LeofyevNDccEcknPxP9Vh+kU7EsHTB1tm8bNbOz/GtzmO7zUL+QK X-Received: by 2002:a50:eb81:: with SMTP id y1mr30878576edr.119.1572429108368; Wed, 30 Oct 2019 02:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572429108; cv=none; d=google.com; s=arc-20160816; b=Nh4I5YEjngJBHEOESsl6FncmJyzDDCn474XiDEAvK+u78QYKfZboiFnK9aLBli2NWU efEJ1AVqVefgWBIHRbaeT9TuKil9DsoFXFrGyvyVtzJzcByab8CTpiuHOoVGFrDCgQse dn4qmYpC+DGAGSMHJezf4Hknu08bAn0TIaaRMCDB6NuGa4eaEIhv4w4TJel02u7x0mx8 4U2VM+nRb7P5iFyMn0AuGv9tn/Qo3iv7RV0/upYxihLQz3IsC36jADnvasQDP5W5uEvK F0iLfueQqLYoysiz0EOsidTmnzHSLUNYjYr3mcl8yNj1Gmg+quF9whpNuMGPqKk4pKQi lPXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ezNM7rdzF5GJdI/K6pMEPr7zdlKZrHRBRwkru5SQrtE=; b=HYVD5NTFfaM9cyja1Ks68zwkfzTw0wwwE0Iaa8rvYJFjeCmhFdRFzLU2fpeSsCBLVp dm5N1v9U9i14XLPaXLxkj+BUVPXR0vf9wI/5etEbZbbJjCOhoi+SQ56Z1tviF7FCk+oQ qc9jH5OSvu3tCJ02eg6Kg/ZNcpmwITI+66w9RdOzrj9oS8iCpTBl6H5I0Z9g5kawb6H2 ZZWO25wVgXuu+JGHhjwcY5jx/I+KFeFDgHFgxjo1RjGLRrpcC23lH744Sev+GNL+bN1e hP3KZUoaAG/gph/ZpKFC5v/dUI0E+JJQNX1d/w7J8xDUBr+VTL0EkCpbFFbOlzhJM7I0 e4mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=R0clArm6; 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 e12si1314040edj.70.2019.10.30.02.51.19; Wed, 30 Oct 2019 02:51:48 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=R0clArm6; 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 S1726262AbfJ3JuM (ORCPT + 99 others); Wed, 30 Oct 2019 05:50:12 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35384 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbfJ3JuM (ORCPT ); Wed, 30 Oct 2019 05:50:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ezNM7rdzF5GJdI/K6pMEPr7zdlKZrHRBRwkru5SQrtE=; b=R0clArm67jwuWvTDRXiU7RQgq dN4B5u5eqgS5Qjq0APyuS4Pv7WLScC80OjqnhhiZ1AzTSOspYYy/LddVxQgL0XvQvhrmhryCHqdDk YsCMRVdRzsxPeiRYqfVEemenwVMq5utH23Tu0i/AZwfChMX+NgPYuLmvj2Va/+vWhoBRHEFUyXhHD tnGlvajJ6sVyVUanY+RcIpL5yqmalcCD32A6WlWDnJlVrCcvPgsbYURf1kIR27HMfXC6mOzzSpXKx EoPNz+pB6GMB9vztUBcDjYgFRLbpsrqGDI4UUuLMCsbzb6Kxe2P1UrMbXabxLMcS6nPk7nrBY0mA1 YIm099NSA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iPkbp-0008Mh-T0; Wed, 30 Oct 2019 09:49:46 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id B43A03006D0; Wed, 30 Oct 2019 10:48:40 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CF47F2B438360; Wed, 30 Oct 2019 10:49:41 +0100 (CET) Date: Wed, 30 Oct 2019 10:49:41 +0100 From: Peter Zijlstra To: "Kang, Luwei" Cc: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "Christopherson, Sean J" , "vkuznets@redhat.com" , "wanpengli@tencent.com" , "jmattson@google.com" , "joro@8bytes.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "hpa@zytor.com" , "x86@kernel.org" , "ak@linux.intel.com" , "thomas.lendacky@amd.com" , "acme@kernel.org" , "mark.rutland@arm.com" , "alexander.shishkin@linux.intel.com" , "jolsa@redhat.com" , "namhyung@kernel.org" Subject: Re: [PATCH v1 3/8] KVM: x86: Allocate performance counter for PEBS event Message-ID: <20191030094941.GQ4097@hirez.programming.kicks-ass.net> References: <1572217877-26484-1-git-send-email-luwei.kang@intel.com> <1572217877-26484-4-git-send-email-luwei.kang@intel.com> <20191029144612.GK4097@hirez.programming.kicks-ass.net> <82D7661F83C1A047AF7DC287873BF1E173835B1A@SHSMSX104.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <82D7661F83C1A047AF7DC287873BF1E173835B1A@SHSMSX104.ccr.corp.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 30, 2019 at 04:06:36AM +0000, Kang, Luwei wrote: > > > static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, > > > unsigned config, bool exclude_user, > > > bool exclude_kernel, bool intr, > > > - bool in_tx, bool in_tx_cp) > > > + bool in_tx, bool in_tx_cp, bool pebs) > > > { > > > struct perf_event *event; > > > struct perf_event_attr attr = { > > > @@ -111,9 +111,12 @@ static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, > > > .exclude_user = exclude_user, > > > .exclude_kernel = exclude_kernel, > > > .config = config, > > > + .precise_ip = pebs ? 1 : 0, > > > + .aux_output = pebs ? 1 : 0, > > > > srsly? > > Hi Peter, > Thanks for review. For aux_output, I think it should be set 1 when the guest wants to enabled PEBS by Intel PT. > For precise_ip, it is the precise level in perf and set by perf command line in KVM guest, this may not reflect the accurate value (can be 0~3) here. Here set to 1 is used to allocate a counter for PEBS event and set the MSR_IA32_PEBS_ENABLE register. For PMU virtualization, KVM will trap the guest's write operation to PMU registers and allocate/free event counter from host if a counter enable/disable in guest. We can't always deduce the exact parameter of perf command line from the value of the guest writers to the register. Please, teach your MUA to wrap on 78 chars. The thing I really fell over is the gratuitous 'bool ? 1 : 0'. But yes, the aux_output without a group leader is dead wrong. We'll go fix perf_event_create_kernel_counter() to refuse that.