From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 03/21] Remove use of signalfd in block-raw-posix.c Date: Sun, 03 May 2009 19:48:29 +0300 Message-ID: <49FDCADD.50608@redhat.com> References: <1241040038-17183-1-git-send-email-aliguori@us.ibm.com> <1241040038-17183-4-git-send-email-aliguori@us.ibm.com> <49F96F37.2070002@redhat.com> <49F99F8A.8010806@codemonkey.ws> <49F9A1FC.2060705@redhat.com> <49F9A786.5020306@us.ibm.com> <49F9A949.2040609@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Anthony Liguori Return-path: Received: from mx2.redhat.com ([66.187.237.31]:42709 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751313AbZECQsc (ORCPT ); Sun, 3 May 2009 12:48:32 -0400 In-Reply-To: <49F9A949.2040609@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 #include #include #include #include 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