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 1CC25C05027 for ; Fri, 10 Feb 2023 20:51:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233884AbjBJUvr (ORCPT ); Fri, 10 Feb 2023 15:51:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233874AbjBJUvn (ORCPT ); Fri, 10 Feb 2023 15:51:43 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 748DC7F830 for ; Fri, 10 Feb 2023 12:51:41 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id r3so5796438edq.13 for ; Fri, 10 Feb 2023 12:51:41 -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=IO/lO40UmXaJXigQE/YoJ5QCoHRXBZDWac5/JE0FDOBQtXGaXb4OnNWPSq745U4WIy g9+h1niF1VBSNuSiRe0xyDrh5mG1RQHeReX/kPVDtmN5FGsXZ1zqb3dKj52AjRbztG0g NgP4us45x8pSIrEbTGoR0KpaiTFNKptm2jGmGK0qUXMVfgyPU38AsufnDSPkytf85bPI XMm7vyXvxLEk1HRCTPIBT+YalWkKAef+0AFrumWPJ+nN/LyHaXK2MjNKqs1uXb1iRLEL QSlpk0CfzvuMtbrNp3ya9pOXtOgmhXzN0UJDcyaLwEmdpeaYhAkjjZPtkWI6m83RxUo/ CZHQ== X-Gm-Message-State: AO0yUKUNxrdCIafWyoDQlVbOut3Q3wRSna6vD2xmQ1CIXTlCT0VzEe0T zB/xiRhwbKOSVOa3+TXT171LAjMcXpcvlhTqYcA= X-Google-Smtp-Source: AK7set/3uUVJXMNBZsd6mfklOaZGXHtZ3ps6GgipkKEfyX91jVNWh49U5s8VxaO8FfLR2bJfpks6wg== X-Received: by 2002:a50:a442:0:b0:4aa:9fc2:216 with SMTP id v2-20020a50a442000000b004aa9fc20216mr20542190edb.9.1676062299644; Fri, 10 Feb 2023 12:51:39 -0800 (PST) Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com. [209.85.218.54]) by smtp.gmail.com with ESMTPSA id l26-20020a50c11a000000b00499e5659988sm2736325edf.68.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-f54.google.com with SMTP id hx15so18897554ejc.11 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: linux-kernel@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