Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp314010pxb; Wed, 20 Oct 2021 23:22:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0AdfnsCPox/u3uTEsgE85LsNGyH5UrFM7w1bPLS+3PzoZH3G71ZD6BJAxlf4494V8IIvZ X-Received: by 2002:a17:907:6e02:: with SMTP id sd2mr1258867ejc.46.1634797335302; Wed, 20 Oct 2021 23:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634797335; cv=none; d=google.com; s=arc-20160816; b=MlfEJ4U3cG65XSAB11b6gRGDkMq0/05BMHjTVhnQD6ggKEWGw2o17AE+27WqdykwpU Dl3fuEpVmwYrxNShujwZxo93RFZPT49oV3omYCPq7ncia3SkIbZXa9R8drjcx3I5ODm3 Ny3zS5bSvT9Zrcs7nCBhDFdRchIKlaZEZlnnJQhtH3ypGnnr0BdChcXxdtdxvJCp+CeH s6Iy2OJovSD5JC3ArDP5TbamZ6Xp5ipM9IRWNoDerXMvXdNDJ6PPoutlMahv2Bo60zhs 7pXO920yLv3GcrAw9Ylo96c/Xm61DAMfsxOfDTLlRcWe5igk/kghGEs6JmEzQrFOOHH/ oUdQ== 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=ySym1S+xM/vLmh5qD50mQk6IKKZnZMjSymPhRc8AKZU=; b=Bu445MxucHMVPJQnLnbu6Tsv8ffVtTiOm8xEaRZzGOjR1eF4ZHa5LhuJbGnX3TgJMW 4+kJXg3iQPMXo0mqweXNDel6RUQUY3vN+gF0tTcp6ou8fb3lZMErnl+9FiJ+WH3G8uWX VqMcbMQIuMCEtANG7wtHratWLqcfWN/9KrMwaNf9PvjUK6wMEbWS78yGmKI9DpwoR+lS C1KRsIb8yeVWFH1p5lU3auM7IrZezq/1itr4jLUrQIZJuX1Q2NeQhPeJZbSKdRqtyd/6 Yq1iu/Hs9qXzdSTAKrdcM82bBkE1bFJrNoAmAagW3VvL8wPvQ35Hy6JEWwUBVXMVf+1+ EChQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RmpuE9YS; 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 ia17si5729829ejc.17.2021.10.20.23.21.51; Wed, 20 Oct 2021 23:22:15 -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=RmpuE9YS; 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 S231154AbhJUGWQ (ORCPT + 99 others); Thu, 21 Oct 2021 02:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbhJUGWP (ORCPT ); Thu, 21 Oct 2021 02:22:15 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A29C7C06161C for ; Wed, 20 Oct 2021 23:19:59 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 145so752073ljj.1 for ; Wed, 20 Oct 2021 23:19:59 -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=ySym1S+xM/vLmh5qD50mQk6IKKZnZMjSymPhRc8AKZU=; b=RmpuE9YS+Yq15CaE68H5r+Sd49/j2Y+lxFABfuvmGEPn3ZGXwaksFMZ6o9eFdJsChj 2v/LHZpNjfudJ17zylPn7o2Z2Ux2I7bti/PND6qtRtfb26+3JS7yO0q+vWSx2CFJkuCa shobHsKKJNX/KQtyV6tpC+BY6SKms+67JaxlU= 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=ySym1S+xM/vLmh5qD50mQk6IKKZnZMjSymPhRc8AKZU=; b=FM7Jxt3RB2r5Wf5VJ/EU14vCC5Ws9f9FKfou1iwYrLzkOLR9Yg/JWAwkxhSzQwTdDl nku3pLdDvmlBMPXC1dBZB0A0r9qOMtIo51V9o7Ufv78P4O4wXmBPgquR8loRBL3Hxhr/ xcAOc8UFK7TmzJZstAKo19lsU+L9Fm4Buz5LkxRP6xYvpuPTossBmVSnCJP/1ZU1LvpY R96Zl5BdAdlctSNI6FrCOeL0ZxIDgf6hdWaZbb6Z+7jGlrMQXFfO25GFFN9+mx2DyDYB 3PM2VUo9p8AuyVC5QweJcPIVc7JcEhSKU8km71gupEIVXhu4vZ9VAiZRWh09qH1H7k9a dQMA== X-Gm-Message-State: AOAM533LG/f40JTN3d8Hv08Sppwo6uS+BPb2QrMD21Qbb1nEwO6IJnBG S4cS78Sm74971/mqsVsILAcdtMbvg/CFxsJ0Yw8= X-Received: by 2002:a2e:a277:: with SMTP id k23mr3787939ljm.22.1634797197818; Wed, 20 Oct 2021 23:19:57 -0700 (PDT) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com. [209.85.167.43]) by smtp.gmail.com with ESMTPSA id b10sm447746ljo.14.2021.10.20.23.19.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Oct 2021 23:19:57 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id t9so1742564lfd.1 for ; Wed, 20 Oct 2021 23:19:56 -0700 (PDT) X-Received: by 2002:a19:ad0c:: with SMTP id t12mr3576075lfc.173.1634797196615; Wed, 20 Oct 2021 23:19:56 -0700 (PDT) MIME-Version: 1.0 References: <20211019134204.3382645-1-agruenba@redhat.com> In-Reply-To: From: Linus Torvalds Date: Wed, 20 Oct 2021 20:19:40 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 00/17] gfs2: Fix mmap + page fault deadlocks To: Catalin Marinas Cc: Andreas Gruenbacher , Paul Mackerras , Alexander Viro , Christoph Hellwig , "Darrick J. Wong" , Jan Kara , Matthew Wilcox , cluster-devel , linux-fsdevel , Linux Kernel Mailing List , ocfs2-devel@oss.oracle.com, kvm-ppc@vger.kernel.org, linux-btrfs Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 20, 2021 at 12:44 PM Catalin Marinas wrote: > > However, with MTE doing both get_user() every 16 bytes and > gup can get pretty expensive. So I really think that anything that is performance-critical had better only do the "fault_in_write()" code path in the cold error path where you took a page fault. IOW, the loop structure should be repeat: take_locks(); pagefault_disable(); ret = do_things_with_locks(); pagefault_enable(); release_locks(); // Failure path? if (unlikely(ret == -EFAULT)) { if (fault_in_writable(..)) goto repeat; return -EFAULT; } rather than have it be some kind of "first do fault_in_writable(), then do the work" model. So I wouldn't worry too much about the performance concerns. It simply shouldn't be a common or hot path. And yes, I've seen code that does that "fault_in_xyz()" before the critical operation that cannot take page faults, and does it unconditionally. But then it isn't the "fault_in_xyz()" that should be blamed if it is slow, but the caller that does things the wrong way around. Linus