Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2792633ybx; Sun, 3 Nov 2019 04:05:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwtbFW0juyXyMQHmnfkGKuopTZYouQGu3ddmE1tTiQdmNS15peIuM2hZq1zfZh+Fi/ubRVy X-Received: by 2002:a05:6402:158d:: with SMTP id c13mr7286009edv.62.1572782743570; Sun, 03 Nov 2019 04:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572782743; cv=none; d=google.com; s=arc-20160816; b=ZU2ll8U5b2O6K/Ok2lMRGDGz3O9kdFKk75TZQHxjbwbDizhrqbbP/ZuCZTeGsnLQqL tX3i260KtptWMhvVjqe5Pl/ig8glSYfbaL4/jb+m1L8TKVDxYFBPo6SyPlY5A/P4LLTw hNRQf70KcusdJt5aF92f9IZJf8/Rn1wmuQVm1P25giHWKN6KuMjJ/ENKeZV+i2jS46ma mwClKWZ2ghVf0a62CZ418L6S70mwsgVn5JwUeKdGFLo0LqoKLbhb95wpMcXuTY1Wn27z NOUm6PmNq29TeGkryobwAp9RqK/4STd0dFrboFlEbzi8Sko1J248yUSgC/zHMNPmQ4jE 2F5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=22EDXIE7sdCqMg9/8WHEbWESicgc5h63XsjO5uxv1rM=; b=miUJohL+WXMsQOU0glgfSCNwH2dIETRUPUAfQ6l3RmAHNzZa21NuofNGIos9BbVGbI yvIJB/t0p8yWjPPnogkbKD8gL9TSkUgiHhGQe3wMwvKMIwIMUWA4ABViXdOOFHFRDJLL sq9t0Oo95A2ngItK3KRymO6lQlOnS0r34dlI+oth2DGdzOZAvyZCM5UD7xiP/KlOlSSp wpq+bZF8a7gbSuJMbxg9cvHXYYLgkzoeLQqMyk/v4MgHQQYlh2c1yhqGs284gnzRhWtY ngEHziT1zV+oa7uhPJK3qhxxOGggjtPe5Tb+/TrxFHV0U+lnr9vhyapKw0Jq4qleYO20 Bt+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=dSxNOPO6; 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=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oz10si3245167ejb.163.2019.11.03.04.05.06; Sun, 03 Nov 2019 04:05:43 -0800 (PST) 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=@yandex-team.ru header.s=default header.b=dSxNOPO6; 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=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727541AbfKCMCM (ORCPT + 99 others); Sun, 3 Nov 2019 07:02:12 -0500 Received: from forwardcorp1p.mail.yandex.net ([77.88.29.217]:57400 "EHLO forwardcorp1p.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726998AbfKCMCM (ORCPT ); Sun, 3 Nov 2019 07:02:12 -0500 Received: from mxbackcorp1j.mail.yandex.net (mxbackcorp1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::162]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 54FA82E12F1; Sun, 3 Nov 2019 15:02:07 +0300 (MSK) Received: from myt5-6212ef07a9ec.qloud-c.yandex.net (myt5-6212ef07a9ec.qloud-c.yandex.net [2a02:6b8:c12:3b2d:0:640:6212:ef07]) by mxbackcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id E9iTHkqXmn-25RCivqh; Sun, 03 Nov 2019 15:02:07 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1572782527; bh=22EDXIE7sdCqMg9/8WHEbWESicgc5h63XsjO5uxv1rM=; h=In-Reply-To:Message-ID:From:Date:References:To:Subject:Cc; b=dSxNOPO6KBTPwQVUMQsuoRYP2Rm4g+elu12lWUeOlbU6shBt2vVjk+8a9T+Ws1Crl 7M9I/RtuybtEgw/2CYq/3gOZp2rM6HlcFjEq+tAopJfR6tmmd46WeI5DCF7/o5oKNY gSw+yqWfMiXCpvTo7HcNlk9jNn8xHug4DNIN8o/8= Authentication-Results: mxbackcorp1j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from unknown (unknown [2a02:6b8:b080:7101::1:7]) by myt5-6212ef07a9ec.qloud-c.yandex.net (nwsmtp/Yandex) with ESMTPSA id 1UOEXN5iqJ-25VW2Fdc; Sun, 03 Nov 2019 15:02:05 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: Re: [RFC PATCH 11/10] pipe: Add fsync() support [ver #2] To: Andy Lutomirski , Linus Torvalds Cc: David Howells , 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 , Miklos Szeredi References: From: Konstantin Khlebnikov Message-ID: Date: Sun, 3 Nov 2019 15:02:05 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-CA Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/11/2019 02.14, Andy Lutomirski wrote: > 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. Looks monstrous. This will kill all fun and profit. =) I think vmsplice should at least deprecate and ignore SPLICE_F_GIFT. It almost never works - if page still mapped then page_count in generic_pipe_buf_steal() will be at least 2 (pte and pipe gup). But if user munmap vma between splicing and consuming (and page not stuck in lazy tlb and per-cpu vectors) then page from anon lru could be spliced into file. Ouch. And looks like fuse device still accepts SPLICE_F_MOVE. > > >> >> 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 >