Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1959440ybe; Sat, 7 Sep 2019 06:18:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsRzW0Dbuu4L3Nyppc4bZc5PAd5Ltd7kf3jMTJ7S7wYVedR48O5+MFhenzwzlsHyH31X7z X-Received: by 2002:a17:90a:a489:: with SMTP id z9mr14684147pjp.24.1567862294975; Sat, 07 Sep 2019 06:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567862294; cv=none; d=google.com; s=arc-20160816; b=jQMfspeXIQLjQYH4A64dJk20CiZqIHKWFH6nyF6G6IXz+mX8JP2CCw/Un1bTWnWIaX KbCKK0DkIZMiJ7eV5qw1xhTRdcTFYTf9pD1bQb5Ug630zFuYgUoKN1i5+Jt1tKPftSCk 29Cb7k1r5z9d/cggPVeVDePZ2/mJlqSkp4vEVs6Dx6m+R/rzioJVol0cIphmseSDxoTB K+YG6SKXlH6lCtIHRVMWlX8UgsW1kpqIoSqGVsCJVH7cg+VfDWcgDy2SuIJsVUZDS1FE UjFmIndaskIx6WBFoqLixRj3mJ/RsFRUDzYMSdlPTiHlvh69e9KjMWYF7PhS6w/dqTyz 5liA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=hOgSaQ9OiZSGTbwU3Edr701ZO2qKZIOjSVp4gAjrJTU=; b=L0fZI9yFVwiH2LWepqkZY1ICveMTFA7Wg6fRFkB2SQBQyD+IB3BUZigsypg0WUNnN8 S/Czy5nb/Ji3/qX8mEneByqKVkDpKKF1SlHCOXHqM4tC74Aq6zgt9I3LPJi8uAEFawFw 3KROTTE934xlaWBIl9dUTJWHL7HKPkTLk7KGlhrAru+np0Q4wUgd8NjPh4oOr/lh3xOH S8/0oI1RbDcAt5hbx+v7Q+O+C0OTvD9IFPZIvSCJdcTdg6RM4+QunwCHdMz0lcbgoV2y C4l9ZZAV0JX1Z82gZDcI8/K2v29z3UXXMhasL2sJGmvLS9bo6OlHA8p/lv38XbGe6onO JImg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=yd2a+54P; 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 n26si7041767pgv.192.2019.09.07.06.17.57; Sat, 07 Sep 2019 06:18:14 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=yd2a+54P; 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 S2395165AbfIFROU (ORCPT + 99 others); Fri, 6 Sep 2019 13:14:20 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40071 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395164AbfIFROT (ORCPT ); Fri, 6 Sep 2019 13:14:19 -0400 Received: by mail-pg1-f196.google.com with SMTP id w10so3841912pgj.7 for ; Fri, 06 Sep 2019 10:14:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hOgSaQ9OiZSGTbwU3Edr701ZO2qKZIOjSVp4gAjrJTU=; b=yd2a+54PEaXqiHA9W/77hkPN2VhfSOlLkSERJRJ/Bh1zlws9GocZGNGdm3pxHNPP2k apcVkjkZdq9vP5K898Y0K0fp9Msz4ZIqXGLi1k3bvPTRUs1UDb+7WxEM6JDLxMiQC9Wu hspuXC71/2nCgTYC+nFZhbQMqN+6eyywKJmqPax8RWIZzApVcyFl5TPK/9Tjjmez1ZGz l0D7JZ/pzEMsGILSnd+o1gvbgawAXhr39KQszkwTSRT6FrgwFODq1N4F8fWIgP3aj4VH YyfGqiifL7/wZTGB2yK1JGhsxMeKoGttY75RNEmXrHy9j6PIB31lmiA0uGmL+SbUOsUT Xwwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hOgSaQ9OiZSGTbwU3Edr701ZO2qKZIOjSVp4gAjrJTU=; b=IiFQnGOWqrus/2TVFf7sZzl6ty6tCLFkRi9q5fNNVa4xycz5q0TYnuvNrqC4AjDEA4 mmDqhCKV+NL/IXH5pACYE97aGeLIxoRnbvFIwkdtTK5Gom/K6xVT640mo4N9HXmk77QY 1JiEKgRoSh6dbp8LTivnKtLnG2k2aiIn/lVeZREP/qFDgEVJ08s7umn9GJ9tbjf2pnrV 47z3X8GRLXgh1NTGKl8p1q17ZII4rBQcIDY4rjdyNZfm4dhGn4A7SXWo09zmO+D7IbOq 7/3Skccjz9QnKWQhd0RqkQyKoQTXP5OiSk7HO8+Ue/ENiPveHuSXP5upJK+Eh4efdovp UXeg== X-Gm-Message-State: APjAAAVookyP1IDR6jKlvmMpI3mdiRVmrHNzQ91vXR9OxWRy+ileuvOa d6PWK9bPSKVXnX24Fvy4kglikQ== X-Received: by 2002:a63:7e17:: with SMTP id z23mr8935117pgc.14.1567790058681; Fri, 06 Sep 2019 10:14:18 -0700 (PDT) Received: from ?IPv6:2600:100f:b121:da37:bc66:d4de:83c7:e0cd? ([2600:100f:b121:da37:bc66:d4de:83c7:e0cd]) by smtp.gmail.com with ESMTPSA id l11sm4930140pgq.58.2019.09.06.10.14.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2019 10:14:17 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: Why add the general notification queue and its sources From: Andy Lutomirski X-Mailer: iPhone Mail (16G102) In-Reply-To: <8e60555e-9247-e03f-e8b4-1d31f70f1221@redhat.com> Date: Fri, 6 Sep 2019 10:14:17 -0700 Cc: Linus Torvalds , David Howells , Ray Strode , Greg Kroah-Hartman , 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-Transfer-Encoding: quoted-printable Message-Id: <930B6F39-4174-46C2-B556-E98ED72E27F8@amacapital.net> 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> <8e60555e-9247-e03f-e8b4-1d31f70f1221@redhat.com> To: Steven Whitehouse Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Sep 6, 2019, at 9:12 AM, Steven Whitehouse wrote:= >=20 > Hi, >=20 >> On 06/09/2019 16:53, Linus Torvalds wrote: >> 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 parse= able. >>=20 >> 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. >>=20 >> 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. >>=20 >> This overly stupid program shows off the feature: >>=20 >> #define _GNU_SOURCE >> #include >> #include >>=20 >> int main(int argc, char **argv) >> { >> int fd[2]; >> char buf[10]; >>=20 >> 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; >> } >>=20 >> and it you strace it (because I was too lazy to add error handling or >> printing of results), you'll see >>=20 >> write(4, "hello", 5) =3D 5 >> write(4, "hi", 2) =3D 2 >> read(3, "hello", 10) =3D 5 >> read(3, "hi", 10) =3D 2 >>=20 >> note how you got packets of data on the reader side, instead of >> getting the traditional "just buffer it as a stream". >>=20 >> 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. >>=20 >> (Side note: a zero-sized write will not cause a zero-sized packet. It >> will just be dropped). >>=20 >> Linus >=20 > The events are generally not independent - we would need ordering either i= mplicit in the protocol or explicit in the messages. We also need to know in= case messages are dropped too - doesn't need to be anything fancy, just som= e idea that since we last did a read, there are messages that got lost, most= likely due to buffer overrun. This could be a bit fancier: if the pipe recorded the bitwise or of the firs= t few bytes of dropped message, then the messages could set a bit in the hea= der indicating the type, and readers could then learn which *types* of messa= ges were dropped. Or they could just use multiple pipes. If this whole mechanism catches on, I wonder if implementing recvmmsg() on p= ipes would be worthwhile.=