Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2212737imm; Thu, 20 Sep 2018 09:24:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY0KROZOQ/YNZ1nCFtnZ3mi02ya+5PVzJf5ptE4bI2U3Ob6lihCfAiKKts5rHKGVFnV1rX7 X-Received: by 2002:a17:902:bb08:: with SMTP id l8-v6mr39978015pls.71.1537460699114; Thu, 20 Sep 2018 09:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537460699; cv=none; d=google.com; s=arc-20160816; b=LIrf8HYR9oa8LFJtFj1ArmeJHece+VD41uO7eRBVXERUo7yAGcVjFOshsQqjO/t98V O0afCYaYUIaeBgPoKcAa72S4eA+w3bN+fYuTmGLj1oo8HYJv8X6rflW3ZUE6/aoL6yph dBmYd+LOl8PLLiLfKA+63NDZuDYerheRWodliXYfFjvo7mxOUv/3OmyFFczSnr5M8b2m l+ZFgjZgP92mg6A9koTxjzWtf7R6ZSNYf7yRX9CtrosKsss7qFo6vGE6nJ203ewBkwaX xmx66QeCfm7U2ihg7xzFNZIXaQcD8i6O8XFAkeh6TsLtM7DSL685qbWAkQBgHtexTFi/ Wj2A== 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=aiVv8H0RRgbNo+YW6tyz47IwYmBIyrMZHycD8Ttvbwg=; b=h6DCNJToY77QQPcfIB0tUG7z0SHtIDwaeN9nKdwePEJZnkIajpizrTp6w6IMztTQOA cWXhu9836ryQVtI1DCGkgEhcUpEj0tLVeKd6iAmfjsATHR5o9M+vorKdEJwgdViSnDKL AsjRx7SPaeM7MqxH60jDtw10+nqwqLix/06HHnzJao07hX0bxQ8D/zHc5XllBdSQAwsw 1J2GaMAW+cC+ZUHEHNoetsnC+vcryuTe5B63Ju3NNwZ2w0OLUTa+Z+O7BrTBQLvulMPY B42EmMc0XPolGjw4eIlRXEX0kjbuc3zzaiLXORAiT1wt1cm+8KuC3YSQp+nZzBicW+r2 yYqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=xkDc7jNX; 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 r22-v6si25259453pgm.258.2018.09.20.09.24.43; Thu, 20 Sep 2018 09:24:59 -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=merlin.20170209 header.b=xkDc7jNX; 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 S2388095AbeITWIj (ORCPT + 99 others); Thu, 20 Sep 2018 18:08:39 -0400 Received: from merlin.infradead.org ([205.233.59.134]:39120 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388077AbeITWIi (ORCPT ); Thu, 20 Sep 2018 18:08:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=aiVv8H0RRgbNo+YW6tyz47IwYmBIyrMZHycD8Ttvbwg=; b=xkDc7jNXMg413H986Y/N+eQc8 tcBJNwuW3TDIQtccQiSiJUhF9ZpZeEZkxm2XqlNKZAwa7jFrp/30MMpWZclvy39uieivFmbuPlwqj 70BwkUm2/0yEaexUkeU2mV5jobaJ0Roo/zSm14yHAF0mucGP7C98+tE1WkHMnvhV59qKjYbtfAIPZ RQl0VN0FVZ+WO3xapvAnwe1gkBPgVgLb/bcdRzCmwrHXRK+xx93hPKG+1EsNe5USBO1Jxji+y/KDx EQbRPpdPTWl23DzQzw1I1Z/gLB71XTGuyjMDIQSU1iytlBHy/PF6iBPooEeMbE/6+gGPqHTuqLEuf r/XoAyg8A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g31kP-0003q9-MX; Thu, 20 Sep 2018 16:24:10 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8B4812024E44A; Thu, 20 Sep 2018 18:24:07 +0200 (CEST) Date: Thu, 20 Sep 2018 18:24:07 +0200 From: Peter Zijlstra To: Andi Kleen Cc: Wei Wang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, kan.liang@intel.com, mingo@redhat.com, rkrcmar@redhat.com, like.xu@intel.com, jannh@google.com, arei.gonglei@huawei.com Subject: Re: [PATCH v3 4/5] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack Message-ID: <20180920162407.GA24124@hirez.programming.kicks-ass.net> References: <1537437959-8751-1-git-send-email-wei.w.wang@intel.com> <1537437959-8751-5-git-send-email-wei.w.wang@intel.com> <20180920153035.GB10360@tassilo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180920153035.GB10360@tassilo.jf.intel.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 20, 2018 at 08:30:35AM -0700, Andi Kleen wrote: > > +int intel_pmu_enable_save_guest_lbr(struct kvm_vcpu *vcpu) > > +{ > > + struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); > > + struct perf_event *event; > > + struct perf_event_attr attr = { > > + .type = PERF_TYPE_RAW, > > + .size = sizeof(attr), > > + .pinned = true, > > + .exclude_host = true, > > + .sample_type = PERF_SAMPLE_BRANCH_STACK, > > + .branch_sample_type = PERF_SAMPLE_BRANCH_CALL_STACK | > > + PERF_SAMPLE_BRANCH_USER | > > + PERF_SAMPLE_BRANCH_KERNEL, > > I think that will allocate an extra perfmon counter, right? I throught the same too, but I think the exclude_host/guest, whichever is the right one makes that work for regular counters too. That code is a wee bit magical and I didn't take the time to reverse engineer that. It most certainly needs a comment.