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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2FADECAA24 for ; Thu, 25 Aug 2022 16:47:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 773756B0075; Thu, 25 Aug 2022 12:47:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 723316B0078; Thu, 25 Aug 2022 12:47:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 612636B007B; Thu, 25 Aug 2022 12:47:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 552976B0075 for ; Thu, 25 Aug 2022 12:47:16 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 213EE81D71 for ; Thu, 25 Aug 2022 16:47:16 +0000 (UTC) X-FDA: 79838695272.01.EDA6C13 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id BD97340005 for ; Thu, 25 Aug 2022 16:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661446035; 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=Ik3dAbyBP3eRILyW5gQW835KPNr9Plws4D+AQFrWR4ok0081uAZPeDyfjgU0cp8S5q0y6u fwKpAVmlZhBpA+SR0fwdclz0nILPH19dMSeUK9bUv4NBetUvTvGCA6PjFzNdNC1+9y+r/Q T+vwMa3dRL/p+kN+DWOVI3l93o9isEE= 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 ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ik3dAbyB; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661446035; a=rsa-sha256; cv=none; b=qqcnR+2jTUoP9lajQ6F1DiKXNqfFo9PzZZwG3Iu/Vn0x+u3f9JdUlFzk1HtdTcpWYAoD8j s782NLanoMerSf85oAVSSz30waJ9xDdyCwWKogDkBt3uBMWQ3t4zYM5+xHx+lhMNSxY89i zwlVPAg+TAFaRjz4jb8L4pPd5Dqk4+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661446035; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Q3NPvWyh2xRtoYXHMmyrsAAtGbzTeyv985JIMuXJIb4=; b=oG4PiPF+a6F6louh2y/hd+yeeuHpm/joXPN8OkEr4fg2hSGvJnSZP1rcRU8394wUOBJGa2 VzR1V/P5UlVRHJLMbaPpO4m78b9t+HfaGuTwKlGJvckXl4gTIj7hyFS8SBUvvu+TgsaOL+ t7AGk65KimCrkf801UAJnTG+GXEGKgg= Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ik3dAbyB; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Stat-Signature: 13izr6x6dtkqhkqpa15ibr6gtjzgxgj7 X-Rspamd-Queue-Id: BD97340005 X-Rspamd-Server: rspam04 X-HE-Tag: 1661446035-592427 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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