From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752021AbdHNHMY (ORCPT ); Mon, 14 Aug 2017 03:12:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46812 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751459AbdHNHMW (ORCPT ); Mon, 14 Aug 2017 03:12:22 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0FA4BB17B Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [RFC PATCH V2] kvm: x86: reduce rtc 0x70 access vm-exit time To: Peng Hao , rkrcmar@redhat.com, corbet@lwn.net Cc: kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <1502653881-116299-1-git-send-email-peng.hao2@zte.com.cn> From: Paolo Bonzini Message-ID: <7004ff96-91a8-83f8-8d2d-2bfb1c6ba418@redhat.com> Date: Mon, 14 Aug 2017 09:12:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1502653881-116299-1-git-send-email-peng.hao2@zte.com.cn> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 14 Aug 2017 07:12:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/08/2017 21:51, Peng Hao wrote: > some versions of windows guest access rtc frequently because of > rtc as system tick.guest access rtc like this: write register index > to 0x70, then write or read data from 0x71. writing 0x70 port is > just as index and do nothing else. So we can use coalesced mmio to > handle this scene to reduce VM-EXIT time. > without my patch, get the vm-exit time of accessing rtc 0x70 using > perf tools: (guest OS : windows 7 64bit) > IO Port Access Samples Samples% Time% Min Time Max Time Avg time > 0x70:POUT 86 30.99% 74.59% 9us 29us 10.75us (+- 3.41%) > > with my patch > IO Port Access Samples Samples% Time% Min Time Max Time Avg time > 0x70:POUT 106 32.02% 29.47% 0us 10us 1.57us (+- 7.38%) > > the patch is a part of optimizing rtc 0x70 port access. Another is in > qemu. > > Signed-off-by: Peng Hao Very nice, thanks. The new documentation file can be used later as a base for documentation of coalesced MMIO ioctls. Here is an edited version: ---- Coalesced MMIO and coalesced PIO can be used to optimize writes to simple device registers. Writes to a coalesced-I/O region are not reported to userspace until the next non-coalesced I/O is issued, in a similar fashion to write combining hardware. In KVM, coalesced writes are handled in the kernel without exits to userspace, and are thus several times faster. Examples of devices that can benefit from coalesced I/O include: - devices whose memory is accessed with many consecutive writes, for example the EGA/VGA video RAM. - windowed I/O, such as the real-time clock. The address register (port 0x70 in the RTC case) can use coalesced I/O, cutting the number of userspace exits by half when reading or writing the RTC. ---- Paolo