Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp857850rwe; Thu, 25 Aug 2022 10:17:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR6De41zEMN3o09+gzIBeLuGbsL0LtUbLFfkkm/oi+PlWdjcaxm3QTknHgOerqlW3OFZSiKq X-Received: by 2002:a63:5809:0:b0:42a:3145:507d with SMTP id m9-20020a635809000000b0042a3145507dmr99502pgb.428.1661447849375; Thu, 25 Aug 2022 10:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661447849; cv=none; d=google.com; s=arc-20160816; b=L+zbibMuZ/Xa3L2J0aAAqABE9DcNl2dshdpnJm/7XHrZrtFJJI8G1PJGO+Smb/y861 hi/3meL59qVL3I9wvsZqqIRNMcN67kWv2uRQg+LgAkEP14Cy8TY8Hun+EIyZuxaIPc3K Ew2cNsHU2drfvIgVFg/YITuvQCvInx7EBkQnt/xk5vpP3ZbrlOkf4XvEFgeJfA9uUMd/ d9DlBikGZlmTTN6PTJLeQFLhsrO/Y9qx0J+EyIQfcxvP7eTCe7PClPUXv2dTJnad7IAM 8WMbVkOF/0rxMG6ORTEKYTJAih+n316nHYtX5LQ5Cenp8MLCbdlA9H7DNSMneaFjrzsm Widg== 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=Q3NPvWyh2xRtoYXHMmyrsAAtGbzTeyv985JIMuXJIb4=; b=KzyWZlBvUhOIC5C1C6cwnITU3bkEOwnbx951Csi1p/PyYuoClCbKtVDk8e4Oyiavhz 4caTPc3oxLEe3QXmU/+5y2ecjXR71EI7D851l2WHgoUrf4dg+pj6l1EFTITcB+wmg0PS wpNvS+jeKLqgTHa4/E69b1RBVIzDNbJs6b/lVlQYBOYfCaXZ6tx1l4tHWby6MhFFiYUS /Kxp1d489hRI/VuK9dKKL9MjfYZcEu68r1EI1JUhmEqVS3AoU1pOLgYQlN0tHcvNfV3Q OnMTnm103IfMYF0JHVAGKUarYUavooLbUNmpOm9yrBwf35SqlfHSNUwOVk8Q5pFNA3rP o28Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IuyWJAWM; 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 2-20020a17090a1a4200b001fb1de0807dsi4108225pjl.123.2022.08.25.10.17.14; Thu, 25 Aug 2022 10:17:29 -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=IuyWJAWM; 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 S243421AbiHYQtw (ORCPT + 99 others); Thu, 25 Aug 2022 12:49:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242954AbiHYQtb (ORCPT ); Thu, 25 Aug 2022 12:49:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A62CBFAA7 for ; Thu, 25 Aug 2022 09:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661446031; 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=Q3NPvWyh2xRtoYXHMmyrsAAtGbzTeyv985JIMuXJIb4=; b=IuyWJAWMTr8eL4p1Clm+lJ6P8aG8+34RIxuK7iEslEBbAPvkDQoTrA0lp/jcp2zU9I97d6 g4Cg1uMCU0SgO1v+bm72qfEHBpOBVZ9z2N3xTv0JSXZKOREHoGDWdoxif3Q+ciC3IS5l4L PsYTTwXOVRAqwixZCDq7V4fjumRSzTA= 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-620-xXkhVmbBN16ANoNW0OvGkQ-1; Thu, 25 Aug 2022 12:47:09 -0400 X-MC-Unique: xXkhVmbBN16ANoNW0OvGkQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 689E6101AA45; Thu, 25 Aug 2022 16:47:09 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.192.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF705492CA2; Thu, 25 Aug 2022 16:47:06 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Mel Gorman , Jason Gunthorpe , John Hubbard , "Matthew Wilcox (Oracle)" , Andrea Arcangeli , Hugh Dickins , Peter Xu Subject: [PATCH v1 2/3] mm/gup: use gup_can_follow_protnone() also in GUP-fast Date: Thu, 25 Aug 2022 18:46:58 +0200 Message-Id: <20220825164659.89824-3-david@redhat.com> In-Reply-To: <20220825164659.89824-1-david@redhat.com> References: <20220825164659.89824-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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, 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 There seems to be no reason why FOLL_FORCE during GUP-fast would have to fallback to the slow path when stumbling over a PROT_NONE mapped page. We only have to trigger hinting faults in case FOLL_FORCE is not set, and any kind of fault handling naturally happens from the slow path -- where NUMA hinting accounting/handling would be performed. Note that the comment regarding THP migration is outdated: commit 2b4847e73004 ("mm: numa: serialise parallel get_user_page against THP migration") described that this was required for THP due to lack of PMD migration entries. Nowadays, we do have proper PMD migration entries in place -- see set_pmd_migration_entry(), which does a proper pmdp_invalidate() when placing the migration entry. So let's just reuse gup_can_follow_protnone() here to make it consistent and drop the somewhat outdated comments. Signed-off-by: David Hildenbrand --- mm/gup.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index a1355dbd848e..dfef23071dc8 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2350,11 +2350,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, struct page *page; struct folio *folio; - /* - * Similar to the PMD case below, NUMA hinting must take slow - * path using the pte_protnone check. - */ - if (pte_protnone(pte)) + if (pte_protnone(pte) && !gup_can_follow_protnone(flags)) goto pte_unmap; if (!pte_access_permitted(pte, flags & FOLL_WRITE)) @@ -2736,12 +2732,8 @@ static int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned lo if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) || pmd_devmap(pmd))) { - /* - * NUMA hinting faults need to be handled in the GUP - * slowpath for accounting purposes and so that they - * can be serialised against THP migration. - */ - if (pmd_protnone(pmd)) + if (pmd_protnone(pmd) && + !gup_can_follow_protnone(flags)) return 0; if (!gup_huge_pmd(pmd, pmdp, addr, next, flags, -- 2.37.1