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 963F0C4332F for ; Fri, 18 Nov 2022 14:38:25 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BSH/n/t28jKwRyE7E+fg2GrbnNG/ZzjmiaJvYqe4/AM=; b=uKcZGbKufeiU+3 Jd7jG/aSGmGvpQSfzALFeh5RIAiko6I1a1D5jQncnpk8wtOtX5qDKLrZXJfjjqXe1nQ6kc22nA8mr oSTNlI/jFFkxRdgMGzoyw1wzHm5UPYIrW8whpPj3VsoZ0JQMxLNKhKRJRKCxCbuYUqPtyBSZ9C3BA 1S2lgRvFUbbx3Ien1YVMdBi8kPOwhrthD+O/S+I1Zv43ard80VkGWcmKCKhbmZM0z6AoWBC997z6M xMgsbJxew6T9ByzDcwkkIYtW4Zuj1PT6SekMWWOyH42s9aPR9oLr79TerZ/W4eIFqfH18gcDqyr1z hnic0MgVXUWngKZi00EQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ow2UT-004Vtc-5f; Fri, 18 Nov 2022 14:37:13 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ow2Sw-004Uqx-V2 for linux-arm-kernel@lists.infradead.org; Fri, 18 Nov 2022 14:35:40 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 46E7B6259A; Fri, 18 Nov 2022 14:35:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 346C9C43145; Fri, 18 Nov 2022 14:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668782138; bh=5f8m4VNy9K9chtMF/fnSLQKXkNjLWmsBHHTqqHiXsKM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kpILfNqEpjA+pX3LWJfCRwKTyRbE6WuW0Aw8Z/A7BIb+1/sq6EnS3SBEUsOv+XO6Z 1FCrlJaJ7ljxyPZ4p1ac5w6ej5g0t621os+JSFtT2324FzcWUJEc76/wBe5DF3EJwp mztpZtNdoY9htocRm/G5V2hu8jwddV2Cv/H4mo4Lg8SJPK752YEU8Oz3BMwXrajntO AdJrJxVESzyoD+aNG7dGimoC5JZiLGkxUhUNxiAtCcFinAlMxmMg86Cn2vszBM/qTJ DqFnaQZ5jjZnBcCQXE1soarLZkzwTLrgGkDLlxdTL/bHEBHWAzn0gieFbhg3ccYELV fo4YhQEtmUAtg== Date: Fri, 18 Nov 2022 14:35:32 +0000 From: Will Deacon To: Liu Shixin Cc: Catalin Marinas , Denys Vlasenko , Kefeng Wang , Anshuman Khandual , David Hildenbrand , Rafael Aquini , Pasha Tatashin , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] arm64/mm: fix incorrect file_map_count for non-leaf pmd/pud Message-ID: <20221118143531.GH4046@willie-the-truck> References: <20221117075602.2904324-1-liushixin2@huawei.com> <20221117075602.2904324-2-liushixin2@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221117075602.2904324-2-liushixin2@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221118_063539_160610_4623DA24 X-CRM114-Status: GOOD ( 20.18 ) 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 On Thu, Nov 17, 2022 at 03:56:01PM +0800, Liu Shixin wrote: > The page table check trigger BUG_ON() unexpectedly when collapse hugepage: > > ------------[ cut here ]------------ > kernel BUG at mm/page_table_check.c:82! > Internal error: Oops - BUG: 00000000f2000800 [#1] SMP > Dumping ftrace buffer: > (ftrace buffer empty) > Modules linked in: > CPU: 6 PID: 68 Comm: khugepaged Not tainted 6.1.0-rc3+ #750 > Hardware name: linux,dummy-virt (DT) > pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) > pc : page_table_check_clear.isra.0+0x258/0x3f0 > lr : page_table_check_clear.isra.0+0x240/0x3f0 > [...] > Call trace: > page_table_check_clear.isra.0+0x258/0x3f0 > __page_table_check_pmd_clear+0xbc/0x108 > pmdp_collapse_flush+0xb0/0x160 > collapse_huge_page+0xa08/0x1080 > hpage_collapse_scan_pmd+0xf30/0x1590 > khugepaged_scan_mm_slot.constprop.0+0x52c/0xac8 > khugepaged+0x338/0x518 > kthread+0x278/0x2f8 > ret_from_fork+0x10/0x20 > [...] > > Since pmd_user_accessible_page() doesn't check if a pmd is leaf, it > decrease file_map_count for a non-leaf pmd comes from collapse_huge_page(). > and so trigger BUG_ON() unexpectedly. > > Fix this problem by using pmd_leaf() insteal of pmd_present() in > pmd_user_accessible_page(). Moreover, use pud_leaf() for > pud_user_accessible_page() too. > > Fixes: 42b2547137f5 ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") > Reported-by: Denys Vlasenko > Signed-off-by: Liu Shixin > Reviewed-by: David Hildenbrand > Acked-by: Pasha Tatashin > --- > arch/arm64/include/asm/pgtable.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index 71a1af42f0e8..edf6625ce965 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -863,12 +863,12 @@ static inline bool pte_user_accessible_page(pte_t pte) > > static inline bool pmd_user_accessible_page(pmd_t pmd) > { > - return pmd_present(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd)); > + return pmd_leaf(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd)); > } > > static inline bool pud_user_accessible_page(pud_t pud) > { > - return pud_present(pud) && pud_user(pud); > + return pud_leaf(pud) && pud_user(pud); Acked-by: Will Deacon Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel