Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8690356rwp; Wed, 19 Jul 2023 13:51:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlF53gUPM9kkCYxAATHyek+iDC6obDw4XTGMlgOIwqK1MX35PjRWBByr/bwKZfl6fjzX5efG X-Received: by 2002:a17:902:a606:b0:1bb:32de:95c5 with SMTP id u6-20020a170902a60600b001bb32de95c5mr7130942plq.65.1689799916765; Wed, 19 Jul 2023 13:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689799916; cv=none; d=google.com; s=arc-20160816; b=M4mUbeXDqU2ibFH0ca6PKtYqgOebYcpRXVtpib6dqZNucU0492m0aCc+FG7A2GeLw8 O966gU4PAQlEtcwJq6RXyS0sl3bR/rfGQ0bLnJIsWqFJ5eXMNuqDpa0q7w6sIxRLaR6N OxhWX1KrKCH2uuaSgPFvf9+k5NXk2EvOV1Eqmg+LaHNIYiRzEo1pPOVxDYiGsbWEUjTk JygyAHZWcuLwkHC2m24ShiiS5FTPdjixMs8Hvs0wjKI+0sMXVV7955SSuolG2e/ESw8J m9Td5Ww2TuYAZg1CYFZaXdBGcoZRDUXZb3IcVLPxJdfD7zbMEL5XjU/e9InLzKgCH6nY HjDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ReDr3/cUrrY5O6f157kS0Oes02zkOeh4YD/h5uR7Jps=; fh=Q2dgYJ4A1TeJhJYnNQ+8Ip1V9W8qy6Reb0N6RjBBNZQ=; b=XQi7PL/QKmH8+Sr1YN+96LPCu0SYKZ1teJC9Xg0L66PPfo0N6HDBviPiHoLCOyJlML +R2jQ39HwSMIMrzUKHFmyP66fQ40bXOFxjMB+WNHFSZFerW5N6CGSOYbPWwhVDytIN3T jfkskyJ/xC0g7GqcGaH1Wao8RNdlGAjaJUXtWFbqibZPpLeaX0UrOWVUOUbyQYoIMnV3 1K5zEzKBcmgxuJAJ2JiC8FkFW6U0ugrmff0Al5nsNLNktGaElVgwVa3wTal8IXQiHnef RAcy4bybJTRlSVWQxSLPxGKdJP3oZCeedeHxcIei2ZMAj/eyXiUhy3OaC7YyXZw2nYny nxmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=coi65PEz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix22-20020a170902f81600b001b8e443b6ffsi3868828plb.7.2023.07.19.13.51.45; Wed, 19 Jul 2023 13:51:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=coi65PEz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230173AbjGSUQd (ORCPT + 99 others); Wed, 19 Jul 2023 16:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbjGSUQb (ORCPT ); Wed, 19 Jul 2023 16:16:31 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF1441FEC for ; Wed, 19 Jul 2023 13:16:27 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2b74fa5e7d7so77571fa.2 for ; Wed, 19 Jul 2023 13:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1689797786; x=1692389786; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ReDr3/cUrrY5O6f157kS0Oes02zkOeh4YD/h5uR7Jps=; b=coi65PEzCV7rCDEfL1mpkcR6k+K28LAsBIXeiZTCZLjyw2Hy4j+ku4FXsXBZCMuun9 P4YFf7zHA3iWFEyAOCYUleRCXXLr6ChxfuWsEDVI8+N1e2T11Lo54fctsXWy4wHwot4X ek09n/z1vP6HGncPkGB8YnuM4OcDKlXEa7zZM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689797786; x=1692389786; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ReDr3/cUrrY5O6f157kS0Oes02zkOeh4YD/h5uR7Jps=; b=QGVVtVaY4VN2uyDr4gN8Khj03DbxZG0MBSW9nUCf7cDgAf7EVAEhTMfRLZMXu1I+Ro DOQ22/5zE9wbxr9+Xh+2cDzbdVKF0d+vZVIh98mcoT0Qi35aoCvx4cyQWIqVCPID3Fx8 oohrDNctyR5ND2PTnivz83dDrJESM7t8Kd0WWdQbshFHQivZ7pJ9wXslQZ6uLXAvUcdy Uzp/h2jFO74Iyp9mHmNS8G0fOGxW4yYk1OphoNoPId9gK0EQ/CzLSglLf6YbLxJEL9Xd CYQcekNeB9FNH+rRpgq2yDcci6iZlDgeE2BJSsaAR0VDeZOR+DYizIHia3HpGpdy119p OIvw== X-Gm-Message-State: ABy/qLYH4H2dE+IOebzI16/izlpbXGw5jiRVf80nkYTZnI7JI+qNSMoo bmSdCJJbODw7o2dN7/J6QIvGkygGu6UVIXkP+adKIM74 X-Received: by 2002:a2e:908b:0:b0:2b6:dd9a:e1d3 with SMTP id l11-20020a2e908b000000b002b6dd9ae1d3mr705601ljg.44.1689797786041; Wed, 19 Jul 2023 13:16:26 -0700 (PDT) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com. [209.85.208.179]) by smtp.gmail.com with ESMTPSA id c3-20020a2e9483000000b002b6cb40e9aasm1162151ljh.103.2023.07.19.13.16.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Jul 2023 13:16:25 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2b734aea34aso387471fa.0 for ; Wed, 19 Jul 2023 13:16:25 -0700 (PDT) X-Received: by 2002:a05:6512:368c:b0:4fb:85ad:b6e2 with SMTP id d12-20020a056512368c00b004fb85adb6e2mr613569lfs.50.1689797784754; Wed, 19 Jul 2023 13:16:24 -0700 (PDT) MIME-Version: 1.0 References: <20230629155433.4170837-1-dhowells@redhat.com> <20230629155433.4170837-2-dhowells@redhat.com> In-Reply-To: From: Linus Torvalds Date: Wed, 19 Jul 2023 13:16:07 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/4] splice: Fix corruption of spliced data after splice() returns To: Matthew Wilcox Cc: Miklos Szeredi , Matt Whitlock , David Howells , netdev@vger.kernel.org, Dave Chinner , Jens Axboe , linux-fsdevel@kvack.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Hellwig , linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 19 Jul 2023 at 12:44, Matthew Wilcox wrote: > > So what's the API that provides the semantics of _copying_? It's called "read()" and "write()". Seriously. The *ONLY* reason for splice() existing is for zero-copy. If you don't want zero-copy (aka "copy by reference"), don't use splice. Stop arguing against it. If you don't want zero-copy, you use read() and write(). It really is that simple. And no, we don't start some kind of crazy "versioned zero-copy with COW". That's a fundamental mistake. It's a mistake that has been done - several times - and made perhaps most famous by Hurd, that made that a big thing. And yes, this has been documented *forever*. It may not have been documented on the first line, because IT WAS SO OBVIOUS. The whole reason splice() is fast is because it avoids the actual copy, and does a copy-by-reference. That's still a copy. But a copy-by-reference is a special thing. If you don't know what copy-by-reference is, or don't want it, don't use splice(). I don't know how many different ways I can say the same thing. IF YOU DON'T WANT ZERO-COPY, DON'T USE SPLICE. IF YOU DON'T UNDERSTAND THE DIFFERENCE BETWEEN COPY-BY-VALUE AND COPY-BY-REFERENCE, DON'T USE SPLICE. IF YOU DON'T UNDERSTAND THE *POINT* OF SPLICE, DON'T USE SPLICE. It's kind of a bit like pointers in C: if you don't understand pointers but use them anyway, you're going to have a hard time. That's not the fault of the pointers. Pointers are very very powerful. But if you are used to languages that only do copy-by-value, you are going to think they are bad things. Linus