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 0E8CCC43140 for ; Fri, 6 Sep 2019 15:53:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9150214DE 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=139ahp/hYUsWUtDhY283CFaNw1CA1iklDxVFPl958wPjtzZnfoTqkq0fA99SNCx7j oHvmmRxWJF/CDC7s1cMel67t4G/QR0GiOpzayz4P797kEyjBaGbwRiONvGgMP0mE7X GGfGuO6AwjYMybOQS4ZcLyLMVBAHWMY4JgdxP3gU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391862AbfIFPxb (ORCPT ); Fri, 6 Sep 2019 11:53:31 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35299 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732580AbfIFPxa (ORCPT ); Fri, 6 Sep 2019 11:53:30 -0400 Received: by mail-lf1-f67.google.com with SMTP id w6so5487269lfl.2 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=SPGlXf8sSoV6goYdcqGdn68PRLaxyunNmUJ2BCjJTnMYvXFZV2rc2Fjo66Z5sPpdNH nSmorTA1BmDJp5n/RWbrGRz/T0sB9oRGAHOHkFgWs2iJLw3germaheMbT3BKjtZrPct4 i6CS1ff+IBgqhLZchtq9pkY2GHrycL2YNbFh/9xyFf+03uRNTvh9EWXuKmpim+RNiNKt pX3cXuJSbLrS+YcC7/kPU7kJOsF/QsfEaUozjcbVuGKhd2q1o7kkS77J4JY8U0y84tdv dJcUYTepv1KhvswcJtMVdYYk8hOU66ObESzxXF9cxOVytMPIJ2h0fJOgl+T+krAkJ8Cd J9cQ== X-Gm-Message-State: APjAAAWznPg/LQjOKioLwhFnQU/gIYvijunfla/zTacZZsj6jfTjOav3 IWC1U+tQwZ/hgJvsDwThFXT3gZwDkKY= X-Google-Smtp-Source: APXvYqwPYOjUy1JW1/O4w+sGXjbb4H6JYtJQ6rEUTGlHbRTsQmM5HB9t6QO09n97yUmRozXbT7mcHA== X-Received: by 2002:a19:c3d3:: with SMTP id t202mr7098633lff.48.1567785207813; Fri, 06 Sep 2019 08:53:27 -0700 (PDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id l15sm1207642lfh.48.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-f172.google.com with SMTP id l1so6428234lji.12 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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