Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp764667lqp; Thu, 21 Mar 2024 15:09:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXZMuPszjLNsvFys0vzjswXz0GnTYlArLNc2jZitAnS1192pgk134fOQNgfUOVzuIx+nah8gTa4OWa8jM/yZxKYstcQNbv+fTWZyqjQQ== X-Google-Smtp-Source: AGHT+IEm6BTHV7l/znmw9pfj7qNtg9zcgguaAgdwLrCS7uSsPZBZg5rV9T/IGlJolASIW3jQw3mV X-Received: by 2002:a19:3859:0:b0:513:ca65:8c58 with SMTP id d25-20020a193859000000b00513ca658c58mr396945lfj.43.1711058947595; Thu, 21 Mar 2024 15:09:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711058947; cv=pass; d=google.com; s=arc-20160816; b=P21dAtMhHpHIx6ejY2XVtIqvS1MbaU30604Jt28co0+ElK0TueXXLlyKQzYF0lB6Tk pG6vYMk1YFgaCyOUuelaHDQwFdq8XgSskwLfmNfuxstd9DNJ22UnlrSwPCDGo3Bss9E3 R0jitARN1KlkCUYox+5JxzvlBXgGUj4DhdhsVz8J37wejTWD16J93tvTBCcL4reythjr yhLYSkSspeGFUsJYy/1WyREDkkSYk49Xs2rsQZ/Zq1lxD1O0XPvqOrryBI9WkPhI1dkM 3bwP/3RoZAnX8DjRd06WDH61vARxiutDy4FgVa4QRxfwTo+mN/QsV1bTFVz9Itw6aK7r mTbw== ARC-Message-Signature: i=2; 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=TwZ/C3Y+mq5srgVBOLaWiB530mwVuOVA1xifIUFcqIU=; fh=iem5wJT1XeTxv1ReOekYLZqQRz/OGJ7xaMLMNPh6L3g=; b=glTeZLC0/4/5GwzEgoVgtjqLi5++PtOohd3Y6BYtncrtIWVfTcMz51FiFxOhplpZyZ nExrn/LbNkBMtTwoaQA0sJMaIGN7Z3WQFy85eDMfSAk28JdVBlO+oxTsb08FqSElz/wD +OngFewivC48j6+LcUeYTJmW+MWz4PZw/eTxvRMVQ8JPzVf0YwI54TpWsD3jz7JEUqP2 +cTP3qyxhJc2TBrtQ1Haz6e56PaW9ByL8JBQKMrTGquV7A2iQN9yl6rMAMtzYVRphe+r DYPj7XP8kZMh3RdEv1Hr4b56wjr/GWhfGKAdZCq15w50XDuknjGU+K/KFUJlu0Xq/8ej tMUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gTEh77H6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-110730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y3-20020a17090629c300b00a4710db68a8si308215eje.281.2024.03.21.15.09.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 15:09:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gTEh77H6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-110730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110730-linux.lists.archive=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 215F01F22D3E for ; Thu, 21 Mar 2024 22:09:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F05B13776C; Thu, 21 Mar 2024 22:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gTEh77H6" 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 E53ED1369B7 for ; Thu, 21 Mar 2024 22:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711058897; cv=none; b=DbuEqZSuyvd3CCAqTB4JZzQxanMWDLJOUxJwbO/xCy2AU3KfrsDikblT7SPGx2rZIm/U5XeptVUhTaeIR/WrqF88BaXXUSTFfQc9CIavws0qXvSC2L1Id0lV5I5AVdp1/Sz0CerTr+Vspvunv1QWW6O7ob+4RCyMhEY1ybQRCOU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711058897; c=relaxed/simple; bh=Kixc0NMymkuIn9yHI5UxvEO7k03XXmYFgYWQVgrv4R8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FVp8jvOUyzOsJbYG+echIBtXKmU6WgwYgrnYRn0SlprV3II7tLiT0kb3HgRXBgx7uZ4RpAzsDWPESYufzRJAarK6soC0gRhdggQyIGvbbcP/YMgHulPJ/0uhN5sPGOPrlmBZGzHTtcD+MprnSn4f1aIsyaHRG3HKGqij60OYW5s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gTEh77H6; arc=none smtp.client-ip=170.10.133.124 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=1711058894; 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=TwZ/C3Y+mq5srgVBOLaWiB530mwVuOVA1xifIUFcqIU=; b=gTEh77H6jYYKjNin2pl2EQN1I/WTJRQ3NVBs2IHAsPBY4D/8nDnlJz9KZ2deWbQqpnN2Gw AVYjcvd6rFrvpv7yrw32BVLOgXiLs2/U66PxI8W8uw1ITRE/6R6VjW5bCKOuB0TmPS5+0r 6ED+ezhMv6m2u5/+gB2QqsDSR85iSlA= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-66-coX52MI6OLC2UDlMig_9DA-1; Thu, 21 Mar 2024 18:08:13 -0400 X-MC-Unique: coX52MI6OLC2UDlMig_9DA-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-430b4572a97so4829221cf.1 for ; Thu, 21 Mar 2024 15:08:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711058893; x=1711663693; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TwZ/C3Y+mq5srgVBOLaWiB530mwVuOVA1xifIUFcqIU=; b=Dnu4vgFl97Yfr6DMgdytKYQwPeSrIqftjwa1VvK5/Y0Cf0flYnPNzIdMgXJmG/PpU+ L9jIHTrIPoTmAUp/LCgcAfOo3T9FbXzT+8TAR3zh+DtSTBbOTOHrg6jAQJEtDWcZHm2h VACA20M/cNqS2glXEzGcV51Hq21hkWKq2/8JsUeDU9mGA5UaFGNQVguMmD+Ad4MLDkpF q4Hcz12FLJSxv26PWPWZtDpuOzKvIuUun4bommMnlDDHAi0GhPjeo4xtYu6w2ToFdr5K B4WSJ5k5QJAlrOGbMZtG5OShrwyJD9qunJWDRdJQNo7NntW89VsRbgcPZOpRJVw3L8UH B5dQ== X-Forwarded-Encrypted: i=1; AJvYcCXYu+3zb5Q/vES3OFSr/1a9LNKRY4/Y9g8JtPe6Jjwgd5JdvS4EwxNEuAFSbhjS/E310ZInWVWE15tVSc2b+22OKtjKVEIuSc9X4c/c X-Gm-Message-State: AOJu0Yw8qHfJeUYfhs3wpPPu47VQsnMPYOWsZ9XNNfZIYnaXatHl/TXf nMxL/qaqv89Q8Rg9qulOMhNyQiSjAbns2KFDUWm13VKX/pzIPyitSGRDdSiWBSPHRGet8oG8n1K 4XVwgm9sUsboo5x9pic+M7nsblmp6rfl5ycPgOWQc0s80mBxjdYRcbdh0vy507w== X-Received: by 2002:a05:6214:3f89:b0:690:c35c:7590 with SMTP id ow9-20020a0562143f8900b00690c35c7590mr218137qvb.2.1711058893171; Thu, 21 Mar 2024 15:08:13 -0700 (PDT) X-Received: by 2002:a05:6214:3f89:b0:690:c35c:7590 with SMTP id ow9-20020a0562143f8900b00690c35c7590mr218110qvb.2.1711058892727; Thu, 21 Mar 2024 15:08:12 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id o6-20020a0562140e4600b00690baf5cde9sm351663qvc.118.2024.03.21.15.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 15:08:12 -0700 (PDT) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Christophe Leroy , Matthew Wilcox , Rik van Riel , Lorenzo Stoakes , Axel Rasmussen , peterx@redhat.com, Yang Shi , John Hubbard , linux-arm-kernel@lists.infradead.org, "Kirill A . Shutemov" , Andrew Jones , Vlastimil Babka , Mike Rapoport , Andrew Morton , Muchun Song , Christoph Hellwig , linux-riscv@lists.infradead.org, James Houghton , David Hildenbrand , Jason Gunthorpe , Andrea Arcangeli , "Aneesh Kumar K . V" , Mike Kravetz Subject: [PATCH v3 04/12] mm: Introduce vma_pgtable_walk_{begin|end}() Date: Thu, 21 Mar 2024 18:07:54 -0400 Message-ID: <20240321220802.679544-5-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240321220802.679544-1-peterx@redhat.com> References: <20240321220802.679544-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Peter Xu 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 Reviewed-by: Muchun Song Signed-off-by: Peter Xu --- include/linux/mm.h | 3 +++ mm/memory.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 8147b1302413..d10eb89f4096 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4198,4 +4198,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 9bce1fa76dd7..4f2caf1c3c4d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -6438,3 +6438,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); +} -- 2.44.0