Message ID | 20231219075538.414708-6-peterx@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-4839-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1783328dyi; Tue, 19 Dec 2023 00:07:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwZrHKsFbkpAtegQHlR52yMaLhQc7aRWPY8s+qHBUSvKWZnlka5DRxoCvKSZ7Z8Fdgr+ME X-Received: by 2002:a17:907:a0c6:b0:a17:ab92:3d55 with SMTP id hw6-20020a170907a0c600b00a17ab923d55mr10265950ejc.19.1702973270262; Tue, 19 Dec 2023 00:07:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702973270; cv=none; d=google.com; s=arc-20160816; b=opSTXhnseJkOHImcikil32pDY62/SojxLrChzYufR1tmudGJX3sF5Nin3q/O8Fatkm PpKx9rbhAS92EvoKGrvOpt1P2G8ySbNEq84GCkLNwz/1TdWcddqQ8ZAET4CMswGD1x8L cxWHKqJ8DS14D2VosvdeLF90dm1R5Pkz8l3rYB8Jgn4bsIcrNXmQBz7wa3av5+6vMjY5 /rGhAGwR9O23tex56WjVTY1KA5wXLj+GxwxOJImeyeA47YgfLKlSmaJa6MELe7/anIhM kw1x3tHISfUm5CU3QOlb2H25vEhgOTaD1knEBELhE8qKKij2c8dwDMMu2QK3KQ/5HEXX bApg== 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=cOaAbTjD+sxL1nd4c8n1i5s+aCyb/VfpADXT9rdcjmA=; fh=3mpu6Yyr5hMzDKtkQvzcApl7ZSQGU4G8QyIY2BAU7VY=; b=yZhhaXGZ0S7BjSqYobtufL+hAQqv9KGtaRe3zj/CHvwm5SOvEA27RotQBmXSbDJ7ck hGRXWI2KbMDseevI9yni/qiWQri+5gc+tCRe/ZQttDDnZbgVnRtxi96ELKof44rhDrQ9 3Q0FkG1/VxbffbVkNFJJ4tkZG2w1aOuhZoAqiFJvXsNuq3Q+vFaJPfvL92avnhqDd37l 3VV0DgHsTpIsimd0mj0JY2TzJH98wi0Q6ywaLEBYfEy9ODymWsMCk94H/mhiRA1HSPET 0MGEXe82n7d0yaF1PjsfGXtJ0lIIA9odTpAu1UkyB9syQ4h5YxAznTwVl1wQrRE3jyLD mUQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=I33wxrN3; spf=pass (google.com: domain of linux-kernel+bounces-4839-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4839-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s21-20020a1709066c9500b00a236d3072e5si733862ejr.984.2023.12.19.00.07.50 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 00:07:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4839-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=I33wxrN3; spf=pass (google.com: domain of linux-kernel+bounces-4839-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4839-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 55AB41F2695A for <ouuuleilei@gmail.com>; Tue, 19 Dec 2023 07:57:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F1061865C; Tue, 19 Dec 2023 07:57:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I33wxrN3" 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 216EB168CB for <linux-kernel@vger.kernel.org>; Tue, 19 Dec 2023 07:57:00 +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=1702972620; 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=cOaAbTjD+sxL1nd4c8n1i5s+aCyb/VfpADXT9rdcjmA=; b=I33wxrN3O9vPCiFjlesq0j6PIBNMuraGIScTkbYbvD126LJOerl7Qbv7lyJXAobbriJ5b2 PJE1iXoe277NG5Ay6Jh2t0hOd/pApRLH1V9Tj4fRgUEdtP4kZ+fKXS2veBY3VgWWGbNjpD kfNn/JDYU/BfLh5ML/ltkLYD4M7hhs4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-DMz-Hx_eOQmrxyRviaVqjQ-1; Tue, 19 Dec 2023 02:56:54 -0500 X-MC-Unique: DMz-Hx_eOQmrxyRviaVqjQ-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 26A2183B8E7; Tue, 19 Dec 2023 07:56:53 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFE972026F95; Tue, 19 Dec 2023 07:56:40 +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 05/13] mm: Introduce vma_pgtable_walk_{begin|end}() Date: Tue, 19 Dec 2023 15:55:30 +0800 Message-ID: <20231219075538.414708-6-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: 1785696899587422617 X-GMAIL-MSGID: 1785696899587422617 |
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> Introduce per-vma begin()/end() helpers for pgtable walks. This is a preparation work to merge hugetlb pgtable walkers with generic mm. The helpers need to be called before and after a pgtable walk, will start to be needed if the pgtable walker code supports hugetlb pages. It's a hook point for any type of VMA, but for now only hugetlb uses it to stablize the pgtable pages from getting away (due to possible pmd unsharing). Reviewed-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Peter Xu <peterx@redhat.com> --- include/linux/mm.h | 3 +++ mm/memory.c | 12 ++++++++++++ 2 files changed, 15 insertions(+)
Comments
> On Dec 19, 2023, at 15:55, peterx@redhat.com wrote: > > From: Peter Xu <peterx@redhat.com> > > Introduce per-vma begin()/end() helpers for pgtable walks. This is a > preparation work to merge hugetlb pgtable walkers with generic mm. > > The helpers need to be called before and after a pgtable walk, will start > to be needed if the pgtable walker code supports hugetlb pages. It's a > hook point for any type of VMA, but for now only hugetlb uses it to > stablize the pgtable pages from getting away (due to possible pmd > unsharing). > > Reviewed-by: Christoph Hellwig <hch@infradead.org> > Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com> Thanks.
On Mon, Dec 25, 2023 at 02:34:48PM +0800, Muchun Song wrote:
> Reviewed-by: Muchun Song <songmuchun@bytedance.com>
You're using the old email address here. Do you want me to also use the
linux.dev one that you suggested me to use?
> On Jan 2, 2024, at 13:39, Peter Xu <peterx@redhat.com> wrote: > > On Mon, Dec 25, 2023 at 02:34:48PM +0800, Muchun Song wrote: >> Reviewed-by: Muchun Song <songmuchun@bytedance.com> > > You're using the old email address here. Do you want me to also use the > linux.dev one that you suggested me to use? Either is OK for the RB tag. > > -- > Peter Xu >
diff --git a/include/linux/mm.h b/include/linux/mm.h index b72bf25a45cf..85e43775824b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4181,4 +4181,7 @@ static inline bool pfn_is_unaccepted_memory(unsigned long pfn) return range_contains_unaccepted_memory(paddr, paddr + PAGE_SIZE); } +void vma_pgtable_walk_begin(struct vm_area_struct *vma); +void vma_pgtable_walk_end(struct vm_area_struct *vma); + #endif /* _LINUX_MM_H */ diff --git a/mm/memory.c b/mm/memory.c index 1795aba53cf5..9ac6a9db971e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -6270,3 +6270,15 @@ void ptlock_free(struct ptdesc *ptdesc) kmem_cache_free(page_ptl_cachep, ptdesc->ptl); } #endif + +void vma_pgtable_walk_begin(struct vm_area_struct *vma) +{ + if (is_vm_hugetlb_page(vma)) + hugetlb_vma_lock_read(vma); +} + +void vma_pgtable_walk_end(struct vm_area_struct *vma) +{ + if (is_vm_hugetlb_page(vma)) + hugetlb_vma_unlock_read(vma); +}