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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0773C2B9F4 for ; Tue, 22 Jun 2021 15:32:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D31560FEB for ; Tue, 22 Jun 2021 15:32:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D31560FEB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1F2056B0036; Tue, 22 Jun 2021 11:32:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A2656B006C; Tue, 22 Jun 2021 11:32:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 041D96B0070; Tue, 22 Jun 2021 11:32:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id B83CF6B0036 for ; Tue, 22 Jun 2021 11:32:51 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F1B45180BDF39 for ; Tue, 22 Jun 2021 15:32:51 +0000 (UTC) X-FDA: 78281752542.14.2EA93CD Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by imf13.hostedemail.com (Postfix) with ESMTP id 8800EE002CCE for ; Tue, 22 Jun 2021 15:32:51 +0000 (UTC) Received: by mail-lj1-f179.google.com with SMTP id c11so30734233ljd.6 for ; Tue, 22 Jun 2021 08:32:51 -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=hmjRNaRTsIzZ03uK9rRt/2A93U0PY9kbbj4A/XRT2RE=; b=B6yWARmK6avEL61zEXxkktz5rMZ9fVIMLFKMWeX9LV0Sfcd5VNigl3pqQdvVOnT5fc wmXE3hK9zOlTCkZFZLMF/QUQ+0cmNYbS2oB34FCfw6eCV15UfYIvGJflzAjcMTMrjE3J gE/yWAYAxnnXGInGBg5PdjmBrZOcNgYDrgWts= 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=hmjRNaRTsIzZ03uK9rRt/2A93U0PY9kbbj4A/XRT2RE=; b=BBJnnNUZRaECUFqUHvvNwRzSWEUnxZUosSOsr3FECRcbSx9yJTXFCekSeB6egWzjxn b+cd36Pi2cKJC2AAD4ChgQdxEy1Dtk+ksSnnt94Q+PDJB/84ag+rHd+t210RI1XJ6tsp 5WZjFHKXyJJ/cmRKm/P0iE8J1taFy9e3Pef1qGWOVdyDtrnLHJfF11yRi/2Wtt4lsOt0 KluRpi0tGoceFs7G7ka9kEeVGwg/mzehcl4GdqfJx6+g4S8yxxNZPKCn6BGoro6+KMIp Il86J0dhnZgIbwrU/x9TXZSjHjQi/egK/Vp3D2PJTdlZFdMY38RfxjvM/sm23N/HaOtR HkjQ== X-Gm-Message-State: AOAM530YddpQSHIyY3IaD4w76dA7nGehmIiG9b1xjH547+1Sbb+elmq/ XM/NJLvzK7838Bg12jB6qyrjGfz6Z/9KJ0x1+iE= X-Google-Smtp-Source: ABdhPJwQHdJtDSRXLBTiyYJg1Fw/oBtTZmkVzjgMTdMTMO4aiYbs110iQlBnCefRqP0WdKtsHX4aBA== X-Received: by 2002:a2e:6c1a:: with SMTP id h26mr3870999ljc.34.1624375969923; Tue, 22 Jun 2021 08:32:49 -0700 (PDT) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id r20sm2619352lji.53.2021.06.22.08.32.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Jun 2021 08:32:48 -0700 (PDT) Received: by mail-lj1-f180.google.com with SMTP id u20so11012840ljl.13 for ; Tue, 22 Jun 2021 08:32:47 -0700 (PDT) X-Received: by 2002:a2e:7813:: with SMTP id t19mr3700308ljc.411.1624375967597; Tue, 22 Jun 2021 08:32:47 -0700 (PDT) MIME-Version: 1.0 References: <3221175.1624375240@warthog.procyon.org.uk> In-Reply-To: <3221175.1624375240@warthog.procyon.org.uk> From: Linus Torvalds Date: Tue, 22 Jun 2021 08:32:31 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Do we need to unrevert "fs: do not prefault sys_write() user buffer pages"? To: David Howells Cc: "Ted Ts'o" , Dave Hansen , Andrew Morton , Matthew Wilcox , Al Viro , Linux-MM , Ext4 Developers List , linux-fsdevel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=B6yWARmK; dmarc=none; spf=pass (imf13.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.179 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-Stat-Signature: b3tqz7x4jw8whs1pd9e4riihgz88xa9u X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8800EE002CCE X-HE-Tag: 1624375971-628553 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Note this part: On Tue, Jun 22, 2021 at 8:20 AM David Howells wrote: > > copied = iov_iter_copy_from_user_atomic(page, i, offset, bytes); The "atomic" is the key thing. The fault_in_readable is just an optimistic "let's make things be mapped". But yes, it could get unmapped again before the actual copy happens with the lock held. But that's why the copy is using that atomic version, so if that happens, we'll end up repeating. Honestly, the first part comment above the iov_iter_fault_in_readable() is a bit misleading (the deadlock would be real _except_ for the atomic part), and it would logically make sense to only do this for when the actual atomic copy_from_user_atomic fails. But then you'd have to fault things twice if you do fault. Linus