Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2290353ybx; Sat, 2 Nov 2019 16:15:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/Iy8NWm9M6AU4JhTklQBc2yO+3RVLNdR1/pPy9LarGE0aC/48PVpQzZuZrlVQpFrx3PX4 X-Received: by 2002:a50:9930:: with SMTP id k45mr20944571edb.134.1572736551820; Sat, 02 Nov 2019 16:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572736551; cv=none; d=google.com; s=arc-20160816; b=kfloalWGibVwAysU3OgDQjofEYDj38Fh/O17M6KLC9Yv6wjUmLI2l7RGGGXvBoJOYa f0K3VO7nOsRuE3laXt2Wf4yluJNpDduumNidrUhZMDxzGQ8a9yeVydnFTNmizaUzhIL5 5JiY77g1Fi88RCZuSS/QIpqfuv8xq8ncCOiJpdtfFOqpfO9xtMmKPmj8GwA41cPoqOEY +C/DpEzvGL3g5qePwEX4z28sOeTe4FtQ+NnQEomqhGysDeHadiXw5RLtYFmiDf1ZLrYy kGDay21g9dItOL19kmSQpBrARJZ6WJ/555D50SOISTVzdP+7Dn+4e7F/+jtavjLhDq0K k5Rw== 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=fyi/TNyqgJKpfy6KSh/WD0RSAv5I/tF9gdB7tWeutnY=; b=Z6I5zVLR2/jNzVcgaWr0IGFEsosrh8ZrAEgLe97tb5jBxv6CeLiJI12sFuoqbRnTV8 jqjAZM9g0WclNuRLA/y8PTXsd+QgF0bDLNyNc466k6RTE3pIkHzkLpi4k2J3L6zMcv6k 0LKWxFHzI6+bhEmGl3mE+VNCDk08Ei0oHXCT7iCy3nmOIaEeAkfmMHuFcpgtUepsWPNa IMdwcygDjL1yblvT0JQ97nrMcMD5V34niu3lV7WFCN+DGDhMVOmkPLKZ0U7UVFOymodN 1tlOd8VdJl5D1M2zDCBpIk3fYrnQB0f3fIXKpc1WEUV1Cw8B+D04iVWoDgNpFPl53+Nz L7kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M+eT3FUF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si3872769edb.298.2019.11.02.16.15.28; Sat, 02 Nov 2019 16:15:51 -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=@kernel.org header.s=default header.b=M+eT3FUF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727364AbfKBXPA (ORCPT + 99 others); Sat, 2 Nov 2019 19:15:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:42864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727267AbfKBXO7 (ORCPT ); Sat, 2 Nov 2019 19:14:59 -0400 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 73ADE21855 for ; Sat, 2 Nov 2019 23:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572736498; bh=REB5//Mg+2UUv5NMyr1MVdv8ocwrgYZM1pxYX5vl4iA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=M+eT3FUF2jmJ2jN5PXXRGK/Qoi8ZaXjyPmPt7vGC/lPRcyHAo5BCeJPPl7GT3D2vH NREFz1CxaWKh03aYRPcbilVCC8pb01tix6xuZj4C6avNOQWC+IPC73Ws8tLGiGWf+O me6ANt3XpP/7rESPToHqJsbo7vFYVaL+XK229Yrk= Received: by mail-wr1-f47.google.com with SMTP id a15so13097412wrf.9 for ; Sat, 02 Nov 2019 16:14:58 -0700 (PDT) X-Gm-Message-State: APjAAAWQaBHTl+GR+52RamnWNB5R4Z89h/Ma6wYepWmeN6fg2eij2GTE co25FfzLV1V8MrPPtwdmpeM3oam0lWv8RkhunerXkw== X-Received: by 2002:adf:f7d1:: with SMTP id a17mr16289603wrq.111.1572736496889; Sat, 02 Nov 2019 16:14:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andy Lutomirski Date: Sat, 2 Nov 2019 16:14:45 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 11/10] pipe: Add fsync() support [ver #2] To: Linus Torvalds Cc: David Howells , Konstantin Khlebnikov , Rasmus Villemoes , Greg Kroah-Hartman , Peter Zijlstra , Nicolas Dichtel , raven@themaw.net, Christian Brauner , keyrings@vger.kernel.org, USB list , linux-block , LSM List , linux-fsdevel , Linux API , Linux Kernel Mailing List 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 Sat, Nov 2, 2019 at 4:10 PM Linus Torvalds wrote: > > On Sat, Nov 2, 2019 at 4:02 PM Linus Torvalds > wrote: > > > > But I don't think anybody actually _did_ any of that. But that's > > basically the argument for the three splice operations: > > write/vmsplice/splice(). Which one you use depends on the lifetime and > > the source of your data. write() is obviously for the copy case (the > > source data might not be stable), while splice() is for the "data from > > another source", and vmsplace() is "data is from stable data in my > > vm". > > Btw, it's really worth noting that "splice()" and friends are from a > more happy-go-lucky time when we were experimenting with new > interfaces, and in a day and age when people thought that interfaces > like "sendpage()" and zero-copy and playing games with the VM was a > great thing to do. I suppose a nicer interface might be: madvise(buf, len, MADV_STABILIZE); (MADV_STABILIZE is an imaginary operation that write protects the memory a la fork() but without the copying part.) vmsplice_safer(fd, ...); Where vmsplice_safer() is like vmsplice, except that it only works on write-protected pages. If you vmsplice_safer() some memory and then write to the memory, the pipe keeps the old copy. But this can all be done with memfd and splice, too, I think. > > It turns out that VM games are almost always more expensive than just > copying the data in the first place, but hey, people didn't know that, > and zero-copy was seen a big deal. > > The reality is that almost nobody uses splice and vmsplice at all, and > they have been a much bigger headache than they are worth. If I could > go back in time and not do them, I would. But there have been a few > very special uses that seem to actually like the interfaces. > > But it's entirely possible that we should kill vmsplice() (likely by > just implementing the semantics as "write()") because it's not common > enough to have the complexity. I think this is the right choice. FWIW, the openssl vmsplice() call looks dubious, but I suspect it's okay because it's vmsplicing to a netlink socket, and the kernel code on the other end won't read the data after it returns a response. --Andy