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 A675AC433EF for ; Wed, 24 Nov 2021 23:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346935AbhKXXDb (ORCPT ); Wed, 24 Nov 2021 18:03:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbhKXXD3 (ORCPT ); Wed, 24 Nov 2021 18:03:29 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27333C061574 for ; Wed, 24 Nov 2021 15:00:19 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id y13so17043664edd.13 for ; Wed, 24 Nov 2021 15:00:19 -0800 (PST) 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=3I9PlA7fC8HgB2vr5zydxZ4zg5kA0COA3RvDIbE8i6k=; b=akPSCYrD6EASyAHbxHctwYr0LW3XzQryE1WnwGL61n9RnWw1NkFmVSX0i9BtWuGZYh 3HsX+j15WJiusBmje+0ffkwgWfbwZl3OZuwQ+FeVw4qqieUoMRy3mrm7/NfOdIx1DyJ8 WJvl/rGNRCqOZGiGzEuCEgFc6r1TDjmx7J7Ok= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3I9PlA7fC8HgB2vr5zydxZ4zg5kA0COA3RvDIbE8i6k=; b=M9TJGSauAAct6s3HDIurshrhgCaYd8VIUBikpLUWvbNiv6/IAuXNlVfEtHecOQpYJZ 9KCovfcs3TIrj/XuTPGaqKe+5HCdHLKBPX7QA3Kt5UmhKARx3tDK6n/U4Z1YlCGjHa5S 8ec4jBTfOqATBDiiTF++0+RRkwk88xHvHU3SSmv4Ip+9PDx5wuMYhzJlH8/Bc9HneWmR OnvtkuGOs5X/tcJX6uSS43r7pSeI/zXFnJ1A14qwqHvtlMO1hWeLFmJClbh8f1pNW20H kCetw1U+b4rYp/+E/aYs5bYIHoPwHY/sVbNw+g/x6BeCdyImUomCgqwWEJkb2yo2gG3c cw+w== X-Gm-Message-State: AOAM531m0hgfEfhmNbf3xwyAb1WRitFhK1iGvycoFlb4XLKZlOoI1wxF 7wUKY5lVXVxdhnH0ZTqF/FQgL8i/B7Tizj2S X-Google-Smtp-Source: ABdhPJy8Ya6GpkY/+1+KVvSQRqWgjGZA+Ct9/Uc0yLcSf2V4aEhY0/TPG73jmOZr0qwOgj2b9e64jQ== X-Received: by 2002:a05:6402:51d2:: with SMTP id r18mr31517910edd.13.1637794817414; Wed, 24 Nov 2021 15:00:17 -0800 (PST) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com. [209.85.128.46]) by smtp.gmail.com with ESMTPSA id qf8sm590957ejc.8.2021.11.24.15.00.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Nov 2021 15:00:16 -0800 (PST) Received: by mail-wm1-f46.google.com with SMTP id p18so3901138wmq.5 for ; Wed, 24 Nov 2021 15:00:16 -0800 (PST) X-Received: by 2002:a05:600c:4e07:: with SMTP id b7mr1159359wmq.8.1637794816000; Wed, 24 Nov 2021 15:00:16 -0800 (PST) MIME-Version: 1.0 References: <20211124192024.2408218-1-catalin.marinas@arm.com> <20211124192024.2408218-4-catalin.marinas@arm.com> In-Reply-To: From: Linus Torvalds Date: Wed, 24 Nov 2021 15:00:00 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults To: Matthew Wilcox Cc: Catalin Marinas , Josef Bacik , David Sterba , Andreas Gruenbacher , Al Viro , Andrew Morton , Will Deacon , linux-fsdevel , Linux Kernel Mailing List , Linux ARM , linux-btrfs Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Catalin talked about the other change, but this part: On Wed, Nov 24, 2021 at 12:04 PM Matthew Wilcox wrote: > > (where __copy_to_user_nofault() is a new function that does exactly what > copy_to_user_nofault() does, but returns the number of bytes copied) If we want the "how many bytes" part, then we should just make copy_to_user_nofault() have the same semantics as a plain copy_to_user(). IOW, change it to return "number of bytes not copied". Lookin gat the current uses, such a change would be trivial. The only case that wants a 0/-EFAULT error is the bpf_probe_write_user(), everybody else already just wants "zero for success", so changing copy_to_user_nofault() would be trivial. And it really is odd and very non-intuitive that copy_to_user_nofault() has a completely different return value from copy_to_user(). So if _anybody_ wants a byte-count, that should just be fixed. Linus