Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp432396rwb; Thu, 27 Jul 2023 15:22:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlGJx8fX7UzqFZ2w4MbfcP+pyjhC3ix7NUh0illOGTAn3OeEYgbb6yhBRJT/9NHVQf3U1OED X-Received: by 2002:a17:906:1051:b0:99b:b867:4969 with SMTP id j17-20020a170906105100b0099bb8674969mr373532ejj.64.1690496564065; Thu, 27 Jul 2023 15:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690496564; cv=none; d=google.com; s=arc-20160816; b=K+1dLsTIyvXB3gRyyl5dbGxegh86LiDRUk2hsZxqAL2vsbjFIlTRNjnh8Wjp2fL5DR DUoIYIrYyC2COwLT8XANLZTYM2rfejvUTdJ3OdlsMYV1R00K8xJMHMlqBlLwOBUj1QDs 6Fo6ZHgnR+aIYu1MgupiD/OaTFMzLI7u9rLDe0AAHlSGglL9GlRgEclOeOL//IujLWaj B8DgUSjEEpPOYS+BF5hR8ncAPwUeC/vkzfOf3uiBIzoO0ddM3xHCZY7JKqXsEU/UQ7Ts hz6GXof+CpZ3AusAhyoqLv7Lk89UFL96sEHv+GVf3l1PFfVE7hgVJwAQlfjF+np3wVgu ei5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jGnguQzUAnXSgoEJGq4aUCEYI9GBqFjghH3nhnid2s4=; fh=7Rgwgprh6RG9EUsex42/VTSquO8kknsMsxso4zkcjrY=; b=Q6uWpwnZBtSoveAYRHXABDsde3tiHrlQxZwfjEK7j7LdQU7G99Mbb3z1MQCA0m5mvV jj3YaX19CEu9I/2Zz4suzPzOIFvZVx3ftBPN0aKdL8Iab1LIo0f3VFLzy7kV40dvTVtu k0+LZ4+0bi8VdKWdAWA2aSNSY8D2tKPFgp2FKriqJ3yDoHLhQXszHXYWQ+X4xUcKXJJH SnakigeUuPYbrwF3hk0WWp3kNRdH6H0mABQSZP2KepfC837wiU+XBBxjuwE1ffsexz6X P6UInk+7DhXcc+rMis4aZ9LDkEVXzz7Fo6X/StXHWsH9BfAf9Enevhwv5yx8xsBK50j2 F+wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CE1+m84T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m15-20020a17090607cf00b00992d6e88081si1574553ejc.956.2023.07.27.15.21.53; Thu, 27 Jul 2023 15:22:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CE1+m84T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232167AbjG0Vam (ORCPT + 99 others); Thu, 27 Jul 2023 17:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbjG0Vab (ORCPT ); Thu, 27 Jul 2023 17:30:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4D1C1BC6 for ; Thu, 27 Jul 2023 14:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690493344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jGnguQzUAnXSgoEJGq4aUCEYI9GBqFjghH3nhnid2s4=; b=CE1+m84ToiW7szkkYKChwaKkelUv97ANi7OafUT1aZ8TbNrqKlVepk77xMxrRNZgZwD409 O0Jr5x4f8/q1CbQu/jqiuYDiJlN6z0AX81eggi4Es9ZUSOW/TUBLz93aogqSrpi98+5L/w zoSi9eQdzysFicemscszbjdPnHlSr/s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-u7XBChHRONmnMfoWeq8OoQ-1; Thu, 27 Jul 2023 17:29:00 -0400 X-MC-Unique: u7XBChHRONmnMfoWeq8OoQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C80A3856F66; Thu, 27 Jul 2023 21:28:59 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDA6240C2063; Thu, 27 Jul 2023 21:28:57 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Linus Torvalds , liubo , Peter Xu , Matthew Wilcox , Hugh Dickins , Jason Gunthorpe , John Hubbard Subject: [PATCH v1 4/4] mm/gup: document FOLL_FORCE behavior Date: Thu, 27 Jul 2023 23:28:45 +0200 Message-ID: <20230727212845.135673-5-david@redhat.com> In-Reply-To: <20230727212845.135673-1-david@redhat.com> References: <20230727212845.135673-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As suggested by Peter, let's document FOLL_FORCE handling and make it clear that without FOLL_FORCE, we will always trigger NUMA-hinting faults when stumbling over a PROT_NONE-mapped PTE. Also add a comment regarding follow_page() and its interaction with FOLL_FORCE. Let's place the doc next to the definition, where it certainly can't be missed. Signed-off-by: David Hildenbrand --- include/linux/mm_types.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 2fa6fcc740a1..96cf78686c29 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -1243,7 +1243,30 @@ enum { FOLL_GET = 1 << 1, /* give error on hole if it would be zero */ FOLL_DUMP = 1 << 2, - /* get_user_pages read/write w/o permission */ + /* + * Make get_user_pages() and friends ignore some VMA+PTE permissions. + * + * This flag should primarily only be used by ptrace and some + * GUP-internal functionality, such as for mlock handling. + * + * Without this flag, these functions always trigger page faults + * (such as NUMA hinting faults) when stumbling over a + * PROT_NONE-mapped PTE. + * + * !FOLL_WRITE: succeed even if the PTE is PROT_NONE + * * Rejected if the VMA is currently not readable and it cannot + * become readable + * + * FOLL_WRITE: succeed even if the PTE is not writable. + * * Rejected if the VMA is currently not writable and + * * it is a hugetlb mapping + * * it is not a COW mapping that could become writable + * + * Note: follow_page() does not accept FOLL_FORCE. Historically, + * follow_page() behaved similar to FOLL_FORCE without FOLL_WRITE: + * succeed even if the PTE is PROT_NONE and FOLL_WRITE is not set. + * However, VMA permissions are not checked. + */ FOLL_FORCE = 1 << 3, /* * if a disk transfer is needed, start the IO and return without waiting -- 2.41.0