Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4586300pxv; Tue, 27 Jul 2021 10:54:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7hPhr40NfoTVG6/b+a8zK4qckOjonwXI71SLCOZR4q95YXlThJSD3F5233YwV4kiNHMA4 X-Received: by 2002:a05:6e02:1d15:: with SMTP id i21mr17731475ila.307.1627408448792; Tue, 27 Jul 2021 10:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627408448; cv=none; d=google.com; s=arc-20160816; b=WnhHHDCxYG9WTRLZ9TIdkM9xBLrPjjqqCpJ83tqwZ98VwyJqF8zkjgeKfvBltO73zD p40Osxu6ACA3935GeU2t7bxIZX3PSQQ2AqUM/z3fqDgOL1hVRN8A7J7VbZyS8oAPDinf WazSiZhnjbLffTvwieatdz55/mVu2cJvfKDI3U0taLGL+5B1OmMPP4BgRHS1dauaC6UC jSD2Bbg0zXH4PdvoQdZJMYFVtEvvu6dmkOyTFt4fdfY0n0MbFp2X8ayJzfQmEU+BbeHn yQF2wy71fq3kg6X5qLl7qgXWIeaM4Ht1eBlbDr2f+ad0WI85lZnbWLG08bgUleFz0OhJ Jaig== 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=OBk5RRCD2iLIhOK5co1TZE5o+SAQV6EEDJtV9mSx3y4=; b=kG+PVqG9gKiBUaXoGot+/Q1DnUNZuzqgzes94jTHIHCSRFVyI3b61YkyKD00iUKTDc vna3wHIQH6VM3a9FyUw9EyUsuoyJXTtDqkV9HtXq9Y+r0uIQrB4WccT/xuxBlDUYDfcQ 3tlsyqX/Sy6eVT3WxHBAeUvnUKmn8tg9gKshR0u/R/uoxGFKtZ/BOBgfemGdSMiyBuKG QxcrZW0JbPMUDQOlTj7R0r2Y9lg11PGOKAOcXPOH0jZagBCd74XmxK3AaDpltjuoCB0h 1tehICi6paSgz1Y60LGc82SfRw7dFk9Bh+tIp/lgUCNlquZcl+6nrY+AtjiUijDqkKBf Nysw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=cHnY7pFf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b20si3915611jat.16.2021.07.27.10.53.57; Tue, 27 Jul 2021 10:54:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=cHnY7pFf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230237AbhG0RwB (ORCPT + 99 others); Tue, 27 Jul 2021 13:52:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbhG0Rv6 (ORCPT ); Tue, 27 Jul 2021 13:51:58 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED5AEC061760 for ; Tue, 27 Jul 2021 10:51:57 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id h2so23196274lfu.4 for ; Tue, 27 Jul 2021 10:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OBk5RRCD2iLIhOK5co1TZE5o+SAQV6EEDJtV9mSx3y4=; b=cHnY7pFfsAdkQyfJFNg5EaWUnAvGvmdR6YdJ+HmkdJ6abnT5bydaZvX2wtF+ok6nr4 7AGzXW9dGdx60YszoBA4wNaFmE747x3Kk2TBtM5CDprIKnApwqYEvPDQPEyogBzV7JX7 14joPYpiwvuQTijyCdwG44D45lS6M1/RP7VVs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OBk5RRCD2iLIhOK5co1TZE5o+SAQV6EEDJtV9mSx3y4=; b=aKcgutnLKlnw89o6DxUiBCZBgY/hI46bDi+orTJNpq6I/e7coMgEIBB1zxC7YBCqeW FEY+Y9lpgEAZ4DtlcoKLZ6kKBZaBF1BwVZGBybwtFHNlhwgkHrm6XFyF5bYRzh+fgtBL uJWQD8PWtRmelBOfc+GDkHjXFLmJvvfl7Kz4L0rqjpMWCR+a3hwS51/N/L4TQEIN41Xb FZ+kDpZI/l2AtwwODis4Py66S32GWCBjN8nIgTMV0Aozg14LJT7zETbN9u8s+PHuKa+2 klfNbZg0NhpShmS4mwsf0VFCWESvWBYjoSMDuOU9a6ZHZu+POo6VxM6IjLRKkr7dSf93 JHtg== X-Gm-Message-State: AOAM533H9/nk9uB+D+ZveI9CNXrj+TOZ+mmj4EDS7oGHa1rT/AMKu65L Er4F7ak6KZrrOR7RWob/jdTUPhvlbOwlOLEnhsA= X-Received: by 2002:ac2:54b8:: with SMTP id w24mr17316630lfk.593.1627408316221; Tue, 27 Jul 2021 10:51:56 -0700 (PDT) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com. [209.85.208.174]) by smtp.gmail.com with ESMTPSA id p16sm352597lfr.122.2021.07.27.10.51.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jul 2021 10:51:55 -0700 (PDT) Received: by mail-lj1-f174.google.com with SMTP id u20so16685216ljo.0 for ; Tue, 27 Jul 2021 10:51:54 -0700 (PDT) X-Received: by 2002:a2e:81c4:: with SMTP id s4mr15961914ljg.251.1627408314168; Tue, 27 Jul 2021 10:51:54 -0700 (PDT) MIME-Version: 1.0 References: <20210724193449.361667-1-agruenba@redhat.com> <20210724193449.361667-2-agruenba@redhat.com> <03e0541400e946cf87bc285198b82491@AcuMS.aculab.com> In-Reply-To: From: Linus Torvalds Date: Tue, 27 Jul 2021 10:51:38 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/8] iov_iter: Introduce iov_iter_fault_in_writeable helper To: Andreas Gruenbacher Cc: David Laight , Alexander Viro , Christoph Hellwig , "Darrick J. Wong" , Jan Kara , Matthew Wilcox , cluster-devel , linux-fsdevel , Linux Kernel Mailing List , "ocfs2-devel@oss.oracle.com" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 27, 2021 at 4:14 AM Andreas Gruenbacher wrote: > > On Tue, Jul 27, 2021 at 11:30 AM David Laight wrote: > > > > Is it actually worth doing any more than ensuring the first byte > > of the buffer is paged in before entering the block that has > > to disable page faults? > > We definitely do want to process as many pages as we can, especially > if allocations are involved during a write. Yeah, from an efficiency standpoint, once you start walking page tables, it's probably best to just handle as much as you can. But once you get an error, I don't think it should be "everything is bad". This is a bit annoying, because while *most* users really just want that "everything is good", *some* users might just want to handle the partial success case. It's why "copy_to/from_user()" returns the number of bytes *not* written, rather than -EFAULT like get/put_user(). 99% of all users just want to know "did I write all bytes" (and then checking for a zero return is a simple and cheap verification of "everything was ok"). But then very occasionally, you hit a case where you actually want to know how much of a copy worked. It's rare, but it happens, and the read/write system calls tend to be the main user of it. And yes, the fact that "copy_to/from_user()" doesn't return an error (like get/put_user() does) has confused people many times over the years. It's annoying, but it's required by those (few) users that really do want to handle that partial case. I think this iov_iter_fault_in_readable/writeable() case should do the same. And no, it's not new to Andreas' patch. iov_iter_fault_in_readable() is doing the "everything has to be good" thing already. Which maybe implies that nobody cares about partial reads/writes. Or it's very very rare - I've seen code that handles page faults in user space, but it's admittedly been some very special CPU simulator/emulator checkpointing stuff. Linus