Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1761718ybe; Sat, 7 Sep 2019 02:21:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTOBP+8tfN/PhyAAGjRWhU8WHe7NgoShcCAcuxr1LI1WNzv/PE69rHaMf+bApNIIkkJPKh X-Received: by 2002:a63:ff03:: with SMTP id k3mr11978152pgi.40.1567848099611; Sat, 07 Sep 2019 02:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567848099; cv=none; d=google.com; s=arc-20160816; b=knlMqRvPHCr9lBQt/tMOjhWBq0B4nw8oEaZXyxDKVLnpMNdfP7LaNyw0B10JUR3rCd UyMm9DSATPPq3tCAU/dTJWpllgCWYb7KIRldJx1LSIHRhjtqLj1Sw3JFS/636NsD2uQZ l68Dh2f3IKgwI7fJWIT99lXKebuJeCbc20YbMossj9s8naRLBBVjBvXdvkaxgJ6I312K D0pPuQaw/+BdFMMCTlZnLPXhFUCArvgnp2KQff3XVw9BWLHNwXQiwZrzLH1QLFOVboPm H41KPUqC5951x7rzjSceyDtK1oZk0/LSxf2drak/tiI9Wh2qaPE/DvlINd4xTwE8jGHZ 55EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SLIGvVtM1MWun0WWtqWDQtU9G8VMp6qsOxjP6sOjf2I=; b=p2KpMfRZGdKLVs6UdH2HfQQDtIOXJNpNIb5kxMjC0ceZGlefGWtqBj+tiaV5RiSgSM BcVA82yKILauHTsSGRFl7XPDUEEI0OVPsh8qtI/uJ53PXvbWZSrff7eUjG2ej81U1Doi wNpfQV09RBQ+AaSVmZz+m+2uaPyYV09BcEhQJsiuxRuNFpFCQ0gvqTUwDhyrT69hN/5r Az0e1Y8Y3TNDFNI6KFPcdJHGbHRWTvM4e54917ZPWIMyiiuxGm6dUluJN2k+ITUiiRWW 34MHj1xXgS4Od/jenx0nn2g5xfWuCakPLfixK8/s+FvxGRRXr70Qorrv2C1VG/T5bMz9 ytyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Ia8xZ4G7; 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 z18si8727811pfk.120.2019.09.07.02.21.21; Sat, 07 Sep 2019 02:21:39 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Ia8xZ4G7; 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 S2394981AbfIFP6c (ORCPT + 99 others); Fri, 6 Sep 2019 11:58:32 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:37879 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388180AbfIFP6c (ORCPT ); Fri, 6 Sep 2019 11:58:32 -0400 Received: by mail-lj1-f196.google.com with SMTP id t14so6483664lji.4 for ; Fri, 06 Sep 2019 08:58:31 -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=IkjkztPVfWAIVoRoJbwCv5nA9jg0QRvAcEArgUGmZrjqCoAQsRunsTbopTAkVCmPxE s/2zrA04aSodAF6QV4kzhAD7J+Pvz7OGX1r7LhjvtSH4jvBT1ld8qrocbYVhi2z1iLq1 mPfyayExZ5rCUS39dnWFxKnaNgQDjh6Xc9xHD7hLp4I0eXKvPHqYxFJjQ4x8o2eaV1HL 66G82BwhN4/Tmp0Ved7T42uVzYdcSVMAj1YepP4WaCzfAohvxeozNGwlQF8Nl8KsHrXU YJ4IsiLgy5yreN41SPUdzanpBbrl1HNYq7+wr8zHyvv1jJq/uJyBikowgmftHkQNGtP5 +yiA== X-Gm-Message-State: APjAAAVYYxPlwXjM8QEjELrZjw63uHibTgWoR/TQucU6AfOnAuQrEHEH dSvVSEAGD0qvTa0YNY9l3T4YG2qT6XE= X-Received: by 2002:a2e:85c1:: with SMTP id h1mr6074929ljj.174.1567785510252; Fri, 06 Sep 2019 08:58:30 -0700 (PDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id a20sm1212153lff.78.2019.09.06.08.58.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Sep 2019 08:58:30 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id l1so6442621lji.12 for ; Fri, 06 Sep 2019 08:58:29 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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