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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9BB8C433FE for ; Mon, 21 Nov 2022 15:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbiKUP6u (ORCPT ); Mon, 21 Nov 2022 10:58:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbiKUP6o (ORCPT ); Mon, 21 Nov 2022 10:58:44 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A519854B26 for ; Mon, 21 Nov 2022 07:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669046262; 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=fSrlQMIuLLb408AYq73wGHaQitblZLzVnKNYWxZfL9g=; b=VowR4wfR8UHqKXIe1WJHXg6weJBt+Vo/zCLu79AvuQFUoRTlFXd1OUoJV71lhbQ+A2sH0H jXEqXyIMJu8GGum2ilJGJlFcIVI6POlIVhZcgF6lzT3qpHLupMnPrVsBKTKyDqKWh2o+np omwjq37W+Gb7rrGAI+SS1cf66pBFVlM= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-632-OnAlqkleNDaT4EXkB4Sm5Q-1; Mon, 21 Nov 2022 10:57:41 -0500 X-MC-Unique: OnAlqkleNDaT4EXkB4Sm5Q-1 Received: by mail-ej1-f71.google.com with SMTP id xh12-20020a170906da8c00b007413144e87fso6787860ejb.14 for ; Mon, 21 Nov 2022 07:57:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fSrlQMIuLLb408AYq73wGHaQitblZLzVnKNYWxZfL9g=; b=XXNEnskTauaeWJwgsye96rJU/uH7e63iIkDOu+buMru63kKsQEq76At1uEm73teOfx Fuu1YxA3d7sh9Qs77IZkIZT+vRiwApD1Nk42EJjlKQyG5rWQ1rkk3Z05oIwluXzXeZ1T f5DhXU4hGnaXxTvMHAslgjLBMj+krYygZXtOcmn/oCmnAb4ZjqEvF50DfVn/SDBV6sc9 uaoCSZ0qqkj/zeVpuBKRDbWmWHZ+kqJlFaKPTZjNks8k8DxRbVMjQho6nF6B6l+K5fM7 szaJstArfmdlnBeXVHF1pzFsznpL58v99/sp1Fggo9YLCxbrqDTC6fA09fRsXTscATSM ZNPw== X-Gm-Message-State: ANoB5plckYtpHNl5MFv3qS4Plmbzm+MtVQlTSi/23XymHa3hY2KAejPH pTeER0a8KWZ3whuMoHptS9TCiIGVwdMXNJZG4M7A2H5iLZ7Z0zahjQ0EgfBQc9Fy7bUlVdY8YJe UFjHkDeW9201Q59gjS6wCAi8X X-Received: by 2002:a17:906:3155:b0:7ad:90db:c241 with SMTP id e21-20020a170906315500b007ad90dbc241mr16094428eje.284.1669046259204; Mon, 21 Nov 2022 07:57:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf4/y8bb1kzSiZCC9luT4L+ZHOKAD7cRl9fZuGVQyKNvIyOfHUXVykJkl23EkrRlztWFizx4Sg== X-Received: by 2002:a17:906:3155:b0:7ad:90db:c241 with SMTP id e21-20020a170906315500b007ad90dbc241mr16094411eje.284.1669046259014; Mon, 21 Nov 2022 07:57:39 -0800 (PST) Received: from [10.43.17.4] (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id s8-20020aa7cb08000000b00461b169c02csm5283198edt.91.2022.11.21.07.57.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Nov 2022 07:57:38 -0800 (PST) Message-ID: Date: Mon, 21 Nov 2022 16:57:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 1/2] arm64/mm: fix incorrect file_map_count for non-leaf pmd/pud Content-Language: en-US To: Liu Shixin , Catalin Marinas , Will Deacon , Kefeng Wang , Anshuman Khandual , David Hildenbrand , Rafael Aquini , Pasha Tatashin Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20221116083811.464678-1-liushixin2@huawei.com> <20221116083811.464678-2-liushixin2@huawei.com> From: Denys Vlasenko In-Reply-To: <20221116083811.464678-2-liushixin2@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/16/22 09:38, 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 Tested on 6.0.6 kernel, no oopses anymore. 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 437E6C4332F for ; Mon, 21 Nov 2022 16:01:49 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Shx25oJBDpSinxPBhSKHmwCo1d0qI/L49GdndxUbRXs=; b=xBf5lpd5RKqRAn JUGYzrI6Vkfv7QPPHGF0fqejKIBYiTKW3Bwe3ujJENQWRKgZseFPu9f+UJ1RbXmZ91loz3b6aXKg/ hkrqKAjg4ZmMHkFjsiWnW6CcLA/TayXY4IpwSZSiGBriHlzpV5nSLx0p2konpCfj9/7xQCOrqD258 wwjXn74CK60aaNS1m/fPBrUCl4HOCvX/+20byWIQSh2EQBxLMLrm7b8vvR4NHelcZk499E8leX3/e t77HNyJNsppzmiwUHSaz6BnvmymTtBE9st7k36rgy+3TBNmcV9B4C9dTkgFiqstZ9cysAQH0bjb5n SXwG5LDPI1xUgb1RDwMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox9Dh-00FTlh-4C; Mon, 21 Nov 2022 16:00:29 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox9DH-00FTTK-KS for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2022 16:00:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669046401; 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=fSrlQMIuLLb408AYq73wGHaQitblZLzVnKNYWxZfL9g=; b=am7RrXt2Pj464jXvI+AePP39klmyYcofgDsb+GmAfafOUBDtNRoi32Vr5NHuKacA20IZdt Sv3/uFvyoyVBpAUMKQXeyRLU9BANKfgDblHf8zUJuPCLYXYwi3HAHEV7y3doVMFznQXfB0 tYNB+tM73mU8DSoLDWI4Qa3FLmCAv/g= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-213-zih7_zn_PwWp8n3Fetz0ig-1; Mon, 21 Nov 2022 10:57:41 -0500 X-MC-Unique: zih7_zn_PwWp8n3Fetz0ig-1 Received: by mail-ej1-f69.google.com with SMTP id qw20-20020a1709066a1400b007af13652c92so6917377ejc.20 for ; Mon, 21 Nov 2022 07:57:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fSrlQMIuLLb408AYq73wGHaQitblZLzVnKNYWxZfL9g=; b=k0gJUELgTV34bWomKBkw54oXdJo8cLZIKx7PSaCTALtNw5AInYn5GL2eUZkBBBKzbc gtxnYWB+acUkN6nS1ZMlY30DIYS9CjCIZD1QtP8Qg0LBmv31WgtUXVA8sK04VdGtPrLc 9vIbeZgImhIlWZuttk+mShtHpRCcJjcRCHerW+2lQnDFYievqkX1MZH9KK8pBmdDhkzn bDpup2LIWWyVVdnYkXfvjI0eyDrQ5u76ueKx+4RW1s89q3sk+uy/69txHeBjHnzNGiyM cCq6yjyMe+pO9O09hAEtRzqB10vL9xvzi+iqnL5T+gifeRhifrXiPvmoFZBa2F7DFjO/ rWGA== X-Gm-Message-State: ANoB5pkoiMHpB6g+Sih32Rz04awpPGs/2y07ZdhZXqPer8R97aRPHNuN bRIf6uI9LYjlsVYOVtOrcPTv+Pns/tn/t9jG9CfDz7X+a9HWldD9G2lr4Au8xo+4EX8LpnHkWyG k/kA/2JoFHizVYEW4tL8D+6FOSshtGY6hr/A= X-Received: by 2002:a17:906:3155:b0:7ad:90db:c241 with SMTP id e21-20020a170906315500b007ad90dbc241mr16094427eje.284.1669046259203; Mon, 21 Nov 2022 07:57:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf4/y8bb1kzSiZCC9luT4L+ZHOKAD7cRl9fZuGVQyKNvIyOfHUXVykJkl23EkrRlztWFizx4Sg== X-Received: by 2002:a17:906:3155:b0:7ad:90db:c241 with SMTP id e21-20020a170906315500b007ad90dbc241mr16094411eje.284.1669046259014; Mon, 21 Nov 2022 07:57:39 -0800 (PST) Received: from [10.43.17.4] (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id s8-20020aa7cb08000000b00461b169c02csm5283198edt.91.2022.11.21.07.57.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Nov 2022 07:57:38 -0800 (PST) Message-ID: Date: Mon, 21 Nov 2022 16:57:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 1/2] arm64/mm: fix incorrect file_map_count for non-leaf pmd/pud To: Liu Shixin , Catalin Marinas , Will Deacon , Kefeng Wang , Anshuman Khandual , David Hildenbrand , Rafael Aquini , Pasha Tatashin Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20221116083811.464678-1-liushixin2@huawei.com> <20221116083811.464678-2-liushixin2@huawei.com> From: Denys Vlasenko In-Reply-To: <20221116083811.464678-2-liushixin2@huawei.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221121_080003_795481_52B38CA3 X-CRM114-Status: GOOD ( 12.17 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 11/16/22 09:38, 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 Tested on 6.0.6 kernel, no oopses anymore. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel