Message ID | 20231219075538.414708-7-peterx@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-4840-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1778721dyi; Mon, 18 Dec 2023 23:58:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQhqKvE9Ehnf8NmK4A8PvjZ9dcsfomcFPxRTS5lBRb7K+iLDmOzToHF66pgXifelZCPSho X-Received: by 2002:a05:620a:11a6:b0:780:dde7:43d7 with SMTP id c6-20020a05620a11a600b00780dde743d7mr4120951qkk.59.1702972692140; Mon, 18 Dec 2023 23:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702972692; cv=none; d=google.com; s=arc-20160816; b=MnfhUmGJEBWOhgALO30GTrjvhKTFSz+RRmbeKgYnUjDXwqbP0WroI7Ac8PoWCOsLON PbJOD0iaVU9EValernVRl8uRxNGdoA8gviCQZHIbZ6shfgUeEr+7OUh8wsRHHoZ/uuaR 7tzNjVbkdnMax3FN3pbsprL2RERF9N7F4GtMZ2t0Myvhs7sCCPIY2XBPZsAa1Uz71fmS X0XktBZVG++NHYwK5SMjtLhmj+xUTlYyHV2QTjxnxnTOy3gHf+jqL3OzoKdBIHcvdLMY HWAfIskY7aJpM3xLMiP0dUJ+nFTq2OD4F5a+tQC8Oj7kfbuUz/U6EDQWI/dLC0vpDmQx ocwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uyBT0nqGKaQsvTTr5mCIJmcBkZIho6YT9IXUJI5Nmzw=; fh=3mpu6Yyr5hMzDKtkQvzcApl7ZSQGU4G8QyIY2BAU7VY=; b=vkeNbStwRox6k6LPKMEyzfk4V8kfoPXe7o24sr8V9ur7tdnwC16HgVesPbKj8TpsfF zltVQXPebfbM+KxN7n4aA+mdfZ6GDOAKxatT2VNw/DbWz7fO4AemELW3Feemu2l/BVyE gf0Yi3znzBwTDly4yjsdWoMAn/ra4PXSOtv0/VUftqrKCH8iY0vAFvkiN4khCAAVeDKb o67kew/ivfY91K/llDaZtAYgnh1bcC9DvLuqyXMYg9iITNi848SkHCWPfgzhl3VaOIKg 48KpHziT9uds/UBfP7SD5XI3nRFW/lLUvpTkNVAdBZiUPJmwH74db4r140iD6knhy8/7 o6Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NkviQZc1; spf=pass (google.com: domain of linux-kernel+bounces-4840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4840-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u15-20020a05620a430f00b0077d6a185ca5si19503748qko.683.2023.12.18.23.58.12 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 23:58:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NkviQZc1; spf=pass (google.com: domain of linux-kernel+bounces-4840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4840-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E493F1C23877 for <ouuuleilei@gmail.com>; Tue, 19 Dec 2023 07:58:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6589F1944E; Tue, 19 Dec 2023 07:57:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NkviQZc1" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9060718E10 for <linux-kernel@vger.kernel.org>; Tue, 19 Dec 2023 07:57:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702972629; 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=uyBT0nqGKaQsvTTr5mCIJmcBkZIho6YT9IXUJI5Nmzw=; b=NkviQZc12NmMFj4HgvIl2cAmddrWkG9ee0wuSQYz1ZfZcEPG/W4lyvV5qIxX8BaJmG/QjY YG/pse4Nc5vOwf+d1/mwZN2vBnPcHgKJowD9zvjc1AuyGqyz+FnySk5VSCZtY+aIGpeCAS e4mFA7rm15Uji9Khdq9uL+/XCRrdxPs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-150-L9GGlqWjOR6XdFWT616TOg-1; Tue, 19 Dec 2023 02:57:06 -0500 X-MC-Unique: L9GGlqWjOR6XdFWT616TOg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E4B5F3813F20; Tue, 19 Dec 2023 07:57:04 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAA8A2026D66; Tue, 19 Dec 2023 07:56:53 +0000 (UTC) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox <willy@infradead.org>, Christophe Leroy <christophe.leroy@csgroup.eu>, Lorenzo Stoakes <lstoakes@gmail.com>, David Hildenbrand <david@redhat.com>, Vlastimil Babka <vbabka@suse.cz>, Mike Kravetz <mike.kravetz@oracle.com>, Mike Rapoport <rppt@kernel.org>, Christoph Hellwig <hch@infradead.org>, John Hubbard <jhubbard@nvidia.com>, Andrew Jones <andrew.jones@linux.dev>, linux-arm-kernel@lists.infradead.org, Michael Ellerman <mpe@ellerman.id.au>, "Kirill A . Shutemov" <kirill@shutemov.name>, linuxppc-dev@lists.ozlabs.org, Rik van Riel <riel@surriel.com>, linux-riscv@lists.infradead.org, Yang Shi <shy828301@gmail.com>, James Houghton <jthoughton@google.com>, "Aneesh Kumar K . V" <aneesh.kumar@kernel.org>, Andrew Morton <akpm@linux-foundation.org>, Jason Gunthorpe <jgg@nvidia.com>, Andrea Arcangeli <aarcange@redhat.com>, peterx@redhat.com, Axel Rasmussen <axelrasmussen@google.com> Subject: [PATCH 06/13] mm/gup: Drop folio_fast_pin_allowed() in hugepd processing Date: Tue, 19 Dec 2023 15:55:31 +0800 Message-ID: <20231219075538.414708-7-peterx@redhat.com> In-Reply-To: <20231219075538.414708-1-peterx@redhat.com> References: <20231219075538.414708-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785696293724138393 X-GMAIL-MSGID: 1785696293724138393 |
Series |
mm/gup: Unify hugetlb, part 2
|
|
Commit Message
Peter Xu
Dec. 19, 2023, 7:55 a.m. UTC
From: Peter Xu <peterx@redhat.com> Hugepd format for GUP is only used in PowerPC with hugetlbfs. There are some kernel usage of hugepd (can refer to hugepd_populate_kernel() for PPC_8XX), however those pages are not candidates for GUP. Commit a6e79df92e4a ("mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings") added a check to fail gup-fast if there's potential risk of violating GUP over writeback file systems. That should never apply to hugepd. Considering that hugepd is an old format (and even software-only), there's no plan to extend hugepd into other file typed memories that is prone to the same issue. Drop that check, not only because it'll never be true for hugepd per any known plan, but also it paves way for reusing the function outside fast-gup. To make sure we'll still remember this issue just in case hugepd will be extended to support non-hugetlbfs memories, add a rich comment above gup_huge_pd(), explaining the issue with proper references. Cc: Christoph Hellwig <hch@infradead.org> Cc: Lorenzo Stoakes <lstoakes@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Peter Xu <peterx@redhat.com> --- mm/gup.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c index efc9847e58fb..bb5b7134f10b 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2820,11 +2820,6 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, return 0; } - if (!folio_fast_pin_allowed(folio, flags)) { - gup_put_folio(folio, refs, flags); - return 0; - } - if (!pte_write(pte) && gup_must_unshare(NULL, flags, &folio->page)) { gup_put_folio(folio, refs, flags); return 0; @@ -2835,6 +2830,14 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, return 1; } +/* + * NOTE: currently GUP for a hugepd is only possible on hugetlbfs file + * systems on Power, which does not have issue with folio writeback against + * GUP updates. When hugepd will be extended to support non-hugetlbfs or + * even anonymous memory, we need to do extra check as what we do with most + * of the other folios. See writable_file_mapping_allowed() and + * folio_fast_pin_allowed() for more information. + */ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, unsigned int pdshift, unsigned long end, unsigned int flags, struct page **pages, int *nr)