From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernhard Held Subject: Re: [PATCH 04/13] qemu-kvm: Remove eventfd compat header Date: Sun, 03 Jul 2011 20:31:11 +0200 Message-ID: <4E10B56F.2030305@mgpi.de> References: <20110628110908.GB5661@redhat.com> <4E103A8B.70602@mgpi.de> <20110703095406.GA14862@redhat.com> <20110703095743.GB14862@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Jan Kiszka , Avi Kivity , Marcelo Tosatti , kvm@vger.kernel.org, Alex Williamson To: "Michael S. Tsirkin" Return-path: Received: from smtp.mgpi.de ([212.202.249.42]:41672 "EHLO smtp.mgpi.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754566Ab1GCSzQ (ORCPT ); Sun, 3 Jul 2011 14:55:16 -0400 In-Reply-To: <20110703095743.GB14862@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Am 03.07.2011 11:57, schrieb Michael S. Tsirkin: > On Sun, Jul 03, 2011 at 12:54:06PM +0300, Michael S. Tsirkin wrote: >> On Sun, Jul 03, 2011 at 11:46:51AM +0200, Bernhard Held wrote: >>> #ifndef _COMPAT_SYS_EVENTFD >>> #define _COMPAT_SYS_EVENTFD >>> >>> #include >>> #include >>> >>> /* Flags for signalfd. */ >>> enum >>> { >>> EFD_SEMAPHORE = 1, >>> #define EFD_SEMAPHORE EFD_SEMAPHORE >>> EFD_CLOEXEC = 02000000, >>> #define EFD_CLOEXEC EFD_CLOEXEC >>> EFD_NONBLOCK = 04000 >>> #define EFD_NONBLOCK EFD_NONBLOCK >>> }; >>> >>> #ifndef __NR_eventfd2 >>> #if defined(__x86_64__) >>> #define __NR_eventfd2 290 >>> #elif defined(__i386__) >>> #define __NR_eventfd2 328 >>> #else >>> #error Cannot detect your architecture! >>> #endif >>> #endif >> >> Can't we use SYS_eventfd2 instead? > > Looks like we can't, but __NR_eventfd2 > does seem to exit? SYS_eventfd2 is not defined on systems with old glibc. These numbers are working for me, for 32 and 64 bit linux. What means "__NR_eventfd2 does seem to exit"? The eventfd() man page nicely documents the evolution: http://www.kernel.org/doc/man-pages/online/pages/man2/eventfd.2.html "eventfd() is available on Linux since kernel 2.6.22. Working support is provided in glibc since version 2.8. The eventfd2() system call (see NOTES) is available on Linux since kernel 2.6.27. Since version 2.9, the glibc eventfd() wrapper will employ the eventfd2() system call, if it is supported by the kernel." "There are two underlying Linux system calls: eventfd() and the more recent eventfd2(). The former system call does not implement a flags argument. The latter system call implements the flags values described above. The glibc wrapper function will use eventfd2() where it is available." This means that the current compat header is buggy; qemu-kvm sets the flags argument, but the wrapper uses the old eventfd() system call. Bernhard >>> static inline int eventfd (int count, int flags) >>> { >>> return syscall(__NR_eventfd2, count, flags); >>> } >>> >>> #endif >>> >>