Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8585989imu; Fri, 28 Dec 2018 22:51:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN62ntFNd7Zwi9H4q4gi4jbZgdRfDPiL/BWe11HYfEeL8pPmbDGyQC5gjJkzsHYFWd+48pbG X-Received: by 2002:a63:f515:: with SMTP id w21mr791996pgh.220.1546066315542; Fri, 28 Dec 2018 22:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546066315; cv=none; d=google.com; s=arc-20160816; b=F9lhxUNfrXBTuiw5BZDH8AHzoPzBU1+XvXu3lrvM9CECKBNZZ3MfKElCiinjaCIcoy U9Qm2iG+FqUAkajl1Hzdp+QUG98VT1JRYPRy04rxErjbxCbYKGLLgvpusVQY26CJYdnE /ICjktZPqWLLu424GZKENDx9qIpkRDN2jRj6kvLdZjb0Bja3o4Ic8jE8vEK2cLUgjUnj teHiEYZT2iyx2Z9D5LmIskxMa32NSJd6XtnouPtz6DcGoVhXao6fU0Y/+krSnJQZKWzG Y6qd8fh0vLHV941joIofA2dMuNC0UM3OP3Pg/VdRiFLdnUoOrl3eVUdSMFkhHJRd0DLl BTNw== 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; bh=CrqqZGANgt/jdez7geXqZO9XcP7gDnwT/1TFziqS1kI=; b=rYOY22Sbw7clJfk+5r4jlc6SpMkSYH59UiBym+cXGgKOrE/hMTgKjL6T79gg0oXc9k ii/Zj6WzxFa8zLiSIoI2DQev4C33P/RHcbJqSZp2GplTBLovHsfwzByQIiqrYJ/kG2jQ D3KcQMUZFLr8px2+aRgS6Cgsfp8bnofNnz0eOxVa0RaG7frvl0VtpRtEJ7MUMZ7gqpNq yJ0VKj3xlP6W2x0RZnKWDL/eZlmTMi8Kucw4ObuJcMSi/OjN7BFokJMv7hd/TkJRsoGg oDeSqTVt0xWApK+XlQ05/DN9FZTIPniB174REr1xKdGHYFe+jK476IxT8F8iTGA383BN 6HKQ== 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 a13si42613418pfd.3.2018.12.28.22.51.40; Fri, 28 Dec 2018 22:51:55 -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 S1730815AbeL1TKH (ORCPT + 99 others); Fri, 28 Dec 2018 14:10:07 -0500 Received: from mga01.intel.com ([192.55.52.88]:8692 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727890AbeL1TKH (ORCPT ); Fri, 28 Dec 2018 14:10:07 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Dec 2018 11:10:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,410,1539673200"; d="scan'208";a="121838978" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.137]) by FMSMGA003.fm.intel.com with ESMTP; 28 Dec 2018 11:10:06 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id 1CC76300B65; Fri, 28 Dec 2018 11:10:06 -0800 (PST) Date: Fri, 28 Dec 2018 11:10:06 -0800 From: Andi Kleen To: Wei Wang Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, peterz@infradead.org, kan.liang@intel.com, mingo@redhat.com, rkrcmar@redhat.com, like.xu@intel.com, jannh@google.com, arei.gonglei@huawei.com Subject: Re: [PATCH v4 10/10] KVM/x86/lbr: lazy save the guest lbr stack Message-ID: <20181228191006.GI25620@tassilo.jf.intel.com> References: <1545816338-1171-1-git-send-email-wei.w.wang@intel.com> <1545816338-1171-11-git-send-email-wei.w.wang@intel.com> <20181227205104.GG25620@tassilo.jf.intel.com> <5C259CBA.4030805@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5C259CBA.4030805@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 Fri, Dec 28, 2018 at 11:47:06AM +0800, Wei Wang wrote: > On 12/28/2018 04:51 AM, Andi Kleen wrote: > > Thanks. This looks a lot better than the earlier versions. > > > > Some more comments. > > > > On Wed, Dec 26, 2018 at 05:25:38PM +0800, Wei Wang wrote: > > > When the vCPU is scheduled in: > > > - if the lbr feature was used in the last vCPU time slice, set the lbr > > > stack to be interceptible, so that the host can capture whether the > > > lbr feature will be used in this time slice; > > > - if the lbr feature wasn't used in the last vCPU time slice, disable > > > the vCPU support of the guest lbr switching. > > time slice is the time from exit to exit? > > It's the vCPU thread time slice (e.g. 100ms). I don't think the time slices are that long, but ok. > > > > > This might be rather short in some cases if the workload does a lot of exits > > (which I would expect PMU workloads to do) Would be better to use some > > explicit time check, or at least N exits. > > Did you mean further increasing the lazy time to multiple host thread > scheduling time slices? > What would be a good value for "N"? I'm not sure -- i think the goal would be to find a value that optimizes performance (or rather minimizes overhead). But perhaps if it's as you say the scheduler time slice it might be good enough as it is. I guess it could be tuned later based on more experneice. > > or partially cleared. This would be user visible. > > > > In theory could try to detect if the guest is inside a PMI and > > save/restore then, but that would likely be complicated. I would > > save/restore for all cases. > > Yes, it is easier to save for all the cases. But curious for the > non-callstack > mode, it's just ponit sampling functions (kind of speculative in some > degree). > Would rarely losing a few recordings important in that case? In principle no for statistical samples, but I know some tools complain for bogus samples (e.g. autofdo will). Also with perf report --branch-history it will be definitely visible. I think it's easier to always safe now than to handle the user complaints about this later. -Andi