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,URIBL_BLOCKED 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 5629DC4338F for ; Wed, 18 Aug 2021 21:49:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3602A61103 for ; Wed, 18 Aug 2021 21:49:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234276AbhHRVuX (ORCPT ); Wed, 18 Aug 2021 17:50:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234057AbhHRVuW (ORCPT ); Wed, 18 Aug 2021 17:50:22 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62760C0613CF for ; Wed, 18 Aug 2021 14:49:47 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id w4so6239684ljh.13 for ; Wed, 18 Aug 2021 14:49:47 -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=iJVkGRZsMGQxCh04dQEEetPATyoitTCuRRt3dR/OwaQ=; b=MBJrjaGztFAJR0qOLiTWThRt9z10srm4PeJK99NfdPS1VdWHes04bGEuCMJ3+81yKG xMmt1W/5VFXH3Y/rlf6JGj6KPQ5aqt6Bo2HysLVRmrbi/u8P9ZK6QtkU0Zxnv02rxAmg ETOd9msrKzgzXYudP8auMlhAHgLqL7dhfq+1A= 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=iJVkGRZsMGQxCh04dQEEetPATyoitTCuRRt3dR/OwaQ=; b=Gf087C7VT9asL7bq8iWr8Y+ZTv/xrvylunpdtBog1iSA3twkNUEf3uCq5jYU1QVhvI 8O7dpBPKfxcAqjVnlaha5BBCm38OcPqmBC4OpMJH2fqfRFDTk9e/fF1cA86FPSTXZZO7 rTd6d6sBHGjy6hcTkJLH3Chu228cMgXs4ST26pYoxwAiXAZ1aiaLSF+iN/ogs97SHpBo uNUExQuZyEZUpMKboeIBRs+qvxIbcrI78kJ1y1VhpxoESUkVNcwQUXwzYU0XcVgHK1+N 8+pcV3mFkmHEooSnGEYQieStXVsgXYQwBsJXs4xFj17oSeUD5XJ3QkuwMJnZP6IbCGfz 9waQ== X-Gm-Message-State: AOAM531yUyigUB3MrNZYxJl+jqlc2yIlCqGZlGXsjTi4pjikEv6JLHPd A6adQqWL7A10zud+03crayWjoM7VTxbB3x1n X-Google-Smtp-Source: ABdhPJz+UJQrgcm8PcgmTrog3InsM9YwybupE3s+Ly9dOD+OgDyMOjLHhsyEAuZ5c+YuDhYFE0vSPA== X-Received: by 2002:a2e:b605:: with SMTP id r5mr3759697ljn.283.1629323385645; Wed, 18 Aug 2021 14:49:45 -0700 (PDT) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id l8sm85883lfg.218.2021.08.18.14.49.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Aug 2021 14:49:44 -0700 (PDT) Received: by mail-lf1-f48.google.com with SMTP id r9so7826184lfn.3 for ; Wed, 18 Aug 2021 14:49:44 -0700 (PDT) X-Received: by 2002:ac2:5a1a:: with SMTP id q26mr7636192lfn.41.1629323384436; Wed, 18 Aug 2021 14:49:44 -0700 (PDT) MIME-Version: 1.0 References: <20210803191818.993968-1-agruenba@redhat.com> In-Reply-To: From: Linus Torvalds Date: Wed, 18 Aug 2021 14:49:28 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 00/12] gfs2: Fix mmap + page fault deadlocks To: Andreas Gruenbacher Cc: Alexander Viro , Christoph Hellwig , "Darrick J. Wong" , Paul Mackerras , Jan Kara , Matthew Wilcox , cluster-devel , linux-fsdevel , Linux Kernel Mailing List , ocfs2-devel@oss.oracle.com, kvm-ppc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Sorry for the delay, I was on the road and this fell through the cracks ] On Mon, Aug 16, 2021 at 12:14 PM Andreas Gruenbacher wrote: > > On Tue, Aug 3, 2021 at 9:45 PM Linus Torvalds > wrote: > > > > Hmm. Have you tried to figure out why that "still returns 0" happens? > > The call stack is: > > gup_pte_range > gup_pmd_range > gup_pud_range > gup_p4d_range > gup_pgd_range > lockless_pages_from_mm > internal_get_user_pages_fast > get_user_pages_fast > iov_iter_get_pages > __bio_iov_iter_get_pages > bio_iov_iter_get_pages > iomap_dio_bio_actor > iomap_dio_actor > iomap_apply > iomap_dio_rw > gfs2_file_direct_write > > In gup_pte_range, pte_special(pte) is true and so we return 0. Ok, so that is indeed something that the fast-case can't handle, because some of the special code wants to have the mm_lock so that it can look at the vma flags (eg "vm_normal_page()" and friends. That said, some of these cases even the full GUP won't ever handle, simply because a mapping doesn't necessarily even _have_ a 'struct page' associated with it if it's a VM_IO mapping. So it turns out that you can't just always do fault_in_iov_iter_readable() and then assume that you can do iov_iter_get_pages() and repeat until successful. We could certainly make get_user_pages_fast() handle a few more cases, but I get the feeling that we need to have separate error cases for EFAULT - no page exists - and the "page exists, but cannot be mapped as a 'struct page'" case. I also do still think that even regardless of that, we want to just add a FOLL_NOFAULT flag that just disables calling handle_mm_fault(), and then you can use the regular get_user_pages(). That at least gives us the full _normal_ page handling stuff. Linus