Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp716152pxb; Thu, 9 Sep 2021 10:19:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3EvEC0D/yFjYuOR1O9m96eGiD2W2sKsFbAyXIhmMRwN3hjOYTGfmOoeqJXzbJdd5AEdCK X-Received: by 2002:a17:906:dc43:: with SMTP id yz3mr4707959ejb.467.1631207973592; Thu, 09 Sep 2021 10:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631207973; cv=none; d=google.com; s=arc-20160816; b=TbmCtsEv5KeptTqh8yLKhKCViL15cq1zCTLZAneAzIOfzg5WxP01hlimXI9v6XpfNi /2z39/F9kFfYmARiubgHuEsv5l3qchBIRkGtZKri6h0A7cdv2NakAyiBlpUR0AWqXRSX PryoGliocZRoF+dInfmdzo4MNWPhXXE3e0vdIc+rdA6O7zHZdoAU/5evsrXWmwCeqchx GhQatedNKXBGO3V6pIuIp/CfcamPTk2D49RXLlELxvDSAidYXl4jFeAnUSX0VQxb290F gbeHe5FBiHUv7MkAHLhuLDs57cwTLHYvSaIyXDBmDC4VF/QEch1WKhC8yajUZeZgn/t+ 5HPw== 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=jlWzkECk20+XqmMBmmlhgHERfUmOY5RNnADt8Z36qog=; b=GvIWgN4h06azF5055koxUU9lU47/JVEtxvvIpjvDfOYENTIo/QwPLG8Jpck1L/ibHj 7p7Y+4G7UnQb1BxUvx++4Mp+12V1Hx0X6R0wYH7MJevEQu4xIt7vYxU+2jYv9KBdQm1M eX6/OiSQiKFxVlL16ongjEc4lmmlQSRUqmEync3h3IPfLervz+WTnImLq9FrfHtDUwIg XhmJdit8CuorI9iPdXCAJc35wRgQMIaKiWB4PIi0ZqkyNa6v8uZEtaAUpkXr/sHMAc5K xYuLQLy4vgyhW6kEDzOkZ35d8Kwtxrlb+aSexx8nSNxDGwu7n2BiTjG+u9lP6rUBTGQI IHmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=EK8cd8m3; 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 e1si3351566edl.348.2021.09.09.10.19.08; Thu, 09 Sep 2021 10:19:33 -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=EK8cd8m3; 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 S240916AbhIIRSo (ORCPT + 99 others); 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-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