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 48D02C433DB for ; Thu, 28 Jan 2021 11:05:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E44464DDA for ; Thu, 28 Jan 2021 11:05:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E44464DDA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gaisler.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5A8BE6B0005; Thu, 28 Jan 2021 06:05:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 531516B0006; Thu, 28 Jan 2021 06:05:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41DD76B006C; Thu, 28 Jan 2021 06:05:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id 28FA56B0005 for ; Thu, 28 Jan 2021 06:05:39 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E9DD91EE6 for ; Thu, 28 Jan 2021 11:05:38 +0000 (UTC) X-FDA: 77754903156.19.pull12_07051de2759f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 94D1B1AD1B3 for ; Thu, 28 Jan 2021 11:05:38 +0000 (UTC) X-HE-Tag: pull12_07051de2759f X-Filterd-Recvd-Size: 2847 Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Jan 2021 11:05:37 +0000 (UTC) X-Halon-ID: bac96e9c-6158-11eb-b73f-0050569116f7 Authorized-sender: andreas@gaisler.com Received: from andreas.got.gaisler.com (h-98-128-223-123.na.cust.bahnhof.se [98.128.223.123]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id bac96e9c-6158-11eb-b73f-0050569116f7; Thu, 28 Jan 2021 12:05:33 +0100 (CET) Subject: Re: sparc32: boot fails with > 256 MB memory after switch to NO_BOOTMEM To: Mike Rapoport Cc: Sparc kernel list , linux-mm@kvack.org, Mike Rapoport , Linux Kernel Mailing List , "David S. Miller" , Sam Ravnborg , Michal Hocko References: <5adb7c41-ad71-b904-6b73-35aef4dfcafe@gaisler.com> <20210128093541.GC299309@linux.ibm.com> From: Andreas Larsson Message-ID: Date: Thu, 28 Jan 2021 12:05:28 +0100 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: <20210128093541.GC299309@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: On 2021-01-28 10:35, Mike Rapoport wrote: > On Wed, Jan 27, 2021 at 04:03:00PM +0100, Andreas Larsson wrote: >> >> >> Commit cca079ef8ac29a7c02192d2bad2ffe4c0c5ffdd0 makes sparc32 use >> memblocks instead of the previous bootmem solution. Unfortunately, due >> to this: >> >> #define PAGE_OFFSET 0xf0000000 >> #define __va(x) ((void *)((unsigned long) (x) - phys_base + >> PAGE_OFFSET)) >> #define phys_to_virt __va >> >> it makes physical addresses >= 0x10000000 past phys_base wrap around the >> 32-bit memory space when converted to virtual addresses, e.g. in >> memblock_alloc_try_nid. Physical memory exactly 0x10000000 past >> phys_base is returned as an unintended NULL pointer, leading to a panic >> in my boot when percpu memory allocation fails due to it. >> >> Unfortunately I have had 256 MB memory or less in a lot of my testing, >> so this old one has slipped by me. >> >> Does anyone has any ideas or pointers on how to resolve this? > > I think the simplest way to work around this is to limit early allocations > to 256M with addition of > > memblock_set_current_limit(SZ_256M); > > somewhere at setup_arch(). > > The page allocator will anyway see the entire memory, so I cannot think of > any downside here. That works like a charm! Thank you! I'll submit a patch. -- Andreas Larsson Cobham Gaisler