From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: Non-exiting rdpmc on KVM guests? Date: Tue, 21 Apr 2015 17:05:14 +0200 Message-ID: <20150421150514.GC3182@worktop.meeting.verilan.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm list To: Andy Lutomirski Return-path: Received: from casper.infradead.org ([85.118.1.10]:45752 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752266AbbDUPFV (ORCPT ); Tue, 21 Apr 2015 11:05:21 -0400 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Apr 20, 2015 at 05:47:23PM -0700, Andy Lutomirski wrote: > I just wrote a little perf self-monitoring tool that uses rdpmc to > count cycles. Performance sucks under KVM (VMX). > > How hard would it be to avoid rdpmc exits in cases where the host and > guest pmu configurations are compatible as seen by rdpmc? I'm mostly > ignorant of how the PMU counter offsets and such work. I'm not sure how all the VMX stuff works. how is rdpmc seem? It it at all possible to not trap that? But as it stands there is not even a hint from the emulated pmu events on which counters they 'ought' to run so they landing the same way the guest thinks they ought to is rather small. 'someone' would have to go look at the event scheduling and see how to implement it, my first suggestion would be to set hwc->idx to the desired number and hope x86_schedule_events() takes the fast path. Of course, the moment there's host events along with the guest events the whole thing comes tumbling down, but there's nothing much one can do about that.