Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp887454ybx; Wed, 30 Oct 2019 06:44:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxOb72yRUC/kEKbggu0C4DXJ1s8UmJj91H08A03ey4WAtrkGQ1D3j6RLU17YGXbb0wGBR7 X-Received: by 2002:a17:906:e2c2:: with SMTP id gr2mr8958430ejb.31.1572443061288; Wed, 30 Oct 2019 06:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572443061; cv=none; d=google.com; s=arc-20160816; b=Mc1CTQKMZq/LPikkHIKOI7iigUxi6B3PSNbDFxHo4cIqE1y+fhSn3mpPPnQNw6W04T KCiERpmj5SDyeKJJ+3v3rZw2rqo8nrmNAdMHMimX8HVQh98D+MCLFLwdc8G4srREi+Qz krJJWdeh5hAQOM5Y5eln3ut7fq5mbLZ0LpzGSTX+CfQTYXXk9sP9Y12/E4lRYByn7XPK jR7Q9SgRvzGL3iJybHrVFB1AP45UBlCWSN9qDCEoBT41R9u6lyRaJ74ZowlscaWK4js3 jB5PdjUruioz7gDOYakVdIN94KCHu8O9tqvlLDh15TyaJJLBRaHe9meMAsMRX+DTv0C1 IJRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=11UevIIi08OdopeifVWtv6XjUEPtTK8aUNhhsCMHeVs=; b=bw+TBcK/NLzs7nkXzMSOitOO9D6rF1eaJvzOH6FWVUT+kyUAxUgJNIT73B6SoraMSm iWdB5GpOT3B+D1MhC+gi7DCdZXUpYua1wVvejdycZjB8RusajsK8waZhLctF2a++h/OH 5pOkASyH9Pxl7F0n4SOdbC872io+ZqFxkfymPSapHvaQgW+Rmd/+jj+rpO6bCoztQJ6h 0Stx03YZZreFohPkdYVaUOUMTjzm6c5SzciLv2diH3ymE1MnqvkADMcir2e8jOvGndMA SVuBCov92b/q17C5CEToULsfBAuGzGYHPytsUt0S8tzFD/6l5uAchgECL+Pjtqa3cpLN JndA== 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 j5si1498843edc.195.2019.10.30.06.43.57; Wed, 30 Oct 2019 06:44:21 -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; 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 S1726602AbfJ3NlM (ORCPT + 99 others); Wed, 30 Oct 2019 09:41:12 -0400 Received: from mga04.intel.com ([192.55.52.120]:45426 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbfJ3NlL (ORCPT ); Wed, 30 Oct 2019 09:41:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2019 06:41:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,247,1569308400"; d="scan'208";a="283555445" Received: from um.fi.intel.com (HELO um) ([10.237.72.57]) by orsmga001.jf.intel.com with ESMTP; 30 Oct 2019 06:41:05 -0700 From: Alexander Shishkin To: Peter Zijlstra , "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" , "jolsa\@redhat.com" , "namhyung\@kernel.org" , alexander.shishkin@linux.intel.com Subject: Re: [PATCH v1 3/8] KVM: x86: Allocate performance counter for PEBS event In-Reply-To: <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> <20191030094941.GQ4097@hirez.programming.kicks-ass.net> Date: Wed, 30 Oct 2019 15:41:04 +0200 Message-ID: <87k18mfj0v.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter Zijlstra writes: > 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, Notice the .exclude_kernel assignment above that does the same thing the other way around. Regards, -- Alex