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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 8AE1CC2B9F4 for ; Tue, 22 Jun 2021 17:26:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0D5726109E for ; Tue, 22 Jun 2021 17:26:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D5726109E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A37E16B0036; Tue, 22 Jun 2021 13:26:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E8C16B005D; Tue, 22 Jun 2021 13:26:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 855A06B006C; Tue, 22 Jun 2021 13:26:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 246786B0036 for ; Tue, 22 Jun 2021 13:26:25 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5E2D11B419 for ; Tue, 22 Jun 2021 17:26:25 +0000 (UTC) X-FDA: 78282038730.19.5469E67 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 81347543 for ; Tue, 22 Jun 2021 17:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mOJMY6UOYq7EaC2SDC9v+zeUo0FEEd2ZM34anZJPrG8=; b=RDSUY3nJuJPGNXnzMGU4Nm5OFG knOmUgsCxWwKh/8EEHQUy9vtATVzVa8ve5UAvHrphjagiV5sMXQBT4oiOpM56T/AXJAqcpSJwD5A/ TaSvPzxDSTgo2NBa69kr1+HwavpGgZan5lVpRGf2qGKgLXfHgKq1d7I2IF1Na7rdx8tmP+lloSlRw ZumFsdUMykOmBOGfn0HqHv968m2YdfHs11FnwSsPriLaEBFmXg4B6I6KDyaYxrfl7V5IY3outGNQx WvWuOuZermop/gA5DF6UoLvqJXJ+efg0szmPWASoPPyX3nHPhyYdKQLnV+DvqhGYli8bhEQQGWXTq S6KI9I5Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvk9t-00EY8S-Ia; Tue, 22 Jun 2021 17:26:00 +0000 Date: Tue, 22 Jun 2021 18:25:57 +0100 From: Matthew Wilcox To: Al Viro Cc: David Howells , torvalds@linux-foundation.org, Ted Ts'o , Dave Hansen , Andrew Morton , linux-mm@kvack.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Do we need to unrevert "fs: do not prefault sys_write() user buffer pages"? Message-ID: References: <3221175.1624375240@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RDSUY3nJ; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Stat-Signature: 6g7gj9d8y58nb3ykouy13kibquxr7xb5 X-Rspamd-Queue-Id: 81347543 X-Rspamd-Server: rspam06 X-HE-Tag: 1624382784-122110 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: On Tue, Jun 22, 2021 at 03:36:22PM +0000, Al Viro wrote: > On Tue, Jun 22, 2021 at 03:27:43PM +0000, Al Viro wrote: > > On Tue, Jun 22, 2021 at 04:20:40PM +0100, David Howells wrote: > > > > > and wondering if the iov_iter_fault_in_readable() is actually effective. Yes, > > > it can make sure that the page we're intending to modify is dragged into the > > > pagecache and marked uptodate so that it can be read from, but is it possible > > > for the page to then get reclaimed before we get to > > > iov_iter_copy_from_user_atomic()? a_ops->write_begin() could potentially take > > > a long time, say if it has to go and get a lock/lease from a server. > > > > Yes, it is. So what? We'll just retry. You *can't* take faults while holding > > some pages locked; not without shitloads of deadlocks. > > Note that the revert you propose is going to do fault-in anyway; we really can't > avoid it. The only thing it does is optimistically trying without that the > first time around, which is going to be an overall loss exactly in "slow > write_begin" case. If source pages are absent, you'll get copyin fail; > iov_iter_copy_from_user_atomic() (or its replacement) is disabling pagefaults > itself. Let's not overstate the case. I think for the vast majority of write() calls, the data being written has recently been accessed. So this userspace access is unnecessary. From the commentary around commits 00a3d660cbac and 998ef75ddb57, it seems that Dave had a CPU which was particularly inefficient at accessing userspace. I assume Intel have fixed that by now and the extra load is in the noise. But maybe enough CPU errata have accumulated that it's slow again?