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.7 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 BE09FC433EF for ; Thu, 9 Sep 2021 17:17:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AFBA610CE for ; Thu, 9 Sep 2021 17:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239891AbhIIRSo (ORCPT ); Thu, 9 Sep 2021 13:18:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237002AbhIIRSn (ORCPT ); Thu, 9 Sep 2021 13:18:43 -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 A6288C061574 for ; Thu, 9 Sep 2021 10:17:33 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id f2so4152059ljn.1 for ; Thu, 09 Sep 2021 10:17:33 -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=jlWzkECk20+XqmMBmmlhgHERfUmOY5RNnADt8Z36qog=; b=EK8cd8m3N90BRu7k+tQtRObfDdPm0WNzqcuF6FrjTVlzmoTGEV2VxpLRUXVf9jH8aT G4eBWVkI6uQCMRJzKE9fKssV/wmh8IHKnfFtSZCCFwM1RslKOwFVYeqDmIxarH/iLLjP HwKvShhp9FmcqErZVIckI4ZtDeQufVRuWD4Zs= 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=jlWzkECk20+XqmMBmmlhgHERfUmOY5RNnADt8Z36qog=; b=aJmC1PcnAq0FVhTVYXidl3jsHgmm6PxWs57Z2F6YDWa6rONOBPR9eDzsNrTLntMUGZ zcM1RePws1aVxmXG8WDMDglel/5O/wzBY0B7rTH5rKwrZT/e7cysuDt6DHCR6HpApD6W +fvP0PL7kNk2SvrqHH2pfZ2zUNb24kjKqsoRF1+/MdTD4zZgkfmx1cquqExhjjqdU6XI PX7AmpvaWpJks9Xx61XMSKrn7Q9eJsSdv8V4RNcXTVIlW3cPXqYaE/IqrwTqmHMxYozt Z5Wkri7G+yvD34frX0cJB80o/rajT8BYrnz6VUSBSROR7CmM60niCnxwiupiyJotBk3v jTxQ== X-Gm-Message-State: AOAM532sW7zut76V81v4YgDScAC8uUJMkl4N82D6KfB2gihbn9uZYOWM 4lI0h8p1uEHZW+xRSpX+Me0ohv21GWxr9O1OQZY= X-Google-Smtp-Source: ABdhPJzGLqlMs9b8WskgWFYlW8Sdf8nDapgyQni3UWyB43cLMLWL6LxbKmr1BVhGbTXfK6V0jRIQxA== X-Received: by 2002:a2e:9154:: with SMTP id q20mr729960ljg.455.1631207851497; Thu, 09 Sep 2021 10:17:31 -0700 (PDT) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com. [209.85.208.170]) by smtp.gmail.com with ESMTPSA id j3sm259020lfm.92.2021.09.09.10.17.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Sep 2021 10:17:30 -0700 (PDT) Received: by mail-lj1-f170.google.com with SMTP id j12so4097449ljg.10 for ; Thu, 09 Sep 2021 10:17:30 -0700 (PDT) X-Received: by 2002:a2e:8185:: with SMTP id e5mr734988ljg.31.1631207850194; Thu, 09 Sep 2021 10:17:30 -0700 (PDT) MIME-Version: 1.0 References: <20210827164926.1726765-1-agruenba@redhat.com> <20210827164926.1726765-18-agruenba@redhat.com> In-Reply-To: From: Linus Torvalds Date: Thu, 9 Sep 2021 10:17:14 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 17/19] gup: Introduce FOLL_NOFAULT flag to disable page faults To: Christoph Hellwig Cc: Andreas Gruenbacher , Alexander Viro , "Darrick J. Wong" , Jan Kara , Matthew Wilcox , cluster-devel , linux-fsdevel , Linux Kernel Mailing List , ocfs2-devel@oss.oracle.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 9, 2021 at 4:36 AM Christoph Hellwig wrote: > > On Fri, Aug 27, 2021 at 06:49:24PM +0200, Andreas Gruenbacher wrote: > > Introduce a new FOLL_NOFAULT flag that causes get_user_pages to return > > -EFAULT when it would otherwise trigger a page fault. This is roughly > > similar to FOLL_FAST_ONLY but available on all architectures, and less > > fragile. > > So, FOLL_FAST_ONLY only has one single user through > get_user_pages_fast_only (pin_user_pages_fast_only is entirely unused, > which makes totally sense given that give up on fault and pin are not > exactly useful semantics). So I think we should treat FOLL_FAST_ONLY as a special "internal to gup.c" flag, and perhaps not really compare it to the new FOLL_NOFAULT. In fact, maybe we could even just make FOLL_FAST_ONLY be the high bit, and not expose it in and make it entirely private as a name in gup.c. Because FOLL_FAST_ONLY really is meant more as a "this way we can share code easily inside gup.c, by having the internal helpers that *can* do everything, but not do it all when the user is one of the limited interfaces". Because we don't really expect people to use FOLL_FAST_ONLY externally - they'll use the explicit interfaces we have instead (ie "get_user_pages_fast()"). Those use-cases that want that fast-only thing really are so special that they need to be very explicitly so. FOLL_NOFAULT is different, in that that is something an external user _would_ use. Admittedly we'd only have one single case for now, but I think we may end up with other filesystems - or other cases entirely - having that same kind of "I am holding locks, so I can't fault into the MM, but I'm otherwise ok with the immediate mmap_sem lock usage and sleeping". End result: FOLL_FAST_ONLY and FOLL_NOFAULT have some similarities, but at the same time I think they are fundamentally different. The FAST_ONLY is the very very special "I can't sleep, I can't even take the fundamental MM lock, and we export special interfaces because it's _so_ special and can be used in interrupts etc". In contrast, NOFAULT is not _that_ special. It's just another flag, and has generic use. Linus