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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham 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 06119C433E1 for ; Sun, 24 May 2020 16:54:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B932D207D8 for ; Sun, 24 May 2020 16:54:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="lgVmuHWz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B932D207D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 488BA80008; Sun, 24 May 2020 12:54:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 413C480007; Sun, 24 May 2020 12:54:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 302C080008; Sun, 24 May 2020 12:54:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 1610880007 for ; Sun, 24 May 2020 12:54:07 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C475F8245571 for ; Sun, 24 May 2020 16:54:06 +0000 (UTC) X-FDA: 76852210092.01.snow36_23dcea8aab00b X-HE-Tag: snow36_23dcea8aab00b X-Filterd-Recvd-Size: 3553 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Sun, 24 May 2020 16:54:06 +0000 (UTC) Received: from aquarius.haifa.ibm.com (nesher1.haifa.il.ibm.com [195.110.40.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5264B2073B; Sun, 24 May 2020 16:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590339245; bh=tbfyF8Gc0VJZg/qt06s+XuPIZbuK7GsvX8u3HOrwBQY=; h=From:To:Cc:Subject:Date:From; b=lgVmuHWzTKcfFO926HF7v+JvUBv/SAafc4WDxcrRf1btKKf9XdaKY99pxOWRYvR3o cScRHiUgRP1zyTfdcx5N0AS1O53w6n/k9rY4271Bk2ptxtvsMFCW0A6E9BlPTGqL4Y 2TEXdt6SqEojy7Nvm6HJ9m+wBUQ2ofw1Cdz0N1j4= From: Mike Rapoport To: Andrew Morton Cc: "David S. Miller" , Guenter Roeck , sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport , Mike Rapoport Subject: [PATCH] sparc32: register memory occupied by kernel as memblock.memory Date: Sun, 24 May 2020 19:53:58 +0300 Message-Id: <20200524165358.27188-1-rppt@kernel.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: From: Mike Rapoport sparc32 never registered the memory occupied by the kernel image with memblock_add() and it only reserved this memory with meblock_reserve(). With openbios as system firmware, the memory occupied by the kernel is reserved in openbios and removed from mem.available. The prom setup code = in the kernel uses mem.available to set up the memory banks and essentially there is a hole for the memory occupied by the kernel image. Later in bootmem_init() this memory is memblock_reserve()d. Up until recently, memmap initialization would call __init_single_page() for the pages in that hole, the free_low_memory_core_early() would mark them as reserved and everything would be Ok. After the change in memmap initialization introduced by the commit "mm: memmap_init: iterate over memblock regions rather that check each PFN", t= he hole is skipped and the page structs for it are not initialized. And when they are passed from memblock to page allocator as reserved, the latter gets confused. Simply registering the memory occupied by the kernel with memblock_add() resolves this issue. Tested on qemu-system-sparc with Debian Etch [1] userspace. [1] https://people.debian.org/~aurel32/qemu/sparc/debian_etch_sparc_small= .qcow2 Signed-off-by: Mike Rapoport Link: https://lkml.kernel.org/r/20200517000050.GA87467@roeck-us.nlllllet/= =20 --- David, I'd really appreciate your Ack or an explanation where my analysis is wro= ng :) arch/sparc/mm/init_32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index e45160839f79..eb2946b1df8a 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c @@ -192,6 +192,7 @@ unsigned long __init bootmem_init(unsigned long *page= s_avail) /* Reserve the kernel text/data/bss. */ size =3D (start_pfn << PAGE_SHIFT) - phys_base; memblock_reserve(phys_base, size); + memblock_add(phys_base, size); =20 size =3D memblock_phys_mem_size() - memblock_reserved_size(); *pages_avail =3D (size >> PAGE_SHIFT) - high_pages; --=20 2.26.2