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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2B2ECD1280 for ; Wed, 27 Mar 2024 15:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ROzow6XucFkLMSr0dX/P9txY60787ucuVBPup2hF7uw=; b=sFvyigR2X7WWTN EUmcU5zQgt5XR17fDnbc+FA3ETc4x2AVsQMXR7Ul2icHOwLyy76+WkoRkZlo+ZDezvYxjOXc/Vwhq QK/K4lLcgGAoAGdRL1IbmERfNGWToMFsuJeKyicpkY9gmdBMQBPc4Ybs8K579ZE46Kkx5AGCFlnFg 6IMdyqypN9c/0tnXTtcs8Ds8kEc+9lvYkHbCvIv1JS3nQT6AD5AE6tnHQtzKVla0B7GXATHQY1B9Y /NviABt1w9GKjoiDnnFiG0gzGniutBtFnluiGadUTGrfSYWarBuGn1uuqkiN8ItSKmO8bZH6iE/rJ eSaoQKXBuAt9qpspuPRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpV8S-00000009lhR-2iMl; Wed, 27 Mar 2024 15:24:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpV84-00000009lMa-1ram for linux-riscv@bombadil.infradead.org; Wed, 27 Mar 2024 15:23:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=rDQo7ngeFL6dXnYlJ/hTQ6s7Sw Pjcy8ufQkpzoKe53+t6qqhmL2GmR+NebLU4bq/AIcq/lMmrIvgRusEFyg+JZtStCb1m9pbIzkbHra BQfywIhxnFLn+Cue9Iud19DwtFkq2esNmcOfAk5APzQ4NaFjt2xEC5Wj3oQGLCA/PRREyWPu41IpH gAYtnzBuuMDF1BuWzWMfEFuzyk5EArBh/My2OqlSDcclpBvtgEhBXll9RWKFpI/LrQG4MC+jIVoOY wiW+8cuKuahhUyKHDMCXYEIVVHE3HjWu2avXR3ZeOxLLH/mGfi4sw9gEKrvwM64qd4EkZ0asfJH4V gfIsPr6A==; Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpV80-00000000KzI-0X7U for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 15:23:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711553026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=E0m8c0g4mMcVpRGlZq3lof8PUsb6a7CeiZTHQhuS5Deitn7B3/6mUZJkHOYFCUK5u+VK8+ gNN6+/+fKJNfKjNqYJK5MxZmuIg9GV3UiDZOtn60DpbXqKNYof4bF4TwhtAtI1wpHO5vdF hbduVgMnvApSArxYYTzzbQDAGnIHV8k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711553027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=YoUFMiqFRQwhob84m5cE7rl4ymoqHhlX4EDmjLX6XYrePEOIIbfmCh/MAOwdaYeQHBYR+R zahoAgoWPVh3bqDzBgpodsIDqI1r7v4l2TP9JFH8fqbyuDel/wgMjx+Yz4rmFKVIbWqbHw hXtPSMsy4uouiL7XlpLU7jvFHIs5uZE= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-507-uFmadyJ3Ne2S53oZu8wyjQ-1; Wed, 27 Mar 2024 11:23:45 -0400 X-MC-Unique: uFmadyJ3Ne2S53oZu8wyjQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-69152af7760so25772506d6.1 for ; Wed, 27 Mar 2024 08:23:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711553025; x=1712157825; 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=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=tavU+Z/waR9t7o/ZO8sBKGFbzJGNTI1lJoKee/qYX16WpZU7lMNegW7tGbUu01FQMP Mhb3flCXYj09YO+19m0hlPuFdKdvK1kaZbAmeLrZBcNgOul0m6k3jMEQ3AG53EqlctPI faJBjXki8JUYemifCvJbs0patXUfOc9JPc8otxo/bZWpPHG47hCAGBG+e5Orliyo/r+V eZhxBbqCvEg115qUb5c+hWVLls5hkYsgGuorvAuQDZuaKMahM/21DEDwbcx7sivCCaBf VHdezmXmRU4RvrTonBen1t8DTqfjtVXo8+EfgIHWXimDj30N+3j5UT9S7LDoqZR/GyfI MCwA== X-Forwarded-Encrypted: i=1; AJvYcCUGMzlGQj/mS0UWmJv9/HLxG7wuVi/QPrymZjNF1tX3dLsPXKyz12XWzMSBImIaJxUSew/B22NiHtap6PNb5WUhKLU60tm9wxiUdyvs25Vk X-Gm-Message-State: AOJu0YxMa2vnnsAQrJOlbPtdsC1FWSNjmotyhWBRuDf8PzJY1IZcdI5J hFs2xE1MYb1UpNclyWP6XOeiYH4ws3slDSBsxtDm3VeT9B+BqccRI9bKvmaaZnx60uIRDPFvZnh nfkjtKafQ0Xs6QDc9p9nj4UBfAhmSTMa9PheirGKBcHEhr1xOBbiA74Zbs+upoFXZtw== X-Received: by 2002:a05:6214:4598:b0:696:7b32:cceb with SMTP id op24-20020a056214459800b006967b32ccebmr13869561qvb.6.1711553024696; Wed, 27 Mar 2024 08:23:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFS0Dr3UNRPnI4el/D5x8gcrtCXLMsQwIvd4dOzHJoXuoNg03xhCSCfsu9VpmJMAiYn3G+95A== X-Received: by 2002:a05:6214:4598:b0:696:7b32:cceb with SMTP id op24-20020a056214459800b006967b32ccebmr13869513qvb.6.1711553024070; Wed, 27 Mar 2024 08:23:44 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hu4-20020a056214234400b00690dd47a41csm6412639qvb.86.2024.03.27.08.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:23:43 -0700 (PDT) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Yang Shi , "Kirill A . Shutemov" , Mike Kravetz , John Hubbard , Michael Ellerman , peterx@redhat.com, Andrew Jones , Muchun Song , linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , Christoph Hellwig , Lorenzo Stoakes , Matthew Wilcox , Rik van Riel , linux-arm-kernel@lists.infradead.org, Andrea Arcangeli , David Hildenbrand , "Aneesh Kumar K . V" , Vlastimil Babka , James Houghton , Jason Gunthorpe , Mike Rapoport , Axel Rasmussen Subject: [PATCH v4 04/13] mm: Introduce vma_pgtable_walk_{begin|end}() Date: Wed, 27 Mar 2024 11:23:23 -0400 Message-ID: <20240327152332.950956-5-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327152332.950956-1-peterx@redhat.com> References: <20240327152332.950956-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_152348_383958_295A1C45 X-CRM114-Status: GOOD ( 11.30 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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 afe27ff3fa94..d8f78017d271 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4233,4 +4233,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 3d0c0cc33c57..27d173f9a521 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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E12EC54E67 for ; Wed, 27 Mar 2024 15:27:20 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YoUFMiqF; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YoUFMiqF; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4V4VsL5J6Tz3vrt for ; Thu, 28 Mar 2024 02:27:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YoUFMiqF; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YoUFMiqF; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=peterx@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 lists.ozlabs.org (Postfix) with ESMTPS id 4V4VnL16frz3vYX for ; Thu, 28 Mar 2024 02:23:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711553027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=YoUFMiqFRQwhob84m5cE7rl4ymoqHhlX4EDmjLX6XYrePEOIIbfmCh/MAOwdaYeQHBYR+R zahoAgoWPVh3bqDzBgpodsIDqI1r7v4l2TP9JFH8fqbyuDel/wgMjx+Yz4rmFKVIbWqbHw hXtPSMsy4uouiL7XlpLU7jvFHIs5uZE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711553027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=YoUFMiqFRQwhob84m5cE7rl4ymoqHhlX4EDmjLX6XYrePEOIIbfmCh/MAOwdaYeQHBYR+R zahoAgoWPVh3bqDzBgpodsIDqI1r7v4l2TP9JFH8fqbyuDel/wgMjx+Yz4rmFKVIbWqbHw hXtPSMsy4uouiL7XlpLU7jvFHIs5uZE= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-XbcEmYQHOVie1qLx1N32LQ-1; Wed, 27 Mar 2024 11:23:45 -0400 X-MC-Unique: XbcEmYQHOVie1qLx1N32LQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-696a9c482a4so3595806d6.0 for ; Wed, 27 Mar 2024 08:23:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711553025; x=1712157825; 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=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=ZJiJSk6VIjW25maVIDy1qoaIOrNdbuMmESRKvUMJwb8laO4UewEPnzRu0Fg/x4We8X iQx0vSKCtWq/dkdzWL+zfEYeqPuPCPnKypqSd5xpGyK/nMe9dUS4MWFxxIGAlvDhgrBB jjJH83kfq8UXxlEXZ5dW18h7ueFx7gueYj2lcXTON2tI5CVQ3JmjfPFs318pRbXZ1zIc lekNCwqOg7bb4lRGQeMXRrP3fmtVg8ds8Y5eB+GqskGq3AMluMm4lKTBIHwfl1ZGTmfm vdknfkDuh9chRlEK79sRacI3XsvMT2aL8UEOV6PQrrVKnhEYU2bSSdugLhdxZYzMnlHq fV2Q== X-Forwarded-Encrypted: i=1; AJvYcCUE+qhUgLIS7uT2nkVj3K96QBik4013+IMh/ZBcoWBheFqfNjukfmU6Ff3RqgPwFRxCGN6MJSViXnebTCwOoD4CwGEJcOuALYjivoUPIA== X-Gm-Message-State: AOJu0Yxc8vdseyoGkHTSZRZGqzcsuz4pLYOPW2Y9/ba5eBgzXn1m262x tCRvwDO5Wdlz7gVHYdTV5Zt3yQqH7cBZR+UepGaGJTk+j1RzAcPC8jFYumUIJ7ee5/8SsnB3HHL a+J9sfVJifiTNESOzIsiAU0KZnmf0nWPFr7Cv7Wvpk2On4TqQfpGDVYUPUXlo/Tk= X-Received: by 2002:a05:6214:4598:b0:696:7b32:cceb with SMTP id op24-20020a056214459800b006967b32ccebmr13869546qvb.6.1711553024672; Wed, 27 Mar 2024 08:23:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFS0Dr3UNRPnI4el/D5x8gcrtCXLMsQwIvd4dOzHJoXuoNg03xhCSCfsu9VpmJMAiYn3G+95A== X-Received: by 2002:a05:6214:4598:b0:696:7b32:cceb with SMTP id op24-20020a056214459800b006967b32ccebmr13869513qvb.6.1711553024070; Wed, 27 Mar 2024 08:23:44 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hu4-20020a056214234400b00690dd47a41csm6412639qvb.86.2024.03.27.08.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:23:43 -0700 (PDT) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/13] mm: Introduce vma_pgtable_walk_{begin|end}() Date: Wed, 27 Mar 2024 11:23:23 -0400 Message-ID: <20240327152332.950956-5-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327152332.950956-1-peterx@redhat.com> References: <20240327152332.950956-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Houghton , David Hildenbrand , Yang Shi , peterx@redhat.com, Andrew Jones , linux-riscv@lists.infradead.org, Andrea Arcangeli , Christoph Hellwig , Matthew Wilcox , "Aneesh Kumar K . V" , linux-arm-kernel@lists.infradead.org, Jason Gunthorpe , Axel Rasmussen , Rik van Riel , John Hubbard , "Kirill A . Shutemov" , Vlastimil Babka , Lorenzo Stoakes , Muchun Song , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Mike Rapoport , Mike Kravetz Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 afe27ff3fa94..d8f78017d271 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4233,4 +4233,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 3d0c0cc33c57..27d173f9a521 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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A06A6C54E67 for ; Wed, 27 Mar 2024 15:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qTrH4Mp15l+ROmvYeS750aQTjtqy9o4A7c5q9RWjV9g=; b=AOShJvuTtorEkK t2DZe1CD7cpOUpeOkHlOrRguiCPCNByC0E9A5vS4fnjmHu5qgeIHxelQcxDvW7B77kzNRkha0Zwxq c+7arkmAQanNiugnGhiKbDsmoCbrfmLrgrOdYyIsAn86yxv7WWh5SeA/+W18BUzazHcrd0hyBmvpD 37OmULnXZOm63rtI59teJA/wQuKC4LBWBnYJ49TgoOEBXDFxwQHo+VLegvIuBdyimAzESp+izRxkg iOu7lhZXqEGazCPWP3Ryki9Lm95MaczKjl519Eq5QpjCRfbEVgzhOFxD2u7RNM4+Ilm5rephgwUdt UTI0Ys+DWUVMqjjaJGYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpVB6-00000009nF8-3Bms; Wed, 27 Mar 2024 15:27:00 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpV84-00000009lMX-1VkS for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 15:23:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=rDQo7ngeFL6dXnYlJ/hTQ6s7Sw Pjcy8ufQkpzoKe53+t6qqhmL2GmR+NebLU4bq/AIcq/lMmrIvgRusEFyg+JZtStCb1m9pbIzkbHra BQfywIhxnFLn+Cue9Iud19DwtFkq2esNmcOfAk5APzQ4NaFjt2xEC5Wj3oQGLCA/PRREyWPu41IpH gAYtnzBuuMDF1BuWzWMfEFuzyk5EArBh/My2OqlSDcclpBvtgEhBXll9RWKFpI/LrQG4MC+jIVoOY wiW+8cuKuahhUyKHDMCXYEIVVHE3HjWu2avXR3ZeOxLLH/mGfi4sw9gEKrvwM64qd4EkZ0asfJH4V gfIsPr6A==; Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpV7z-00000000KzF-3vQA for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 15:23:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711553026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=E0m8c0g4mMcVpRGlZq3lof8PUsb6a7CeiZTHQhuS5Deitn7B3/6mUZJkHOYFCUK5u+VK8+ gNN6+/+fKJNfKjNqYJK5MxZmuIg9GV3UiDZOtn60DpbXqKNYof4bF4TwhtAtI1wpHO5vdF hbduVgMnvApSArxYYTzzbQDAGnIHV8k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711553027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=YoUFMiqFRQwhob84m5cE7rl4ymoqHhlX4EDmjLX6XYrePEOIIbfmCh/MAOwdaYeQHBYR+R zahoAgoWPVh3bqDzBgpodsIDqI1r7v4l2TP9JFH8fqbyuDel/wgMjx+Yz4rmFKVIbWqbHw hXtPSMsy4uouiL7XlpLU7jvFHIs5uZE= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-xvzDmXT3NJSZnIsuwvaUfw-1; Wed, 27 Mar 2024 11:23:45 -0400 X-MC-Unique: xvzDmXT3NJSZnIsuwvaUfw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-696a9c482a4so3595846d6.0 for ; Wed, 27 Mar 2024 08:23:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711553025; x=1712157825; 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=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=poHZfHxFIJBv93Ql3oAE15/hLnpPFN6vUrjeSRPXxRCwqEBe0G+un7hekiYk+G3v51 etLyXeecW2FufJnTuZIZbp6oah1518E9ZzQk5k/WJ4y4Z2K+n+3zrRzUNdCjb7SOWyka veWaNtdSY56xON5/owgkDyVWrVo678tZ4KMYJAGiZybJ1tXIicD1J5tKSHKX67YszKEm 2WDJ8pwWGwUnb8bscReEFQ3fY9WasL3f7dZe4Locp+pTvLZWy+z1Bj6tVOWgYuTMi4n9 mPPBK/wfNbDW26ujy6YixALHiSZvZl4f47F7Ads3Yd1d6FbwptTGI0bh1HPrgxDkWi56 QgWQ== X-Forwarded-Encrypted: i=1; AJvYcCXPYLOF5JHedGAiUWTq4xk21cp8ho0TyRgwDesDxB9pgVFz9WvbQeZiP4t1Gn4tvlhoDtLtCvrjHUTFngDJh6OSYE3vz95Vxm8F7SaZr6y2puDHqCA= X-Gm-Message-State: AOJu0YyR/RHuhPLydRGuUuKgsIEd5fQ4Z9tqcFox3JenwLbIX+zMIvMA bc8jQUTL7fFbj7OrvLOz+yvebT6Ru3oIzLVF1Z9dISPXngZIhJ/oI0qWDKgQJRh5UK9r3DQ8r9z CJq3M9tMD5yMqlF/AaFRDtuFpHalBOmTUq7X7uwbTUDPO6erMP8xq7UmoA7lVqOszu/ttdEn6 X-Received: by 2002:a05:6214:4598:b0:696:7b32:cceb with SMTP id op24-20020a056214459800b006967b32ccebmr13869548qvb.6.1711553024684; Wed, 27 Mar 2024 08:23:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFS0Dr3UNRPnI4el/D5x8gcrtCXLMsQwIvd4dOzHJoXuoNg03xhCSCfsu9VpmJMAiYn3G+95A== X-Received: by 2002:a05:6214:4598:b0:696:7b32:cceb with SMTP id op24-20020a056214459800b006967b32ccebmr13869513qvb.6.1711553024070; Wed, 27 Mar 2024 08:23:44 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hu4-20020a056214234400b00690dd47a41csm6412639qvb.86.2024.03.27.08.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:23:43 -0700 (PDT) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Yang Shi , "Kirill A . Shutemov" , Mike Kravetz , John Hubbard , Michael Ellerman , peterx@redhat.com, Andrew Jones , Muchun Song , linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , Christoph Hellwig , Lorenzo Stoakes , Matthew Wilcox , Rik van Riel , linux-arm-kernel@lists.infradead.org, Andrea Arcangeli , David Hildenbrand , "Aneesh Kumar K . V" , Vlastimil Babka , James Houghton , Jason Gunthorpe , Mike Rapoport , Axel Rasmussen Subject: [PATCH v4 04/13] mm: Introduce vma_pgtable_walk_{begin|end}() Date: Wed, 27 Mar 2024 11:23:23 -0400 Message-ID: <20240327152332.950956-5-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327152332.950956-1-peterx@redhat.com> References: <20240327152332.950956-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_152348_222418_C15E1ED2 X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 afe27ff3fa94..d8f78017d271 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4233,4 +4233,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 3d0c0cc33c57..27d173f9a521 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 00EF7CD1280 for ; Wed, 27 Mar 2024 15:24:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8B0A6B009F; Wed, 27 Mar 2024 11:23:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E35906B00A0; Wed, 27 Mar 2024 11:23:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8A276B00A1; Wed, 27 Mar 2024 11:23:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A60D56B009F for ; Wed, 27 Mar 2024 11:23:59 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3B91B1A0DD4 for ; Wed, 27 Mar 2024 15:23:59 +0000 (UTC) X-FDA: 81943189398.24.2EEDA3B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 151A14001A for ; Wed, 27 Mar 2024 15:23:56 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OzgduuCE; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711553037; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=Y81U8eHhLibXGIGvaeFo5LLoANECbqQSQCcu7gIE+XIfb0HiHdj3+WkGyeGis83gW53ymd 31Qea5fHUlN/T6/TGWKCoPr/j1MUNrSTq1lLFDnTno4RNqHpWM1wMK7Ea8q6G8GxJzVGoD YF55JRj5Gxf4dBRU8KAavTnL7SQn3e4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711553037; a=rsa-sha256; cv=none; b=XnXKEMq58uy7DzCUxEnQRtvPz7SvO7n0h7V6peusUmCuakqcx3z66ysT+r9J9Q4IGfrFHg 6wshETEa7R+TTCCVkROKTmdwWS5OA3y1JebnUqg1er0FF9KNvljE6gbqk1ubN+LdysX0Ra D6nTpAzfdAtpwxe6ge83SHdVUjM5l9Y= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OzgduuCE; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711553036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=OzgduuCE5ijan7+anPU0v3ATulf3xn3Bk7Gk3JYuhoBm3ZS1gIcqJVt2pAesMXzNJJDgWE rEKjZuM7hbLQjp1Z2MVlmx/cUWy3UY90lsp+S+50j6tqO3UmvYbfEs2+2Fphs2IepJQLmq tRbBPSVjZ4Xb1ZzQo+sSp3dXf0khzr0= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-lvZlrj4dMEenZ5lBG6ACHQ-1; Wed, 27 Mar 2024 11:23:45 -0400 X-MC-Unique: lvZlrj4dMEenZ5lBG6ACHQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-696a9c482a4so3595976d6.0 for ; Wed, 27 Mar 2024 08:23:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711553025; x=1712157825; 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=iN7hVKxpU9yGNoa0FvV6QQfaV15Sbc5QZKf/pqr08oc=; b=e1DTHvUMVEXj6wDelgDY9znswepFH/tZWBK6FG8bn8SiLBlN2XGTdBWcYk1+OnmLZq 4hSoxm2lLpX/J7eyOrAgFda5hPGur9PXHu9Xh8Jx7FRPEzNlf6VW06cLc5ww5+oujSeB LBgBdhMjiYWZ/nzjKrpHvqthuqyVfmbV4EpslSDPu5I7if5Vji+hlK1Jd5YZLjNoK3F0 OhQRZpr5/+oT7oD4h8++yi82mNIiZLWWAMFgNK08KOkdSJQlHk0oqZb8dunF1KlA8md8 U3oCBELKlPKYlEG8rMUIUovneLklXzKDX3maOnKd5RRJ61qTvaobC0E/OrELYH3uSd1b yLUA== X-Gm-Message-State: AOJu0YxEcoYoDxwyXrrJNKfIwWFtOUEzZlLIxXeNZiTSb8GfHNCfUsVV vvCEiF/9a8VMGjW+1jKrKgCduY1/gZOGDRUk+XK3u+7zM9wb4XBid7qB/ia7W1qWVPbQpPLdKnN +I0w+QlJbVCC+HUvHZuP3vfu37BPiqIlb6ITbxrI6IPdqCb01lHAv4ep1+I/cSx8YI2mCB85ESL ClkFHYAb2qYSUTaOXPqeCPmAdxggiYbw== X-Received: by 2002:a05:6214:4598:b0:696:7b32:cceb with SMTP id op24-20020a056214459800b006967b32ccebmr13869575qvb.6.1711553024769; Wed, 27 Mar 2024 08:23:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFS0Dr3UNRPnI4el/D5x8gcrtCXLMsQwIvd4dOzHJoXuoNg03xhCSCfsu9VpmJMAiYn3G+95A== X-Received: by 2002:a05:6214:4598:b0:696:7b32:cceb with SMTP id op24-20020a056214459800b006967b32ccebmr13869513qvb.6.1711553024070; Wed, 27 Mar 2024 08:23:44 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hu4-20020a056214234400b00690dd47a41csm6412639qvb.86.2024.03.27.08.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:23:43 -0700 (PDT) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Yang Shi , "Kirill A . Shutemov" , Mike Kravetz , John Hubbard , Michael Ellerman , peterx@redhat.com, Andrew Jones , Muchun Song , linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , Christoph Hellwig , Lorenzo Stoakes , Matthew Wilcox , Rik van Riel , linux-arm-kernel@lists.infradead.org, Andrea Arcangeli , David Hildenbrand , "Aneesh Kumar K . V" , Vlastimil Babka , James Houghton , Jason Gunthorpe , Mike Rapoport , Axel Rasmussen Subject: [PATCH v4 04/13] mm: Introduce vma_pgtable_walk_{begin|end}() Date: Wed, 27 Mar 2024 11:23:23 -0400 Message-ID: <20240327152332.950956-5-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327152332.950956-1-peterx@redhat.com> References: <20240327152332.950956-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: 151A14001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: yfnhrdisatua895kc7mdkupt8tygzm4d X-HE-Tag: 1711553036-710980 X-HE-Meta: U2FsdGVkX1/ZVUkhOEulavnL4HKywEjbDgKrGtWpXp2LF9FHDqaIzflLM7TAbunDE6nnEUu2gBK3s7pVigHkQhebacAJIPougLLxZeBHWekrfJ0qsUZahf0x4Lt2PWADos9W+Uoxb/DBEeSnA93rAI2nhDN6c1CJ/KwIgGIMvSDLVJIWgXQC/9342YbNOou9kTIBp01FivjlFLSPvEJt6De7fefvwLAnAjqSSmBRres3TdbmL0HtLTKNU13xVPj6/9ai7eorS1rteBBHue5jnyfDhDddDVFYAd5tfoVTxPdxMve8CZQOs9nSOScspZfb+VNTOBi4Ra/HOT+QcYqZfBHiWboIOTmBxuuBYxpdENGPNRTK/WuH1tR3uRmXGqYHp/yLhuW8MVs7kvgwKLqRB2T2APx0aBAoHhfYC5khR7YBuACtOTmocW+jIriLzg1u4sxW0qtQZrbIE3gYdTPK28j7CO8d+ZYcueF6YYb0PzWEsTJWVctbYG15nDtIySeg6SRFhss1K3hlyV027BgIveZIqcs/mN6sM+vIIvtG+UuV5ejSurKY02L3NyvfkugILht9taII2/B22zNLlRCWvmp8dVBPBU1VTQc0HRtgMu5kXzgJhB3GsQB73plF5c9gLBJEKtrnOLDqOOC2cF7rlvJW8XtRby5KvoaLcHeuXKqBrmX4O8W3BKvIGngepkSug4fps6RVzCLC1MR7Ej5EDA0h4pcqXYX2C+ZF8n9uGpWqP/DtX8lYsUwBSfKhuZm4760oLclSmIG0y1kx3TdyiTOjOKObJ1m7dZwG6/U01rGmQk98JuZ456qo61D3rRHwom4IqU0yxB/q8E8Ygq5q9eKuJ23X39coepYRACbhMlDErSiRwRwzUIeRU9TSxKzFuRNzmjKc+MqJZT1icbTP3bZluPHlf8ZmKTc0voWbG7jEr/Rg9tcL1dK+1gnfgG/KE0cxYth4mITL6ZTHlft 8t817T/T 7MJ9MYuOLT6BGW/Athqe6OehcnhxQMgpmbv1VrzVkNRXpyxUhx/NY6osgNzjja90s76tiju0yekPLTXdogfDsocWnxzfBMF2fm4R/Xf6d7v5eCVbjWXKLZFHBoHukMtzu7a2VxWezUhQF4nFMQkF4z7MfrxGCYIQrfsAvffpCGr+oNXBLv+FLNJu1Z2dibn0BLh8QluM4Ojy6yc2wiD7TboVJkiEi6+orM/e11w/fzecr5Bu9DfixE71A150JreZmISzXtYQ0fkv0DRVciQt+3Cmb2pYklrxlxWsRgqNrrK/3A+pc4sG3pnGbslO7wNPQpGds9tZ3+30N9qCeXYm3MTcO3dPwhAx7IHmWNdUWxjBmBop7Rk89uRgT5z9ETgP/pLtP0Sfb01+qP1t7H2VxoKezwO3mKJfib+bAFu5nT3vfqz5ec6vwgK6qFvUEAv1U+NGHaG74AtCZQPBGvhwaOp33rPb+i1I6YV8JRjLvidahbds= 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: List-Subscribe: List-Unsubscribe: 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 afe27ff3fa94..d8f78017d271 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4233,4 +4233,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 3d0c0cc33c57..27d173f9a521 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