Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp356591ybi; Fri, 31 May 2019 02:35:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeY0Rz/8mmVklIR6UoKvrO3Cs+AgklFlF3rrT1aFr4UtXawwyASrSkuwisPtfS7CnQHO1r X-Received: by 2002:a17:90a:e0f:: with SMTP id v15mr7722076pje.140.1559295332730; Fri, 31 May 2019 02:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559295332; cv=none; d=google.com; s=arc-20160816; b=fxcAUW7/jG4X7iIc9xvz4dd0+p/FaDuxa4Si2Tx5REm0NpgEy36O1FBgelKLZhPyNL tO/txkWU5XAf+VI9KhNoevkoIJRCKfK6R3K1K1nr1py2Z5aO4FD2kcFWYV8fH+Km/zQl zDJdRcZ9YvOLmesmYq3ReVPzX3nzMxUwxvCLgPTBm03gpAUsiNZy8EXfbPlmz13lH/eD 9jZxotXLTu3kBo3MR/WG0U9Owh+Sm9gxEpWWa5Jg5ozd6MJMl/TJCIxyIia7/qAqczSD O0IOaqzePpZPP6qn40Yu5okiJHuaDK9zjvQxI4Owe+85868M89Y+J1CbIyYbYNUUBZ8j Z4Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version; bh=sOI7lUseb37wdJAnRkFixDJ/Fd5yhVfMo0AyFlkWHno=; b=fzsvd4g2PjpIMv50U8Fzmun8PHgCo3K1GTF6Fy+iTIIh4shS0/u6rorub1BzIvev9e iKT648jJsRiC1+Z0outFBe+p+vI1vMYaCYAUTdGsKsJ0gDupXgTL2HRqBU+17usYn1RX I9GR9oaC/zDWD6FJScOhrIoEmLAGs7wYvLX+ve/OJWacP4BdWyNZhBHgo48dPLZvUvbp WGqyYFrsacCwQk/2iwImNmg3UjelfU1tY42yBuLoYrNT4JLPddmuhRPMI1i4C4uEfpyB xlNeyTlHa69FVRtdwHRDlGnnime058ZQI7IrNzmL7TXm21pXUQanqcaWFTgMM2wc3053 isfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b22si5269551plz.417.2019.05.31.02.35.16; Fri, 31 May 2019 02:35:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726668AbfEaJeL (ORCPT + 99 others); Fri, 31 May 2019 05:34:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:34428 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726233AbfEaJeK (ORCPT ); Fri, 31 May 2019 05:34:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 21D74AE5A; Fri, 31 May 2019 09:34:09 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 31 May 2019 11:34:08 +0200 From: Roman Penyaev To: Renzo Davoli Cc: Greg KH , Alexander Viro , Davide Libenzi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel-owner@vger.kernel.org Subject: Re: [PATCH 1/1] eventfd new tag EFD_VPOLL: generate epoll events In-Reply-To: <20190527133621.GC26073@cs.unibo.it> References: <20190526142521.GA21842@cs.unibo.it> <20190527073332.GA13782@kroah.com> <20190527133621.GC26073@cs.unibo.it> Message-ID: <480f1bda66b67f740f5da89189bbfca3@suse.de> X-Sender: rpenyaev@suse.de User-Agent: Roundcube Webmail Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Renzo, On 2019-05-27 15:36, Renzo Davoli wrote: > On Mon, May 27, 2019 at 09:33:32AM +0200, Greg KH wrote: >> On Sun, May 26, 2019 at 04:25:21PM +0200, Renzo Davoli wrote: >> > This patch implements an extension of eventfd to define file descriptors >> > whose I/O events can be generated at user level. These file descriptors >> > trigger notifications for [p]select/[p]poll/epoll. >> > >> > This feature is useful for user-level implementations of network stacks >> > or virtual device drivers as libraries. >> >> How can this be used to create a "virtual device driver"? Do you have >> any examples of this new interface being used anywhere? > > Networking programs use system calls implementing the Berkeley sockets > API: > socket, accept, connect, listen, recv*, send* etc. Programs dealing > with a > device use system calls like open, read, write, ioctl etc. > > When somebody wants to write a library able to behave like a network > stack (say > lwipv6, picotcp) or a device, they can implement functions like > my_socket, > my_accept, my_open or my_ioctl, as drop-in replacement of their system > call counterpart. (It is also possible to use dynamic library magic to > rename/divert the system call requests to use their 'virtual' > implementation provided by the library: socket maps to my_socket, recv > to my_recv etc). > > In this way portability and compatibility is easier, using a well known > API > instead of inventing new ones. > > Unfortunately this approach cannot be applied to > poll/select/ppoll/pselect/epoll. If you have to override other systemcalls, what is the problem to override poll family? It will add, let's say, 50 extra code lines complexity to your userspace code. All you need is to be woken up by *any* event and check one mask variable, in order to understand what you need to do: read or write, basically exactly what you do in your eventfd modification, but only in userspace. >> Why can it not be less than 64? > This is the imeplementation of 'write'. The 64 bits include the > 'command' > EFD_VPOLL_ADDEVENTS, EFD_VPOLL_DELEVENTS or EFD_VPOLL_MODEVENTS (in the > most > significant 32 bits) and the set of events (in the lowest 32 bits). Do you really need add/del/mod semantics? Userspace still has to keep mask somewhere, so you can have one simple command, which does: ctx->count = events; in kernel, so no masks and this games with bits are needed. That will simplify API. -- Roman