From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B14BDC636D4 for ; Fri, 10 Feb 2023 20:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233733AbjBJUvo (ORCPT ); Fri, 10 Feb 2023 15:51:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233857AbjBJUvm (ORCPT ); Fri, 10 Feb 2023 15:51:42 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7BE77F82F for ; Fri, 10 Feb 2023 12:51:40 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id u21so5884084edv.3 for ; Fri, 10 Feb 2023 12:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=s2Azvxdn84xto/x8V66pxCf76GAuLOkrFIRsWg8lS4s=; b=CExvujm0mDZb5b8Q0YyIk4qMEt2KO+XrVyPAus7CXHhyvaiDKton8DMFVNJsqauRlU nI1nneBrMPjQD5z0K9+CdqJYNcj8cP+aS9E0t7rQMDVkDPH9lCTi56TrRMFd1OP/EM6c 8oYMudVstq0I+TSzaRmEBx/yV05z10/f7jbHs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=s2Azvxdn84xto/x8V66pxCf76GAuLOkrFIRsWg8lS4s=; b=O7rjpqzPF0xA10UPACSt/sH2+hIJ69WpNqymgkrh7FpYXk2abEAN7mHce0rbejnJnd rZN7sxjLN329iJCsjnjv113/Yx5VWDH4ehaHNsRywkAbm0GKZ8SpNmxZDdjukgxIyv4X QFkgM0aH+pLkcbgVIfzImJCXCbzGV89qjw/v09Sl+wWuraOMeT0cFEV7pR5lsc0D5G7F zh7gTEQgIFVX7q3zJM9qO5WFqz1CK+NEv/CCXvegE8NpmYivNRBrTMnCHQosBgpsynFP nVtgKJEO5L4bHy649XxWO0dKbdoFezRAy/eJd2KDpUakxhXRm+hjmhUdHI9fQly8J+RE F3qA== X-Gm-Message-State: AO0yUKUorBahg7bqXYSOcP/uJwS0y//sZW9NrdnhG/N3WI9Qx2tylUQZ Dlt4FejhsnjIsJ/VVfGjP1zPuWV/pG15iMWh85Y= X-Google-Smtp-Source: AK7set+8M8Ua3At2hmxPYkaK2Ef9yDnFF28QdyGVozucAXvzroHwHa+yOBcaEAoTrtsD+J0rt9ngbg== X-Received: by 2002:a50:8d15:0:b0:4aa:b406:4b83 with SMTP id s21-20020a508d15000000b004aab4064b83mr18353781eds.23.1676062299005; Fri, 10 Feb 2023 12:51:39 -0800 (PST) Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com. [209.85.218.52]) by smtp.gmail.com with ESMTPSA id t18-20020a50c252000000b0049148f6461dsm2735389edf.65.2023.02.10.12.51.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Feb 2023 12:51:38 -0800 (PST) Received: by mail-ej1-f52.google.com with SMTP id qb15so16882146ejc.1 for ; Fri, 10 Feb 2023 12:51:38 -0800 (PST) X-Received: by 2002:a17:906:d217:b0:877:747e:f076 with SMTP id w23-20020a170906d21700b00877747ef076mr1548367ejz.0.1676062298057; Fri, 10 Feb 2023 12:51:38 -0800 (PST) MIME-Version: 1.0 References: <0cfd9f02-dea7-90e2-e932-c8129b6013c7@samba.org> <6858a9bd-a8aa-3eaa-979d-83e1743ce85e@samba.org> In-Reply-To: <6858a9bd-a8aa-3eaa-979d-83e1743ce85e@samba.org> From: Linus Torvalds Date: Fri, 10 Feb 2023 12:51:21 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: copy on write for splice() from file to pipe? To: Stefan Metzmacher Cc: David Howells , Jens Axboe , Linux API Mailing List , Samba Technical , "linux-kernel@vger.kernel.org" , Al Viro , linux-fsdevel , io-uring , linux-crypto@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On Fri, Feb 10, 2023 at 12:45 PM Stefan Metzmacher wrote: > > I guess it would be easy to pass a flag (maybe SPLICE_F_FORCE_COPY) > down to generic_file_splice_read() and let it create dedicated pages > and use memcpy() from the page cache to the dedicated pages. I really think you'd be much better off passing it off to the *destination*, not the source. The destination knows whether it needs to copy or not, and in the case of at least networking, already has the copy option. The destination might also already know whether it can use the data synchronously, so that there isn't even any issue with "data may change later". In contrast, the source has no clue. It just knows "I'm a page cache page". It would have to always copy. Linus