Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7397343rwd; Tue, 20 Jun 2023 00:14:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6a1jxZgWpMSG4LjBHUjbHbkcQDWqjh15LpTGodDWiH8WUO7Y2dyAtvaLN2X3jKgQ2z5yDo X-Received: by 2002:a17:90b:118e:b0:25c:a8b:4f34 with SMTP id gk14-20020a17090b118e00b0025c0a8b4f34mr6595750pjb.23.1687245244076; Tue, 20 Jun 2023 00:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687245244; cv=none; d=google.com; s=arc-20160816; b=r38CrLaY0yOCliVPMdu+PCpp3+oJ6dBa2DnqCZKXuuNW3dfFOJsBZ634HGHgGy2NeW H1IWE31JkyaHLOT6WQFPtCq04tQ2RHpqdI9xO9oTSnPmUfNeh54VcROF8cwsrFgOQEQz HIT6OTw51GfMjm+sqebPn46Akw8P0hVB6NZs19WBFZ8DPcmHFehW5BpbkFuZ97GWxCIr Qtt9hSZkmlSt2ZS7/gEiehzzXfIgfUBqracE8MOq9aPMuCKBRnDpRTqsu2Dzu00gh5bO VhsgqF5VwpcZVW48l2vmehGg4xlYfGoYw8aQFxGJPsqdExFG27vpqnx2Qzwy/gIZGrIb +Gnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :in-reply-to:from:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=wxwuBSSha1K2fZxBjAtxKD1GbnYXS8tOVukSR/bt5Mo=; b=eVpke2Mw+JMP/YVkGNxeaRj15vRcTAAhfA6X1v31AgFiH5C6duf90BAU6KVa/Gzfrs NzLKbJoYWzSl/gAJs7O8a780bEdNZiWhfhgkTgPuD7ohVL3+oi2oijX83nzrhxWJ9X9l gEwF4brMjKNa4OZf7XEj4ZDxbWB4p7weI7R9E7o+UmxHbHgxPjHsVaILeCmv5tkUeJ/O l4qSbY2IEUszGleNC4c1AtMVhLO8BkercIv11PXXPdoSln7FVi8+ovDatFS7PTVzFwWX CAz568GrqMkC2heTGCjp0+DzDJyDmVzjqV6gU1L1nPibVWFThnYUDvjQy2VR+S6W0NYd cf/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q62-20020a632a41000000b0053fbacdaf5asi1097907pgq.759.2023.06.20.00.13.51; Tue, 20 Jun 2023 00:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbjFTHFJ (ORCPT + 99 others); Tue, 20 Jun 2023 03:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjFTHFI (ORCPT ); Tue, 20 Jun 2023 03:05:08 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24C71CC for ; Tue, 20 Jun 2023 00:05:04 -0700 (PDT) X-QQ-mid: bizesmtp68t1687244697t5j1vrfc Received: from [192.168.1.114] ( [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 20 Jun 2023 15:04:55 +0800 (CST) X-QQ-SSF: 00200000000000B08000000A0000000 X-QQ-FEAT: J5JfekO1WsjPosBijC6AUvsD8qiWRMfmiqOBKJ2jPS0mNmwhUxXYF2849gB0/ 88ldsBiRsnqOAnCs4rPW3d/sO2JqkLFBfsbwrAIvNkSqDJXTCabS/lwB++SOpmUOkZhe+41 eyYUM1ni6LJTW92kCR23uaHISKqsdpOG59j7qFCN7zX4aR+5kwptACrhSSUWwmLFStqaFJL hfb4ixh2r/8aiDc3uIQkyDk34/x+cq9KIexbGIN+4JYtfeO627sfGoFGZTmkc1ZCV0QWCXh RVFYiZBXx1lMYC6Jvw6ZsegtIyOoQNS8CLRdaA87WcqxaPDnntgGJAatkRtCY0puz1AxHj+ BMcXbw7fAY2dO4puZCma/EO3VXdJA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16156462231222719866 Message-ID: <6EA2B512AB4F2017+9d56e9b9-a875-9799-147b-1c8adc693507@tinylab.org> Date: Tue, 20 Jun 2023 15:04:55 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH] memblock: Add error message when memblock_can_resize is not ready To: Mike Rapoport Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230614131746.3670303-1-songshuaishuai@tinylab.org> <20230614160710.GH52412@kernel.org> From: Song Shuai In-Reply-To: <20230614160710.GH52412@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-3 X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry for not replying to you in time 在 2023/6/15 00:07, Mike Rapoport 写道: > Hi, > > On Wed, Jun 14, 2023 at 09:17:46PM +0800, Song Shuai wrote: >> The memblock APIs are always correct, thus the callers usually don't >> handle the return code. But the failure caused by unready memblock_can_resize >> is hard to recognize without the return code. Like this piece of log: > > Please make it clear that failure is in memblock_double_array(), e.g. > Having numerous memblock reservations at early boot where memblock_can_resize is unset may exhaust the INIT_MEMBLOCK_REGIONS sized memblock.reserved regions and try to double the region array via memblock_double_array() which fails and returns -1 to the caller. You can find the numerous memblock reservations reported by this commit 24cc61d8cb5a ("arm64: memblock: don't permit memblock resizing until linear mapping is up"). And the similar test sense can be simulated by a constructed dtb with numerous discrete /memreserve/ or /reserved-memory regions. > But when memblock_double_array() is called before memblock_can_resize > is true, it is hard to understand the actual reason for the failure. > >> >> ``` >> [ 0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c >> [ 0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128 >> [ 0.000000] Oops - store (or AMO) access fault [#1] >> ``` >> >> So add an error message for this kind of failure: >> >> ``` >> [ 0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c >> [ 0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128 >> [ 0.000000] memblock: Can't double reserved array for area start 0x000000017ffff000 size 4096 >> [ 0.000000] Oops - store (or AMO) access fault [#1] >> ``` >> >> Signed-off-by: Song Shuai >> --- >> mm/memblock.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/mm/memblock.c b/mm/memblock.c >> index 3feafea06ab2..ab952a164f62 100644 >> --- a/mm/memblock.c >> +++ b/mm/memblock.c >> @@ -418,8 +418,11 @@ static int __init_memblock memblock_double_array(struct memblock_type *type, >> /* We don't allow resizing until we know about the reserved regions >> * of memory that aren't suitable for allocation >> */ >> - if (!memblock_can_resize) >> + if (!memblock_can_resize) { >> + pr_err("memblock: Can't double %s array for area start %pa size %ld\n", >> + type->name, &new_area_start, (unsigned long)new_area_size); > > Most of the time memblock uses %llu and cast to u64 to print size, please > make this consistent. I will fix it in next version if the above description is ok for you. > >> return -1; >> + } >> >> /* Calculate new doubled size */ >> old_size = type->max * sizeof(struct memblock_region); >> -- >> 2.20.1 >> >> > -- Thanks Song Shuai