From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 841F5C43331 for ; Fri, 6 Sep 2019 15:53:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55BE1214DE for ; Fri, 6 Sep 2019 15:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567785211; bh=mpgGkKCrnRxhITt5MelQZFoxgsQdwiTo40PnPEOkVf8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=TcnQDuSFbpCteae+tyqKVShrVsFRpzRYMVhYCaQTZlU484CksF0bLjHnjeNaa5Fve Nj8CfHrKwUO4o5nakULdFIc4mEV3l7IFgfLv9fX6KGuc9rHlQ+WCArcfdWgWQd7MWt SeSwsVdGHvVpUzkxrcXty4de7MQ+SN6/SCOWNdfs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729626AbfIFPxa (ORCPT ); Fri, 6 Sep 2019 11:53:30 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42307 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387862AbfIFPxa (ORCPT ); Fri, 6 Sep 2019 11:53:30 -0400 Received: by mail-lf1-f65.google.com with SMTP id u13so5444012lfm.9 for ; Fri, 06 Sep 2019 08:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SLIGvVtM1MWun0WWtqWDQtU9G8VMp6qsOxjP6sOjf2I=; b=Ia8xZ4G7EXG0h3CEDdsSAnGPbD1nnF6pet2NWhAAqHOXPjQLBhaQh07F0TSGTC2pQA 4aORuaabR+7VQbbIPbEwZhlj4N84fOFkTe7F+AH5iR91RRW0/A+v490l9anWhBNdAZMu chcmmRDkVHmVtn5FD+klXo/q67grBESatc/HU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SLIGvVtM1MWun0WWtqWDQtU9G8VMp6qsOxjP6sOjf2I=; b=aGDQ1uaH0ouAsp/O94v5WLxOVwI3P4YUWr+oAxfNl2BHc/n8F1XOsBMesUEmxcSdSs 0h5TlqbqD2+PpXm+dT0/p7yHuVivolwzC9OAs5ncbXC1OzasipfniDRD49+iH1YQVL46 7j8nvLC+1sd6wFIcYjnRFi9yQNRtHqVI8w6ReIMFxmRHqDEYwBOjRmyzzUKEeZS4f877 lrbjBxufk3cNuoFhOdsGPRd8QAnKs0aBhh5exhxmnUHNmShL5BioPJThCRzMesr4VLan E0FjRGZt24Yb1i/q1ZTcX60w2+g5iAHFElKjwxJiCrucQrcYB1QM4rYVApwyBbFfujuz XbFA== X-Gm-Message-State: APjAAAU2+MmP0hLQk3ntkMuGqPgwL+zzdvRXrKKBHFm94/Qekc09+KAM UBOsy0nB0E9dwJ11SqBopS5iLhkHKPk= X-Google-Smtp-Source: APXvYqwcC4tAZUeFibW8dHA19LmAeGoaCRlTYEtnx+0mbndA4WEgfjUHPoiCNV6xO73IvOUFdEijMA== X-Received: by 2002:ac2:4847:: with SMTP id 7mr7138804lfy.186.1567785208321; Fri, 06 Sep 2019 08:53:28 -0700 (PDT) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com. [209.85.208.179]) by smtp.gmail.com with ESMTPSA id j5sm1191569lfm.29.2019.09.06.08.53.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Sep 2019 08:53:25 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id l20so6478498ljj.3 for ; Fri, 06 Sep 2019 08:53:25 -0700 (PDT) X-Received: by 2002:a2e:814d:: with SMTP id t13mr6334227ljg.72.1567785205260; Fri, 06 Sep 2019 08:53:25 -0700 (PDT) MIME-Version: 1.0 References: <156763534546.18676.3530557439501101639.stgit@warthog.procyon.org.uk> <17703.1567702907@warthog.procyon.org.uk> <5396.1567719164@warthog.procyon.org.uk> <14883.1567725508@warthog.procyon.org.uk> <27732.1567764557@warthog.procyon.org.uk> In-Reply-To: From: Linus Torvalds Date: Fri, 6 Sep 2019 08:53:09 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Why add the general notification queue and its sources To: David Howells Cc: Ray Strode , Greg Kroah-Hartman , Steven Whitehouse , Nicolas Dichtel , raven@themaw.net, keyrings@vger.kernel.org, linux-usb@vger.kernel.org, linux-block , Christian Brauner , LSM List , linux-fsdevel , Linux API , Linux List Kernel Mailing , Al Viro , "Ray, Debarshi" , Robbie Harwood Content-Type: text/plain; charset="UTF-8" Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Fri, Sep 6, 2019 at 8:35 AM Linus Torvalds wrote: > > This is why I like pipes. You can use them today. They are simple, and > extensible, and you don't need to come up with a new subsystem and > some untested ad-hoc thing that nobody has actually used. The only _real_ complexity is to make sure that events are reliably parseable. That's where you really want to use the Linux-only "packet pipe" thing, becasue otherwise you have to have size markers or other things to delineate events. But if you do that, then it really becomes trivial. And I checked, we made it available to user space, even if the original reason for that code was kernel-only autofs use: you just need to make the pipe be O_DIRECT. This overly stupid program shows off the feature: #define _GNU_SOURCE #include #include int main(int argc, char **argv) { int fd[2]; char buf[10]; pipe2(fd, O_DIRECT | O_NONBLOCK); write(fd[1], "hello", 5); write(fd[1], "hi", 2); read(fd[0], buf, sizeof(buf)); read(fd[0], buf, sizeof(buf)); return 0; } and it you strace it (because I was too lazy to add error handling or printing of results), you'll see write(4, "hello", 5) = 5 write(4, "hi", 2) = 2 read(3, "hello", 10) = 5 read(3, "hi", 10) = 2 note how you got packets of data on the reader side, instead of getting the traditional "just buffer it as a stream". So now you can even have multiple readers of the same event pipe, and packetization is obvious and trivial. Of course, I'm not sure why you'd want to have multiple readers, and you'd lose _ordering_, but if all events are independent, this _might_ be a useful thing in a threaded environment. Maybe. (Side note: a zero-sized write will not cause a zero-sized packet. It will just be dropped). Linus