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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61924C07E98 for ; Mon, 5 Jul 2021 03:58:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DCEE661283 for ; Mon, 5 Jul 2021 03:58:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCEE661283 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 88ACF6B0011; Sun, 4 Jul 2021 23:58:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 861D06B0036; Sun, 4 Jul 2021 23:58:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 729296B005D; Sun, 4 Jul 2021 23:58:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id 49A1A6B0011 for ; Sun, 4 Jul 2021 23:58:33 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B2F508248047 for ; Mon, 5 Jul 2021 03:58:32 +0000 (UTC) X-FDA: 78327177264.25.190E5AA Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 2D23530000B6 for ; Mon, 5 Jul 2021 03:58:32 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6AB291063; Sun, 4 Jul 2021 20:58:31 -0700 (PDT) Received: from [10.163.88.246] (unknown [10.163.88.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E8ED53F694; Sun, 4 Jul 2021 20:58:28 -0700 (PDT) Subject: Re: [PATCH] mm/debug_vm_pgtable: Fix corrupted PG_arch_1 by set_pmd_at() To: Gavin Shan , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, akpm@linux-foundation.org, shan.gavin@gmail.com References: <20210702103225.51448-1-gshan@redhat.com> From: Anshuman Khandual Message-ID: <33cfab46-3b9b-0088-17b5-bc821c74aefb@arm.com> Date: Mon, 5 Jul 2021 09:29:16 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210702103225.51448-1-gshan@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-Rspamd-Server: rspam02 X-Stat-Signature: 4dmy8umretddy3nhrnb5y9u3c8i17zgn X-Rspamd-Queue-Id: 2D23530000B6 X-HE-Tag: 1625457512-706371 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: Hello Gavin, On 7/2/21 4:02 PM, Gavin Shan wrote: > There are two addresses selected: random virtual address and physical > address corresponding to kernel symbol @start_kernel. During the PMD > tests in pmd_advanced_tests(), the physical address is aligned down > to the starting address of the huge page, whose size is 512MB on ARM64 > when we have 64KB base page size. After that, set_pmd_at() is called > to populate the PMD entry. PG_arch_1, PG_dcache_clean on ARM64, is > set to the page flags. Unforunately, the page, corresponding to the > starting address of the huge page could be owned by buddy. It means > PG_arch_1 can be unconditionally set to page owned by buddy. > > Afterwards, the page with PG_arch_1 set is fetched from buddy's free > area list, but fails the checking. It leads to the following warning > on ARM64: > > BUG: Bad page state in process memhog pfn:08000 > page:0000000015c0a628 refcount:0 mapcount:0 \ > mapping:0000000000000000 index:0x1 pfn:0x8000 > flags: 0x7ffff8000000800(arch_1|node=0|zone=0|lastcpupid=0xfffff) > raw: 07ffff8000000800 dead000000000100 dead000000000122 0000000000000000 > raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000 > page dumped because: PAGE_FLAGS_CHECK_AT_PREP flag(s) set Does this problem happen right after the boot ? OR you ran some tests and workloads to trigger this ? IIRC never seen this before on arm64. Does this happen on other archs too ? > > This fixes the issue by calling flush_dcache_page() after each call > to set_{pud, pmd, pte}_at() because PG_arch_1 isn't needed in any case. This (arm64 specific solution) might cause some side effects on other platforms ? The solution here needs to be generic enough. I will take a look into this patch but probably later this week or next week. - Anshuman