public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "Li, Xin B" <xin.b.li-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 2/2] Add MSR Bitmap support in VMX
Date: Fri, 03 Aug 2007 19:10:38 +0300	[thread overview]
Message-ID: <46B3537E.30302@qumranet.com> (raw)
In-Reply-To: <B30DA1341B0CFA4893EF8A36B40B5C5D0178DC43-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]

Li, Xin B wrote:
>> -----Original Message-----
>> From: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org 
>> [mailto:kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of 
>> Ulrich Drepper
>> Sent: Friday, August 03, 2007 2:24 AM
>> To: Nakajima, Jun
>> Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>> Subject: Re: [kvm-devel] [PATCH 2/2] Add MSR Bitmap support in VMX
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Nakajima, Jun wrote:
>>     
>>>> Looking at the Linux context switch code, it can bang on MSR_FS_BASE
>>>>         
>>> and
>>>       
>>>> MSR_KERNEL_GS_BASE. A high context switch rate between 
>>>>         
>> threads (which
>>     
>>>> use %gs or %fs) can show an improvement with this.  Things 
>>>>         
>> like kbuild
>>     
>>>> probably won't as they use single threaded processes.
>>>>         
>>> Right. 
>>>       
>> In Linux there is no difference between single- and multi-threaded
>> processes when it comes to setting up segment registers.  Every x86-64
>> process uses %fs for TLS and every x86 process uses %gs.  There are
>> always variables accessed this way (errno, for instance).
>>
>>     
>
> I have to say, the benefit form _no_ VMExits on these VMExits are not so
> obviously, because each context switch invloves a guest CR3 update, then
> a page fault vmexit is triggered and a shadow handling is involved,
> which is the major cost of guest context switch.
>   

A small test program demonstrates the benefit.  In thread mode, it takes 
5 seconds without the patch and 3 seconds with the patch applied (200K 
and ~0 exits/sec).  In fork mode, it takes 10 seconds without the patch 
and 7.2 seconds with the patch (420K and 280K exits/sec).  Note that 
with this test there are no page fault exits, only cr and msr exits 
(with the threaded mode avoiding the cr exit).

So the patch is quite measurable on microbenchmarks -- in threaded mode 
we're at native performance.

-- 
error compiling committee.c: too many arguments to function


[-- Attachment #2: cswitch.c --]
[-- Type: text/x-csrc, Size: 573 bytes --]


#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>

static int p1[2], p2[2];

#define N 1000000

void *server(void *_)
{
	char buf;

	while (read(p1[0], &buf, 1) == 1)
		write(p2[1], &buf, 1);
}

void client()
{
	char buf;
	int i;

	for (i = 0; i < N; ++i) {
		write(p1[1], &buf, 1);
		read(p2[0], &buf, 1);
	}
}

int main(int ac, char **av)
{
	pthread_t thread;

	pipe(p1);
	pipe(p2);

	if (ac < 2 || strcmp(av[1], "fork") != 0)
		pthread_create(&thread, NULL, server, NULL);
	else
		if (fork() == 0) {
			server(NULL);
			return 0;
		}
	client();
	return 0;
}

[-- Attachment #3: Type: text/plain, Size: 315 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

  parent reply	other threads:[~2007-08-03 16:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-01  9:10 [PATCH 2/2] Add MSR Bitmap support in VMX Yang, Sheng
     [not found] ` <DB3BD37E3533EE46BED2FBA80995557F62F4C6-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-02 10:59   ` Avi Kivity
     [not found]     ` <46B1B925.1080808-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-02 12:03       ` He, Qing
     [not found]         ` <37E52D09333DE2469A03574C88DBF40F048ED2-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-02 12:39           ` Avi Kivity
     [not found]             ` <46B1D092.7070609-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-02 14:23               ` Avi Kivity
     [not found]                 ` <46B1E8D6.6010106-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-02 14:41                   ` Li, Xin B
     [not found]                     ` <B30DA1341B0CFA4893EF8A36B40B5C5D0178DAEF-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-02 14:50                       ` Avi Kivity
     [not found]                         ` <46B1EF29.9000200-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-02 15:07                           ` Li, Xin B
2007-08-02 15:30                           ` ron minnich
     [not found]                             ` <13426df10708020830r5e716fb3p179f6937fb1f9412-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-02 15:50                               ` Avi Kivity
     [not found]                                 ` <46B1FD30.9040708-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-02 17:54                                   ` Nakajima, Jun
     [not found]                                     ` <97D612E30E1F88419025B06CB4CF1BE10318605D-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-02 18:23                                       ` Ulrich Drepper
     [not found]                                         ` <46B22134.7080807-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2007-08-03  1:26                                           ` Li, Xin B
     [not found]                                             ` <B30DA1341B0CFA4893EF8A36B40B5C5D0178DC43-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-03 16:10                                               ` Avi Kivity [this message]
2007-08-02 21:55               ` Rusty Russell
     [not found]                 ` <1186091736.6131.149.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-08-03 14:54                   ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46B3537E.30302@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=xin.b.li-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox