public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 03/21] Remove use of signalfd in block-raw-posix.c
Date: Sun, 03 May 2009 19:48:29 +0300	[thread overview]
Message-ID: <49FDCADD.50608@redhat.com> (raw)
In-Reply-To: <49F9A949.2040609@redhat.com>

Avi Kivity wrote:
> Anthony Liguori wrote:
>>>
>>> Oh okay.  But signal delivery is slow; for example the FPU needs to 
>>> be reset.
>>
>> Is it really justified to add all of this extra code (including 
>> signalfd emulation) for something that probably isn't even measurable?
>
> We don't have to add signalfd emulation; we can simply use signal+pipe 
> in that case.
>
> We won't know if it's measurable or not until we measure it (or not).
>
>>
>> I like using wiz-bang features of Linux as much as the next guy, but 
>> I think we're stretching to justify it here :-)
>>
>
> I think it's worth it in this case.  It will become more important in 
> time, too.
>

Out of curiosity, I measured this:

[avi@balrog test]$ ./signal
 2777 ns/signal (pipe)
  844 ns/signal (signalfd)


At 10000 signals/sec, this will save about 2% cpu time.  It's definitely 
worthwhile for the handful of lines it takes.

test program:

#include <signal.h>
#include <unistd.h>
#include <sys/signalfd.h>
#include <sys/time.h>
#include <stdio.h>

static int wfd;

static void handler(int signum)
{
    char b;

    write(wfd, &b, 1);
}

static int create_pipe(void)
{
    int fd[2];
    sigset_t s;

    pipe(fd);
    wfd = fd[1];
    signal(SIGUSR1, handler);
    sigemptyset(&s);
    sigaddset(&s, SIGUSR1);
    sigprocmask(SIG_UNBLOCK, &s, NULL);
    return fd[0];
}

static int create_signalfd(void)
{
    sigset_t s;

    sigemptyset(&s);
    sigaddset(&s, SIGUSR1);
    sigprocmask(SIG_BLOCK, &s, NULL);
    return signalfd(-1, &s, 0);
}

static uint64_t time_usec(void)
{
    struct timeval tv;

    gettimeofday(&tv, NULL);
    return (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec;
}

#define N 10000000

static void test(const char *name, int fd, int len)
{
    int i;
    uint64_t t1, t2;
    char buf[128];

    t1 = time_usec();
    for (i = 0; i < N; ++i) {
        raise(SIGUSR1);
        read(fd, buf, len);
    }
    t2 = time_usec();

    close(fd);

    printf("%5d ns/signal (%s)\n", 1000 * (t2 - t1) / N, name);
}

int main(int ac, char **av)
{
    test("pipe", create_pipe(), 1);
    test("signalfd", create_signalfd(), 128);
    return 0;
}


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


  reply	other threads:[~2009-05-03 16:48 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-29 21:20 [PATCH 0/21] Remove merge artifacts from qemu-kvm Anthony Liguori
2009-04-29 21:20 ` [PATCH 01/21] Remove memalign call for guess_disk_lchs Anthony Liguori
2009-04-29 21:20 ` [PATCH 02/21] Remove devfn from BlockDriverState Anthony Liguori
2009-04-29 21:20 ` [PATCH 03/21] Remove use of signalfd in block-raw-posix.c Anthony Liguori
2009-04-30  9:28   ` Avi Kivity
2009-04-30 12:54     ` Anthony Liguori
2009-04-30 13:05       ` Avi Kivity
2009-04-30 13:28         ` Anthony Liguori
2009-04-30 13:36           ` Avi Kivity
2009-05-03 16:48             ` Avi Kivity [this message]
2009-04-29 21:20 ` [PATCH 04/21] Remove stray whitespace Anthony Liguori
2009-04-29 21:20 ` [PATCH 05/21] Remove extra call to kvm_cpu_exec() Anthony Liguori
2009-04-29 21:20 ` [PATCH 06/21] Remove dead functions from cutils Anthony Liguori
2009-04-29 21:20 ` [PATCH 07/21] Remove dead macros likely/unlikely in exec.c Anthony Liguori
2009-04-29 21:20 ` [PATCH 08/21] Remove leftovers in device-hotplug.c Anthony Liguori
2009-04-29 21:20 ` [PATCH 09/21] Remove unnecessary setting of cmos smp_cpu count Anthony Liguori
2009-04-29 21:20 ` [PATCH 10/21] Remove IBM copyright in unmodified file in upstream Anthony Liguori
2009-04-29 21:38   ` Hollis Blanchard
2009-04-29 21:20 ` [PATCH 11/21] Remove unused variables in vga.c Anthony Liguori
2009-04-30  9:33   ` Avi Kivity
2009-04-30 13:09     ` Anthony Liguori
2009-04-29 21:20 ` [PATCH 12/21] Remove odd hack " Anthony Liguori
2009-04-30  9:39   ` Avi Kivity
2009-04-29 21:20 ` [PATCH 13/21] Remove virtio-console PIF change Anthony Liguori
2009-04-30  9:40   ` Avi Kivity
2009-04-29 21:20 ` [PATCH 14/21] Remove -cpu-vendor-string Anthony Liguori
2009-04-30  9:41   ` Avi Kivity
2009-04-30 13:10     ` Anthony Liguori
2009-04-30 13:16       ` Avi Kivity
2009-04-30 13:26         ` Anthony Liguori
2009-04-30 13:33           ` Avi Kivity
2009-04-29 21:20 ` [PATCH 15/21] Remove defined(TARGET_X86_64) Anthony Liguori
2009-04-29 21:20 ` [PATCH 16/21] Remove clean rule change Anthony Liguori
2009-04-30  9:42   ` Avi Kivity
2009-04-30 15:10     ` Hollis Blanchard
2009-04-30 15:13       ` Avi Kivity
2009-04-29 21:20 ` [PATCH 17/21] Remove #define __user in usb-linux.c Anthony Liguori
2009-04-30  9:43   ` Avi Kivity
2009-04-30 13:11     ` Anthony Liguori
2009-04-30 13:17       ` Avi Kivity
2009-04-30 13:20         ` Anthony Liguori
2009-04-29 21:20 ` [PATCH 18/21] Remove host_alarm_timer hacks Anthony Liguori
2009-04-30  9:44   ` Avi Kivity
2009-04-30 13:19     ` Anthony Liguori
2009-04-30 13:25       ` Avi Kivity
2009-04-30 13:37         ` Anthony Liguori
2009-04-30 15:46           ` Avi Kivity
2009-04-30 15:49             ` Anthony Liguori
2009-04-30 15:53               ` Avi Kivity
2009-04-29 21:20 ` [PATCH 19/21] Use QEMU_PKGVERSION to declare kvm-devel Anthony Liguori
2009-04-29 21:20 ` [PATCH 20/21] Get rid of qemu_get_launch_info() Anthony Liguori
2009-04-29 21:20 ` [PATCH 21/21] Leave upstream QEMU comments intact Anthony Liguori
2009-04-30  9:50 ` [PATCH 0/21] Remove merge artifacts from qemu-kvm 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=49FDCADD.50608@redhat.com \
    --to=avi@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=kvm@vger.kernel.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