From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992868AbXEBHMG (ORCPT ); Wed, 2 May 2007 03:12:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754908AbXEBHMF (ORCPT ); Wed, 2 May 2007 03:12:05 -0400 Received: from haxent.com ([65.99.219.155]:2772 "EHLO haxent.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754889AbXEBHME convert rfc822-to-8bit (ORCPT ); Wed, 2 May 2007 03:12:04 -0400 Message-ID: <463839BD.4030008@haxent.com.br> Date: Wed, 02 May 2007 04:11:57 -0300 From: Davi Arnaut MIME-Version: 1.0 To: Eric Dumazet Cc: Andrew Morton , Davide Libenzi , Linus Torvalds , Linux Kernel Mailing List Subject: Re: [patch 14/22] pollfs: pollable futex References: <20070502052235.914764000@haxent.com.br> <20070502053427.123392000@haxent.com.br> <4638279A.9010105@cosmosbay.com> <46382CA2.1020504@haxent.com.br> <46383218.4020406@cosmosbay.com> In-Reply-To: <46383218.4020406@cosmosbay.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Eric Dumazet wrote: > Davi Arnaut a écrit : >> Eric Dumazet wrote: >>> Davi Arnaut a écrit : >>>> Asynchronously wait for FUTEX_WAKE operation on a futex if it still contains >>>> a given value. There can be only one futex wait per file descriptor. However, >>>> it can be rearmed (possibly at a different address) anytime. >>>> >>>> The pollable futex approach is far superior (send and receive events from >>>> userspace or kernel) to eventfd and fixes (supercedes) FUTEX_FD at the same time. >>>> >>>> Building block for pollable semaphores and user-defined events. >>>> >>>> Signed-off-by: Davi E. M. Arnaut >>>> >>>> --- >>>> fs/pollfs/Makefile | 1 >>>> fs/pollfs/futex.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++ >>>> init/Kconfig | 7 ++ >>>> 3 files changed, 162 insertions(+) >>>> >>>> Index: linux-2.6/fs/pollfs/Makefile >>>> =================================================================== >>>> --- linux-2.6.orig/fs/pollfs/Makefile >>>> +++ linux-2.6/fs/pollfs/Makefile >>>> @@ -3,3 +3,4 @@ pollfs-y := file.o >>>> >>>> pollfs-$(CONFIG_POLLFS_SIGNAL) += signal.o >>>> pollfs-$(CONFIG_POLLFS_TIMER) += timer.o >>>> +pollfs-$(CONFIG_POLLFS_FUTEX) += futex.o >>>> Index: linux-2.6/fs/pollfs/futex.c >>>> =================================================================== >>>> --- /dev/null >>>> +++ linux-2.6/fs/pollfs/futex.c >>>> @@ -0,0 +1,154 @@ >>>> +/* >>>> + * pollable futex >>>> + * >>>> + * Copyright (C) 2007 Davi E. M. Arnaut >>>> + * >>>> + * Licensed under the GNU GPL. See the file COPYING for details. >>>> + */ >>>> + >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> +#include >>>> + >>>> +struct futex_event { >>>> + union { >>>> + void __user *addr; >>>> + u64 padding; >>>> + }; >>>> + int val; >>>> +}; >>> Hum... Here we might have a problem with 64 bit futexes, or private futexes >>> >>> So I believe this interface is not well defined and not expandable: in case of >>> future additions to futexes, an old application compiled with an old pollable >>> futex_event type might fail. >>> >> Hmm, how about: >> >> struct futex_event { >> union { >> void __user *addr; >> u64 padding; >> }; >> union { >> int val; >> s64 val64; >> }; >> /* whatever room is necessary for future improvements */ >> }; >> >> I haven't been keeping up with 64 bit or private futexes. What else >> could probably go wrong? > > Well, that's the point : This interface is like an ioctl() one : pretty bad if > not properly designed :) > > You probably need to stick one field containing one command or version number, > something like that. > > > struct futex_event { > int type; > union { > void __user *addr; > u64 padding; > }; > union { > int val; > s64 val64; > }; > }; > > #define FUTEX_EVENT_SHARED32 1 > #define FUTEX_EVENT_SHARED64 2 > #define FUTEX_EVENT_PRIVATE32 (128|1) > #define FUTEX_EVENT_PRIVATE64 (128|2) > I'm changing the structure to: struct futex_event { union { void __user *addr; u64 addr64; }; union { int val; s64 val64; }; union { s32 flags; s64 flags64; }; }; Plenty room for future FUTEX_WAIT growth ? -- Davi Arnaut