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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 BBFF3C433DB for ; Thu, 4 Mar 2021 00:36:38 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DAE6B64E51 for ; Thu, 4 Mar 2021 00:36:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DAE6B64E51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=Xx4f8qeUk51oUI2p3JyXz+kMPUPLPP7iJVjQlvBGTTc=; b=bZGMBdBov798xY3mTYoFUgnEz Z/8WqCnwSUfa6/guYEWheEANFR1OXEHudf9KCaqNAufPIZYdNGJoOuJYa2agq15tsAWkTof4xLTUZ JGdbNgo0nz91CNiqI3oIk8HdALSex5EMAYeqAbEnM0QaxlnEnCSzGG+aaZ3wjkHLTMh7VWc0od0DU vFLr0SHfeNRcsgryCEYs+oH0Uh22rlWKytM2FeOYWUQh8S3nKBx8ZF6c+rOU/qno8mrtrtZCDpRbb ucBwLilCn1IpYYv7ITX5Jn6xOORcJx9roc85fwGe01IgO3gRBqocjfdluvkPq+AGaNP+LrD8jxf5v 0U3K+/SYQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHbwW-007Aln-G7; Thu, 04 Mar 2021 00:34:17 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHWnb-0068Ul-Rg for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 19:04:46 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA40E601FB; Wed, 3 Mar 2021 19:04:35 +0000 (UTC) Date: Wed, 3 Mar 2021 19:04:33 +0000 From: Catalin Marinas To: David Hildenbrand Cc: Anshuman Khandual , Will Deacon , Mark Rutland , linux-kernel@vger.kernel.org, Mike Rapoport , linux-mm@kvack.org, =?iso-8859-1?B?Suly9G1l?= Glisse , James Morse , Dan Williams , Robin Murphy , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH V2 1/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory Message-ID: <20210303190428.GB24035@arm.com> References: <20210202123215.GA16868@willie-the-truck> <20210202123524.GB16868@willie-the-truck> <20210202125152.GC16868@willie-the-truck> <4d8f5156-8628-5531-1485-322ad92aa15c@redhat.com> <0e649f28-4d54-319d-f876-8a93870cda7f@arm.com> <20210205185552.GA23216@willie-the-truck> <20210211115354.GB29894@willie-the-truck> <23e5eb93-a39c-c68e-eac1-c5ccf9036079@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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, Feb 11, 2021 at 01:35:56PM +0100, David Hildenbrand wrote: > On 11.02.21 13:10, Anshuman Khandual wrote: > > On 2/11/21 5:23 PM, Will Deacon wrote: > > > ... and dropped. These patches appear to be responsible for a boot > > > regression reported by CKI: > > > > Ahh, boot regression ? These patches only change the behaviour > > for non boot memory only. > > > > > https://lore.kernel.org/r/cki.8D1CB60FEC.K6NJMEFQPV@redhat.com > > > > Will look into the logs and see if there is something pointing to > > the problem. > > It's strange. One thing I can imagine is a mis-detection of early sections. > However, I don't see that happening: > > In sparse_init_nid(), we: > 1. Initialize the memmap > 2. Set SECTION_IS_EARLY | SECTION_HAS_MEM_MAP via > sparse_init_one_section() > > Only hotplugged sections (DIMMs, dax/kmem) set SECTION_HAS_MEM_MAP without > SECTION_IS_EARLY - which is correct, because these are not early. > > So once we know that we have valid_section() -- SECTION_HAS_MEM_MAP is set > -- early_section() should be correct. > > Even if someone would be doing a pfn_valid() after > memblocks_present()->memory_present() but before > sparse_init_nid(), we should be fine (!valid_section() -> return 0). I couldn't figure out how this could fail with Anshuman's patches. Will's suspicion is that some invalid/null pointer gets dereferenced before being initialised but the only case I see is somewhere in pfn_section_valid() (ms->usage) if valid_section() && !early_section(). Assuming that we do get a valid_section(ms) && !early_section(ms), is there a case where ms->usage is not initialised? I guess races with section_deactivate() are not possible this early. Another situation could be that pfn_valid() returns true when no memory is mapped for that pfn. > As it happens early during boot, I doubt that some NVDIMMs that get detected > and added early during boot as system RAM (via dax/kmem) are the problem. It is indeed very early, we can't even get the early console output. Debugging this is even harder as it's only misbehaving on a board we don't have access to. On the logic in this patch, is the hot-added memory always covering a full subsection? The arm64 pfn_valid() currently relies on memblock_is_map_memory() but the patch changes it to pfn_section_valid(). So if hot-added memory doesn't cover the full subsection, it may return true even if the pfn is not mapped. Regarding the robustness of the pfn_valid for ZONE_DEVICE memory, could we instead have a SECTION_IS_DEVICE flag and only check for that as not to disturb the hotplugged memory check via memblock_is_map_memory()? -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel