Message ID | 20230519105321.333-1-ssawgyw@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1142673vqo; Fri, 19 May 2023 04:01:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7kXJIhDlGUykXgwlXQYhtSuG83y+3QLqTlyiXc0mEMmoRq0OJ20jvGr/2BynBs7S82ki57 X-Received: by 2002:a17:90a:f0d5:b0:250:7d1f:938b with SMTP id fa21-20020a17090af0d500b002507d1f938bmr1946994pjb.23.1684494068936; Fri, 19 May 2023 04:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684494068; cv=none; d=google.com; s=arc-20160816; b=a5ghXkaN7fo6ajjRG4StoaLPCuKYce22i6m9b8DAIEcM1mZSA+JddjBarz57Ca45Rm 0I0LaMDGD7tUr5+I48bktZynSyMWqq3dAUcmbRNS8a5trNSpO7QHVH1+ERjWlI41YYRs OuU946R9v4YtdjCW9rUCRIOXXvOHtLvhchUdT4ye5Yglvd0saYNZGr5Ty5wCrmQa1zJn baoB2uHApNxgUm2WEuIUBdx77ql0hTOGl+ebUdDGqpbCAufAB3cxMG9ZR4B/0jJOe+KN N2dRVFw0EKbdgmRPtAC8ECIsEbvUIRV3UjZyHdqZuL4jVB948J7Iszw23yT1Iyg+liY2 9FXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=n5ls3SeTHm3utb0beJFgdvQLna8e8DUOYvcEbBp6374=; b=UW3abHcspXhosnlHMwu5TunpjyUkUPuY0Dn0OijSYLSBVX3OxVVlNjZ4mZcNuCIkB1 kMrNmrwBojAVbWm77mJmM0chBChiE3o87o060taHBORVB/a7ATgUzIxFX4ylYLdBpNhc lV7exM4L46h+O4xi/GAaaXhUWZJHGp0THeQojZlDd3mDNqhvxoe653fJCsk+KKemLDQ5 k5CJPdXsOsiHDIAgWhvM+7lX4HBLGNiHTNuDYdaB7zhKh7NvsjfKJIeWB5iQWTv6NgI7 qNFTgjok+8fbNC3HOxtMjSSdrPCdmQ1ytbg8EOeyPk3vr1kUDeVYv+fPN/okLssdip9X 9mWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=oJdmOAay; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p22-20020a17090adf9600b002502b3fa445si1606088pjv.14.2023.05.19.04.00.49; Fri, 19 May 2023 04:01:08 -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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=oJdmOAay; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231340AbjESKxj (ORCPT <rfc822;wlfightup@gmail.com> + 99 others); Fri, 19 May 2023 06:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231375AbjESKxi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 19 May 2023 06:53:38 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69A40E45 for <linux-kernel@vger.kernel.org>; Fri, 19 May 2023 03:53:35 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1a516fb6523so29540905ad.3 for <linux-kernel@vger.kernel.org>; Fri, 19 May 2023 03:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684493615; x=1687085615; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=n5ls3SeTHm3utb0beJFgdvQLna8e8DUOYvcEbBp6374=; b=oJdmOAayLhOyGpjHGxPM+kbykuT92LlGd7nhK+9Q3b+2FvumgN8yMgwlNYjsZvULzh tcBiIUZPO619L5N4ZFJ9YPruJxdA0exCv0dj3CfZQqzSS4Vvth48xTv7ZMh4QyFP0gRx MaaAeD8/nGIqyawaqNvBBPIJBtvbF5DzYuOQNB5XQSNbiD173ZZlmpxM3b0exgYWn1bZ 7o248jYzFx57MnvwE5G+MkB/kNf+0+E5NRJ6+28qMsv/4gfb4b3jKRN5lU67IfSgKWcZ w3eNbkv3giDA5nbMhDIzXYVI/EpNBEidp1OnuGw9lvrbz52Joo5XzlK/UA9y8dXlBq4q ji9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684493615; x=1687085615; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=n5ls3SeTHm3utb0beJFgdvQLna8e8DUOYvcEbBp6374=; b=DBtC179cIpL2nDJ3hKnJUIca+KrTbrh/W1YVT0VRKznPE9QV6p/v+zTuPEAjuzwLoG PBR4gL6LVDK39PTfMI0VHPmtubvG45vBljuXOsNyfPHJPNQa7tzQqbTfXdMaxlUCdI/T DKvHX6KEOQEX7kQnhYQOvbRkLVR2ijCMyBpw9flUIaaYtEBFd8BDIvPg6cidB4nKuzMz +tT6yEpzAH+TrletnGufDGe2LJV1VOAU14Dvxpdig2ayzd26gqnEENsBY4jEMvV2/S+J Uc8wj3wL+7tDfofKnaJINZ6/SElyNEoDc/xMMSBk7v2s1jcCICuCZKBOIX6t2GRCo+KT +PqQ== X-Gm-Message-State: AC+VfDxoyjFjZtUZs+FqyyFnl7aqMCKVKbkXGaWEDE+KIG4WYxGo9H+9 LBGPCsIswEchk+FRJErQdqU= X-Received: by 2002:a17:902:f7c2:b0:1ae:4c2d:94a2 with SMTP id h2-20020a170902f7c200b001ae4c2d94a2mr1622005plw.65.1684493613204; Fri, 19 May 2023 03:53:33 -0700 (PDT) Received: from localhost.localdomain ([45.43.34.98]) by smtp.gmail.com with ESMTPSA id a16-20020a170902ecd000b001ac38343438sm3152478plh.176.2023.05.19.03.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 03:53:32 -0700 (PDT) From: Yuwei Guan <ssawgyw@gmail.com> To: rppt@kernel.org, akpm@linux-foundation.org, tsahu@linux.ibm.com, anshuman.khandual@arm.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yuwei Guan <ssawgyw@gmail.com> Subject: [PATCH v4] memblock: Add flags and nid info in memblock debugfs Date: Fri, 19 May 2023 18:53:21 +0800 Message-Id: <20230519105321.333-1-ssawgyw@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766320052641852407?= X-GMAIL-MSGID: =?utf-8?q?1766320052641852407?= |
Series |
[v4] memblock: Add flags and nid info in memblock debugfs
|
|
Commit Message
Yuwei Guan
May 19, 2023, 10:53 a.m. UTC
Currently, the memblock debugfs can display the count of memblock_type and
the base and end of the reg. However, when memblock_mark_*() or
memblock_set_node() is executed on some range, the information in the
existing debugfs cannot make it clear why the address is not consecutive.
For example,
cat /sys/kernel/debug/memblock/memory
0: 0x0000000080000000..0x00000000901fffff
1: 0x0000000090200000..0x00000000905fffff
2: 0x0000000090600000..0x0000000092ffffff
3: 0x0000000093000000..0x00000000973fffff
4: 0x0000000097400000..0x00000000b71fffff
5: 0x00000000c0000000..0x00000000dfffffff
6: 0x00000000e2500000..0x00000000f87fffff
7: 0x00000000f8800000..0x00000000fa7fffff
8: 0x00000000fa800000..0x00000000fd3effff
9: 0x00000000fd3f0000..0x00000000fd3fefff
10: 0x00000000fd3ff000..0x00000000fd7fffff
11: 0x00000000fd800000..0x00000000fd901fff
12: 0x00000000fd902000..0x00000000fd909fff
13: 0x00000000fd90a000..0x00000000fd90bfff
14: 0x00000000fd90c000..0x00000000ffffffff
15: 0x0000000880000000..0x0000000affffffff
So we can add flags and nid to this debugfs.
For example,
cat /sys/kernel/debug/memblock/memory
0: 0x0000000080000000..0x00000000901fffff 0 NONE
1: 0x0000000090200000..0x00000000905fffff 0 NOMAP
2: 0x0000000090600000..0x0000000092ffffff 0 NONE
3: 0x0000000093000000..0x00000000973fffff 0 NOMAP
4: 0x0000000097400000..0x00000000b71fffff 0 NONE
5: 0x00000000c0000000..0x00000000dfffffff 0 NONE
6: 0x00000000e2500000..0x00000000f87fffff 0 NONE
7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP
8: 0x00000000fa800000..0x00000000fd3effff 0 NONE
9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP
10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE
11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP
12: 0x00000000fd902000..0x00000000fd909fff 0 NONE
13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP
14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE
15: 0x0000000880000000..0x0000000affffffff 0 NONE
Signed-off-by: Yuwei Guan <ssawgyw@gmail.com>
---
v4:
- show string value for each memblock flag
---
mm/memblock.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
Comments
On 5/19/23 16:23, Yuwei Guan wrote: > Currently, the memblock debugfs can display the count of memblock_type and > the base and end of the reg. However, when memblock_mark_*() or > memblock_set_node() is executed on some range, the information in the > existing debugfs cannot make it clear why the address is not consecutive. > > For example, > cat /sys/kernel/debug/memblock/memory > 0: 0x0000000080000000..0x00000000901fffff > 1: 0x0000000090200000..0x00000000905fffff > 2: 0x0000000090600000..0x0000000092ffffff > 3: 0x0000000093000000..0x00000000973fffff > 4: 0x0000000097400000..0x00000000b71fffff > 5: 0x00000000c0000000..0x00000000dfffffff > 6: 0x00000000e2500000..0x00000000f87fffff > 7: 0x00000000f8800000..0x00000000fa7fffff > 8: 0x00000000fa800000..0x00000000fd3effff > 9: 0x00000000fd3f0000..0x00000000fd3fefff > 10: 0x00000000fd3ff000..0x00000000fd7fffff > 11: 0x00000000fd800000..0x00000000fd901fff > 12: 0x00000000fd902000..0x00000000fd909fff > 13: 0x00000000fd90a000..0x00000000fd90bfff > 14: 0x00000000fd90c000..0x00000000ffffffff > 15: 0x0000000880000000..0x0000000affffffff > > So we can add flags and nid to this debugfs. > > For example, > cat /sys/kernel/debug/memblock/memory > 0: 0x0000000080000000..0x00000000901fffff 0 NONE > 1: 0x0000000090200000..0x00000000905fffff 0 NOMAP > 2: 0x0000000090600000..0x0000000092ffffff 0 NONE > 3: 0x0000000093000000..0x00000000973fffff 0 NOMAP > 4: 0x0000000097400000..0x00000000b71fffff 0 NONE > 5: 0x00000000c0000000..0x00000000dfffffff 0 NONE > 6: 0x00000000e2500000..0x00000000f87fffff 0 NONE > 7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP > 8: 0x00000000fa800000..0x00000000fd3effff 0 NONE > 9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP > 10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE > 11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP > 12: 0x00000000fd902000..0x00000000fd909fff 0 NONE > 13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP > 14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE > 15: 0x0000000880000000..0x0000000affffffff 0 NONE > > Signed-off-by: Yuwei Guan <ssawgyw@gmail.com> LGTM Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> > --- > v4: > - show string value for each memblock flag > --- > mm/memblock.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index 511d4783dcf1..10d0ddbeebc1 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) > } > > #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) > +static const char * const flagname[] = { > + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", > + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", > + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", > + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", > +}; > > static int memblock_debug_show(struct seq_file *m, void *private) > { > struct memblock_type *type = m->private; > struct memblock_region *reg; > - int i; > + int i, j; > + unsigned int count = ARRAY_SIZE(flagname); > phys_addr_t end; > > for (i = 0; i < type->cnt; i++) { > @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) > end = reg->base + reg->size - 1; > > seq_printf(m, "%4d: ", i); > - seq_printf(m, "%pa..%pa\n", ®->base, &end); > + seq_printf(m, "%pa..%pa ", ®->base, &end); > + seq_printf(m, "%4d ", memblock_get_region_node(reg)); > + if (reg->flags) { > + for (j = 0; j < count; j++) { > + if (reg->flags & (1U << j)) { > + seq_printf(m, "%s\n", flagname[j]); > + break; > + } > + } > + if (j == count) > + seq_printf(m, "%s\n", "UNKNOWN"); > + } else { > + seq_printf(m, "%s\n", "NONE"); > + } > } > return 0; > }
Hi, On Fri, May 19, 2023 at 06:53:21PM +0800, Yuwei Guan wrote: > Currently, the memblock debugfs can display the count of memblock_type and > the base and end of the reg. However, when memblock_mark_*() or > memblock_set_node() is executed on some range, the information in the > existing debugfs cannot make it clear why the address is not consecutive. > > For example, > cat /sys/kernel/debug/memblock/memory > 0: 0x0000000080000000..0x00000000901fffff > 1: 0x0000000090200000..0x00000000905fffff > 2: 0x0000000090600000..0x0000000092ffffff > 3: 0x0000000093000000..0x00000000973fffff > 4: 0x0000000097400000..0x00000000b71fffff > 5: 0x00000000c0000000..0x00000000dfffffff > 6: 0x00000000e2500000..0x00000000f87fffff > 7: 0x00000000f8800000..0x00000000fa7fffff > 8: 0x00000000fa800000..0x00000000fd3effff > 9: 0x00000000fd3f0000..0x00000000fd3fefff > 10: 0x00000000fd3ff000..0x00000000fd7fffff > 11: 0x00000000fd800000..0x00000000fd901fff > 12: 0x00000000fd902000..0x00000000fd909fff > 13: 0x00000000fd90a000..0x00000000fd90bfff > 14: 0x00000000fd90c000..0x00000000ffffffff > 15: 0x0000000880000000..0x0000000affffffff > > So we can add flags and nid to this debugfs. > > For example, > cat /sys/kernel/debug/memblock/memory > 0: 0x0000000080000000..0x00000000901fffff 0 NONE > 1: 0x0000000090200000..0x00000000905fffff 0 NOMAP > 2: 0x0000000090600000..0x0000000092ffffff 0 NONE > 3: 0x0000000093000000..0x00000000973fffff 0 NOMAP > 4: 0x0000000097400000..0x00000000b71fffff 0 NONE > 5: 0x00000000c0000000..0x00000000dfffffff 0 NONE > 6: 0x00000000e2500000..0x00000000f87fffff 0 NONE > 7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP > 8: 0x00000000fa800000..0x00000000fd3effff 0 NONE > 9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP > 10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE > 11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP > 12: 0x00000000fd902000..0x00000000fd909fff 0 NONE > 13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP > 14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE > 15: 0x0000000880000000..0x0000000affffffff 0 NONE > > Signed-off-by: Yuwei Guan <ssawgyw@gmail.com> > --- > v4: > - show string value for each memblock flag > --- > mm/memblock.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index 511d4783dcf1..10d0ddbeebc1 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) > } > > #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) > +static const char * const flagname[] = { > + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", > + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", > + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", > + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", > +}; > > static int memblock_debug_show(struct seq_file *m, void *private) > { > struct memblock_type *type = m->private; > struct memblock_region *reg; > - int i; > + int i, j; > + unsigned int count = ARRAY_SIZE(flagname); > phys_addr_t end; > > for (i = 0; i < type->cnt; i++) { > @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) > end = reg->base + reg->size - 1; > > seq_printf(m, "%4d: ", i); > - seq_printf(m, "%pa..%pa\n", ®->base, &end); > + seq_printf(m, "%pa..%pa ", ®->base, &end); > + seq_printf(m, "%4d ", memblock_get_region_node(reg)); > + if (reg->flags) { > + for (j = 0; j < count; j++) { > + if (reg->flags & (1U << j)) { > + seq_printf(m, "%s\n", flagname[j]); > + break; The flags are mostly mutually exclusive because it's unlikely they are used together, but not because there are some restrictions on possible flags combinations. So generally it's possible to have multiple flags set on the same region. Sorry, I missed that in v3. > + } > + } > + if (j == count) > + seq_printf(m, "%s\n", "UNKNOWN"); > + } else { > + seq_printf(m, "%s\n", "NONE"); > + } > } > return 0; > } > -- > 2.34.1 >
On 5/23/23 21:35, Mike Rapoport wrote: > Hi, > > On Fri, May 19, 2023 at 06:53:21PM +0800, Yuwei Guan wrote: >> Currently, the memblock debugfs can display the count of memblock_type and >> the base and end of the reg. However, when memblock_mark_*() or >> memblock_set_node() is executed on some range, the information in the >> existing debugfs cannot make it clear why the address is not consecutive. >> >> For example, >> cat /sys/kernel/debug/memblock/memory >> 0: 0x0000000080000000..0x00000000901fffff >> 1: 0x0000000090200000..0x00000000905fffff >> 2: 0x0000000090600000..0x0000000092ffffff >> 3: 0x0000000093000000..0x00000000973fffff >> 4: 0x0000000097400000..0x00000000b71fffff >> 5: 0x00000000c0000000..0x00000000dfffffff >> 6: 0x00000000e2500000..0x00000000f87fffff >> 7: 0x00000000f8800000..0x00000000fa7fffff >> 8: 0x00000000fa800000..0x00000000fd3effff >> 9: 0x00000000fd3f0000..0x00000000fd3fefff >> 10: 0x00000000fd3ff000..0x00000000fd7fffff >> 11: 0x00000000fd800000..0x00000000fd901fff >> 12: 0x00000000fd902000..0x00000000fd909fff >> 13: 0x00000000fd90a000..0x00000000fd90bfff >> 14: 0x00000000fd90c000..0x00000000ffffffff >> 15: 0x0000000880000000..0x0000000affffffff >> >> So we can add flags and nid to this debugfs. >> >> For example, >> cat /sys/kernel/debug/memblock/memory >> 0: 0x0000000080000000..0x00000000901fffff 0 NONE >> 1: 0x0000000090200000..0x00000000905fffff 0 NOMAP >> 2: 0x0000000090600000..0x0000000092ffffff 0 NONE >> 3: 0x0000000093000000..0x00000000973fffff 0 NOMAP >> 4: 0x0000000097400000..0x00000000b71fffff 0 NONE >> 5: 0x00000000c0000000..0x00000000dfffffff 0 NONE >> 6: 0x00000000e2500000..0x00000000f87fffff 0 NONE >> 7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP >> 8: 0x00000000fa800000..0x00000000fd3effff 0 NONE >> 9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP >> 10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE >> 11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP >> 12: 0x00000000fd902000..0x00000000fd909fff 0 NONE >> 13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP >> 14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE >> 15: 0x0000000880000000..0x0000000affffffff 0 NONE >> >> Signed-off-by: Yuwei Guan <ssawgyw@gmail.com> >> --- >> v4: >> - show string value for each memblock flag >> --- >> mm/memblock.c | 24 ++++++++++++++++++++++-- >> 1 file changed, 22 insertions(+), 2 deletions(-) >> >> diff --git a/mm/memblock.c b/mm/memblock.c >> index 511d4783dcf1..10d0ddbeebc1 100644 >> --- a/mm/memblock.c >> +++ b/mm/memblock.c >> @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) >> } >> >> #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) >> +static const char * const flagname[] = { >> + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", >> + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", >> + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", >> + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", >> +}; >> >> static int memblock_debug_show(struct seq_file *m, void *private) >> { >> struct memblock_type *type = m->private; >> struct memblock_region *reg; >> - int i; >> + int i, j; >> + unsigned int count = ARRAY_SIZE(flagname); >> phys_addr_t end; >> >> for (i = 0; i < type->cnt; i++) { >> @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) >> end = reg->base + reg->size - 1; >> >> seq_printf(m, "%4d: ", i); >> - seq_printf(m, "%pa..%pa\n", ®->base, &end); >> + seq_printf(m, "%pa..%pa ", ®->base, &end); >> + seq_printf(m, "%4d ", memblock_get_region_node(reg)); >> + if (reg->flags) { >> + for (j = 0; j < count; j++) { >> + if (reg->flags & (1U << j)) { >> + seq_printf(m, "%s\n", flagname[j]); >> + break; > > The flags are mostly mutually exclusive because it's unlikely they are used > together, but not because there are some restrictions on possible flags > combinations. So generally it's possible to have multiple flags set on the > same region. But do we really need to account for that as of now, when no memblock region carries more than a single flag ? But in that case all flags here need to be printed with "|" in between ? > > Sorry, I missed that in v3. > >> + } >> + } >> + if (j == count) >> + seq_printf(m, "%s\n", "UNKNOWN"); >> + } else { >> + seq_printf(m, "%s\n", "NONE"); >> + } >> } >> return 0; >> } >> -- >> 2.34.1 >> >
On Wed, May 24, 2023 at 09:42:40AM +0530, Anshuman Khandual wrote: > On 5/23/23 21:35, Mike Rapoport wrote: > > Hi, > > > > On Fri, May 19, 2023 at 06:53:21PM +0800, Yuwei Guan wrote: > >> Currently, the memblock debugfs can display the count of memblock_type and > >> the base and end of the reg. However, when memblock_mark_*() or > >> memblock_set_node() is executed on some range, the information in the > >> existing debugfs cannot make it clear why the address is not consecutive. > >> > >> For example, > >> cat /sys/kernel/debug/memblock/memory > >> 0: 0x0000000080000000..0x00000000901fffff > >> 1: 0x0000000090200000..0x00000000905fffff > >> 2: 0x0000000090600000..0x0000000092ffffff > >> 3: 0x0000000093000000..0x00000000973fffff > >> 4: 0x0000000097400000..0x00000000b71fffff > >> 5: 0x00000000c0000000..0x00000000dfffffff > >> 6: 0x00000000e2500000..0x00000000f87fffff > >> 7: 0x00000000f8800000..0x00000000fa7fffff > >> 8: 0x00000000fa800000..0x00000000fd3effff > >> 9: 0x00000000fd3f0000..0x00000000fd3fefff > >> 10: 0x00000000fd3ff000..0x00000000fd7fffff > >> 11: 0x00000000fd800000..0x00000000fd901fff > >> 12: 0x00000000fd902000..0x00000000fd909fff > >> 13: 0x00000000fd90a000..0x00000000fd90bfff > >> 14: 0x00000000fd90c000..0x00000000ffffffff > >> 15: 0x0000000880000000..0x0000000affffffff > >> > >> So we can add flags and nid to this debugfs. > >> > >> For example, > >> cat /sys/kernel/debug/memblock/memory > >> 0: 0x0000000080000000..0x00000000901fffff 0 NONE > >> 1: 0x0000000090200000..0x00000000905fffff 0 NOMAP > >> 2: 0x0000000090600000..0x0000000092ffffff 0 NONE > >> 3: 0x0000000093000000..0x00000000973fffff 0 NOMAP > >> 4: 0x0000000097400000..0x00000000b71fffff 0 NONE > >> 5: 0x00000000c0000000..0x00000000dfffffff 0 NONE > >> 6: 0x00000000e2500000..0x00000000f87fffff 0 NONE > >> 7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP > >> 8: 0x00000000fa800000..0x00000000fd3effff 0 NONE > >> 9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP > >> 10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE > >> 11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP > >> 12: 0x00000000fd902000..0x00000000fd909fff 0 NONE > >> 13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP > >> 14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE > >> 15: 0x0000000880000000..0x0000000affffffff 0 NONE > >> > >> Signed-off-by: Yuwei Guan <ssawgyw@gmail.com> > >> --- > >> v4: > >> - show string value for each memblock flag > >> --- > >> mm/memblock.c | 24 ++++++++++++++++++++++-- > >> 1 file changed, 22 insertions(+), 2 deletions(-) > >> > >> diff --git a/mm/memblock.c b/mm/memblock.c > >> index 511d4783dcf1..10d0ddbeebc1 100644 > >> --- a/mm/memblock.c > >> +++ b/mm/memblock.c > >> @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) > >> } > >> > >> #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) > >> +static const char * const flagname[] = { > >> + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", > >> + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", > >> + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", > >> + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", > >> +}; > >> > >> static int memblock_debug_show(struct seq_file *m, void *private) > >> { > >> struct memblock_type *type = m->private; > >> struct memblock_region *reg; > >> - int i; > >> + int i, j; > >> + unsigned int count = ARRAY_SIZE(flagname); > >> phys_addr_t end; > >> > >> for (i = 0; i < type->cnt; i++) { > >> @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) > >> end = reg->base + reg->size - 1; > >> > >> seq_printf(m, "%4d: ", i); > >> - seq_printf(m, "%pa..%pa\n", ®->base, &end); > >> + seq_printf(m, "%pa..%pa ", ®->base, &end); > >> + seq_printf(m, "%4d ", memblock_get_region_node(reg)); > >> + if (reg->flags) { > >> + for (j = 0; j < count; j++) { > >> + if (reg->flags & (1U << j)) { > >> + seq_printf(m, "%s\n", flagname[j]); > >> + break; > > > > The flags are mostly mutually exclusive because it's unlikely they are used > > together, but not because there are some restrictions on possible flags > > combinations. So generally it's possible to have multiple flags set on the > > same region. > > But do we really need to account for that as of now, when no memblock region > carries more than a single flag ? Right now we don't care indeed, I'm a bit concerned of what will happen if we'd have regions with multiple flags set. > But in that case all flags here need to be printed with "|" in between ? We could use space rather than "|" for simplicity, but thinking more about it, I'm inclined to just take this version and we'll deal with multiple flags if/when required. > > Sorry, I missed that in v3. > > > >> + } > >> + } > >> + if (j == count) > >> + seq_printf(m, "%s\n", "UNKNOWN"); > >> + } else { > >> + seq_printf(m, "%s\n", "NONE"); > >> + } > >> } > >> return 0; > >> } > >> -- > >> 2.34.1 > >> > >
On Fri, May 19, 2023 at 06:53:21PM +0800, Yuwei Guan wrote: > Currently, the memblock debugfs can display the count of memblock_type and > the base and end of the reg. However, when memblock_mark_*() or > memblock_set_node() is executed on some range, the information in the > existing debugfs cannot make it clear why the address is not consecutive. > > For example, > cat /sys/kernel/debug/memblock/memory > 0: 0x0000000080000000..0x00000000901fffff > 1: 0x0000000090200000..0x00000000905fffff > 2: 0x0000000090600000..0x0000000092ffffff > 3: 0x0000000093000000..0x00000000973fffff > 4: 0x0000000097400000..0x00000000b71fffff > 5: 0x00000000c0000000..0x00000000dfffffff > 6: 0x00000000e2500000..0x00000000f87fffff > 7: 0x00000000f8800000..0x00000000fa7fffff > 8: 0x00000000fa800000..0x00000000fd3effff > 9: 0x00000000fd3f0000..0x00000000fd3fefff > 10: 0x00000000fd3ff000..0x00000000fd7fffff > 11: 0x00000000fd800000..0x00000000fd901fff > 12: 0x00000000fd902000..0x00000000fd909fff > 13: 0x00000000fd90a000..0x00000000fd90bfff > 14: 0x00000000fd90c000..0x00000000ffffffff > 15: 0x0000000880000000..0x0000000affffffff > > So we can add flags and nid to this debugfs. > > For example, > cat /sys/kernel/debug/memblock/memory > 0: 0x0000000080000000..0x00000000901fffff 0 NONE > 1: 0x0000000090200000..0x00000000905fffff 0 NOMAP > 2: 0x0000000090600000..0x0000000092ffffff 0 NONE > 3: 0x0000000093000000..0x00000000973fffff 0 NOMAP > 4: 0x0000000097400000..0x00000000b71fffff 0 NONE > 5: 0x00000000c0000000..0x00000000dfffffff 0 NONE > 6: 0x00000000e2500000..0x00000000f87fffff 0 NONE > 7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP > 8: 0x00000000fa800000..0x00000000fd3effff 0 NONE > 9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP > 10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE > 11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP > 12: 0x00000000fd902000..0x00000000fd909fff 0 NONE > 13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP > 14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE > 15: 0x0000000880000000..0x0000000affffffff 0 NONE > > Signed-off-by: Yuwei Guan <ssawgyw@gmail.com> Applied, thanks! > --- > v4: > - show string value for each memblock flag > --- > mm/memblock.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index 511d4783dcf1..10d0ddbeebc1 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) > } > > #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) > +static const char * const flagname[] = { > + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", > + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", > + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", > + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", > +}; > > static int memblock_debug_show(struct seq_file *m, void *private) > { > struct memblock_type *type = m->private; > struct memblock_region *reg; > - int i; > + int i, j; > + unsigned int count = ARRAY_SIZE(flagname); > phys_addr_t end; > > for (i = 0; i < type->cnt; i++) { > @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) > end = reg->base + reg->size - 1; > > seq_printf(m, "%4d: ", i); > - seq_printf(m, "%pa..%pa\n", ®->base, &end); > + seq_printf(m, "%pa..%pa ", ®->base, &end); > + seq_printf(m, "%4d ", memblock_get_region_node(reg)); > + if (reg->flags) { > + for (j = 0; j < count; j++) { > + if (reg->flags & (1U << j)) { > + seq_printf(m, "%s\n", flagname[j]); > + break; > + } > + } > + if (j == count) > + seq_printf(m, "%s\n", "UNKNOWN"); > + } else { > + seq_printf(m, "%s\n", "NONE"); > + } > } > return 0; > } > -- > 2.34.1 >
Hi Yuwei, On Fri, May 19, 2023 at 06:53:21PM +0800, Yuwei Guan wrote: > Currently, the memblock debugfs can display the count of memblock_type and > the base and end of the reg. However, when memblock_mark_*() or > memblock_set_node() is executed on some range, the information in the > existing debugfs cannot make it clear why the address is not consecutive. > > For example, > cat /sys/kernel/debug/memblock/memory > 0: 0x0000000080000000..0x00000000901fffff > 1: 0x0000000090200000..0x00000000905fffff > 2: 0x0000000090600000..0x0000000092ffffff > 3: 0x0000000093000000..0x00000000973fffff > 4: 0x0000000097400000..0x00000000b71fffff > 5: 0x00000000c0000000..0x00000000dfffffff > 6: 0x00000000e2500000..0x00000000f87fffff > 7: 0x00000000f8800000..0x00000000fa7fffff > 8: 0x00000000fa800000..0x00000000fd3effff > 9: 0x00000000fd3f0000..0x00000000fd3fefff > 10: 0x00000000fd3ff000..0x00000000fd7fffff > 11: 0x00000000fd800000..0x00000000fd901fff > 12: 0x00000000fd902000..0x00000000fd909fff > 13: 0x00000000fd90a000..0x00000000fd90bfff > 14: 0x00000000fd90c000..0x00000000ffffffff > 15: 0x0000000880000000..0x0000000affffffff > > So we can add flags and nid to this debugfs. > > For example, > cat /sys/kernel/debug/memblock/memory > 0: 0x0000000080000000..0x00000000901fffff 0 NONE > 1: 0x0000000090200000..0x00000000905fffff 0 NOMAP > 2: 0x0000000090600000..0x0000000092ffffff 0 NONE > 3: 0x0000000093000000..0x00000000973fffff 0 NOMAP > 4: 0x0000000097400000..0x00000000b71fffff 0 NONE > 5: 0x00000000c0000000..0x00000000dfffffff 0 NONE > 6: 0x00000000e2500000..0x00000000f87fffff 0 NONE > 7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP > 8: 0x00000000fa800000..0x00000000fd3effff 0 NONE > 9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP > 10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE > 11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP > 12: 0x00000000fd902000..0x00000000fd909fff 0 NONE > 13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP > 14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE > 15: 0x0000000880000000..0x0000000affffffff 0 NONE > > Signed-off-by: Yuwei Guan <ssawgyw@gmail.com> > --- > v4: > - show string value for each memblock flag > --- > mm/memblock.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index 511d4783dcf1..10d0ddbeebc1 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) > } > > #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) > +static const char * const flagname[] = { > + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", > + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", > + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", > + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", > +}; > > static int memblock_debug_show(struct seq_file *m, void *private) > { > struct memblock_type *type = m->private; > struct memblock_region *reg; > - int i; > + int i, j; > + unsigned int count = ARRAY_SIZE(flagname); > phys_addr_t end; > > for (i = 0; i < type->cnt; i++) { > @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) > end = reg->base + reg->size - 1; > > seq_printf(m, "%4d: ", i); > - seq_printf(m, "%pa..%pa\n", ®->base, &end); > + seq_printf(m, "%pa..%pa ", ®->base, &end); > + seq_printf(m, "%4d ", memblock_get_region_node(reg)); As Kefeng mentioned, the node id for reserved regions will be wrong, so this needs to be updated so that when reg->nid == MAX_NUMNODES we'll print e.g. 'x'. > + if (reg->flags) { > + for (j = 0; j < count; j++) { > + if (reg->flags & (1U << j)) { > + seq_printf(m, "%s\n", flagname[j]); > + break; > + } > + } > + if (j == count) > + seq_printf(m, "%s\n", "UNKNOWN"); > + } else { > + seq_printf(m, "%s\n", "NONE"); > + } > } > return 0; > } > -- > 2.34.1 >
Mike Rapoport <rppt@kernel.org> 于2023年5月27日周六 18:37写道: > > Hi Yuwei, > > On Fri, May 19, 2023 at 06:53:21PM +0800, Yuwei Guan wrote: > > Currently, the memblock debugfs can display the count of memblock_type and > > the base and end of the reg. However, when memblock_mark_*() or > > memblock_set_node() is executed on some range, the information in the > > existing debugfs cannot make it clear why the address is not consecutive. > > > > For example, > > cat /sys/kernel/debug/memblock/memory > > 0: 0x0000000080000000..0x00000000901fffff > > 1: 0x0000000090200000..0x00000000905fffff > > 2: 0x0000000090600000..0x0000000092ffffff > > 3: 0x0000000093000000..0x00000000973fffff > > 4: 0x0000000097400000..0x00000000b71fffff > > 5: 0x00000000c0000000..0x00000000dfffffff > > 6: 0x00000000e2500000..0x00000000f87fffff > > 7: 0x00000000f8800000..0x00000000fa7fffff > > 8: 0x00000000fa800000..0x00000000fd3effff > > 9: 0x00000000fd3f0000..0x00000000fd3fefff > > 10: 0x00000000fd3ff000..0x00000000fd7fffff > > 11: 0x00000000fd800000..0x00000000fd901fff > > 12: 0x00000000fd902000..0x00000000fd909fff > > 13: 0x00000000fd90a000..0x00000000fd90bfff > > 14: 0x00000000fd90c000..0x00000000ffffffff > > 15: 0x0000000880000000..0x0000000affffffff > > > > So we can add flags and nid to this debugfs. > > > > For example, > > cat /sys/kernel/debug/memblock/memory > > 0: 0x0000000080000000..0x00000000901fffff 0 NONE > > 1: 0x0000000090200000..0x00000000905fffff 0 NOMAP > > 2: 0x0000000090600000..0x0000000092ffffff 0 NONE > > 3: 0x0000000093000000..0x00000000973fffff 0 NOMAP > > 4: 0x0000000097400000..0x00000000b71fffff 0 NONE > > 5: 0x00000000c0000000..0x00000000dfffffff 0 NONE > > 6: 0x00000000e2500000..0x00000000f87fffff 0 NONE > > 7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP > > 8: 0x00000000fa800000..0x00000000fd3effff 0 NONE > > 9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP > > 10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE > > 11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP > > 12: 0x00000000fd902000..0x00000000fd909fff 0 NONE > > 13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP > > 14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE > > 15: 0x0000000880000000..0x0000000affffffff 0 NONE > > > > Signed-off-by: Yuwei Guan <ssawgyw@gmail.com> > > --- > > v4: > > - show string value for each memblock flag > > --- > > mm/memblock.c | 24 ++++++++++++++++++++++-- > > 1 file changed, 22 insertions(+), 2 deletions(-) > > > > diff --git a/mm/memblock.c b/mm/memblock.c > > index 511d4783dcf1..10d0ddbeebc1 100644 > > --- a/mm/memblock.c > > +++ b/mm/memblock.c > > @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) > > } > > > > #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) > > +static const char * const flagname[] = { > > + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", > > + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", > > + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", > > + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", > > +}; > > > > static int memblock_debug_show(struct seq_file *m, void *private) > > { > > struct memblock_type *type = m->private; > > struct memblock_region *reg; > > - int i; > > + int i, j; > > + unsigned int count = ARRAY_SIZE(flagname); > > phys_addr_t end; > > > > for (i = 0; i < type->cnt; i++) { > > @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) > > end = reg->base + reg->size - 1; > > > > seq_printf(m, "%4d: ", i); > > - seq_printf(m, "%pa..%pa\n", ®->base, &end); > > + seq_printf(m, "%pa..%pa ", ®->base, &end); > > + seq_printf(m, "%4d ", memblock_get_region_node(reg)); > > As Kefeng mentioned, the node id for reserved regions will be wrong, so > this needs to be updated so that when reg->nid == MAX_NUMNODES we'll print > e.g. 'x'. Hi Mike, How about print 'x' when reg->nid == MAX_NUMNODES, base on this patch, https://lore.kernel.org/linux-mm/44ce007d-8049-1cc9-7e2e-4ccb51a2867d@huawei.com/T/#m6d214d4ea8912b64f5efc9c3f51ae71aa057d1f1 diff --git a/mm/memblock.c b/mm/memblock.c index c5c80d9bcea3..3d449aaba052 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2169,17 +2169,21 @@ static int memblock_debug_show(struct seq_file *m, void *private) { struct memblock_type *type = m->private; struct memblock_region *reg; - int i, j; + int i, j, nid; unsigned int count = ARRAY_SIZE(flagname); phys_addr_t end; for (i = 0; i < type->cnt; i++) { reg = &type->regions[i]; end = reg->base + reg->size - 1; + nid = memblock_get_region_node(reg); seq_printf(m, "%4d: ", i); seq_printf(m, "%pa..%pa ", ®->base, &end); - seq_printf(m, "%4d ", memblock_get_region_node(reg)); + if (nid != MAX_NUMNODES) + seq_printf(m, "%4d ", nid); + else + seq_printf(m, "%4c ", 'x'); if (reg->flags) { for (j = 0; j < count; j++) { if (reg->flags & (1U << j)) { > > > + if (reg->flags) { > > + for (j = 0; j < count; j++) { > > + if (reg->flags & (1U << j)) { > > + seq_printf(m, "%s\n", flagname[j]); > > + break; > > + } > > + } > > + if (j == count) > > + seq_printf(m, "%s\n", "UNKNOWN"); > > + } else { > > + seq_printf(m, "%s\n", "NONE"); > > + } > > } > > return 0; > > } > > -- > > 2.34.1 > > > > -- > Sincerely yours, > Mike.
On Sun, May 28, 2023 at 10:38:03PM +0800, Yuwei Guan wrote: > Mike Rapoport <rppt@kernel.org> 于2023年5月27日周六 18:37写道: > > > > Hi Yuwei, > > > > On Fri, May 19, 2023 at 06:53:21PM +0800, Yuwei Guan wrote: > > > > > Signed-off-by: Yuwei Guan <ssawgyw@gmail.com> > > > --- > > > v4: > > > - show string value for each memblock flag > > > --- > > > mm/memblock.c | 24 ++++++++++++++++++++++-- > > > 1 file changed, 22 insertions(+), 2 deletions(-) > > > > > > diff --git a/mm/memblock.c b/mm/memblock.c > > > index 511d4783dcf1..10d0ddbeebc1 100644 > > > --- a/mm/memblock.c > > > +++ b/mm/memblock.c > > > @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) > > > } > > > > > > #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) > > > +static const char * const flagname[] = { > > > + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", > > > + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", > > > + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", > > > + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", > > > +}; > > > > > > static int memblock_debug_show(struct seq_file *m, void *private) > > > { > > > struct memblock_type *type = m->private; > > > struct memblock_region *reg; > > > - int i; > > > + int i, j; > > > + unsigned int count = ARRAY_SIZE(flagname); > > > phys_addr_t end; > > > > > > for (i = 0; i < type->cnt; i++) { > > > @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) > > > end = reg->base + reg->size - 1; > > > > > > seq_printf(m, "%4d: ", i); > > > - seq_printf(m, "%pa..%pa\n", ®->base, &end); > > > + seq_printf(m, "%pa..%pa ", ®->base, &end); > > > + seq_printf(m, "%4d ", memblock_get_region_node(reg)); > > > > As Kefeng mentioned, the node id for reserved regions will be wrong, so > > this needs to be updated so that when reg->nid == MAX_NUMNODES we'll print > > e.g. 'x'. > Hi Mike, > > How about print 'x' when reg->nid == MAX_NUMNODES, base on this patch, > https://lore.kernel.org/linux-mm/44ce007d-8049-1cc9-7e2e-4ccb51a2867d@huawei.com/T/#m6d214d4ea8912b64f5efc9c3f51ae71aa057d1f1 This is fine, can you please send a formal patch? > diff --git a/mm/memblock.c b/mm/memblock.c > index c5c80d9bcea3..3d449aaba052 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2169,17 +2169,21 @@ static int memblock_debug_show(struct seq_file > *m, void *private) > { > struct memblock_type *type = m->private; > struct memblock_region *reg; > - int i, j; > + int i, j, nid; > unsigned int count = ARRAY_SIZE(flagname); > phys_addr_t end; > > for (i = 0; i < type->cnt; i++) { > reg = &type->regions[i]; > end = reg->base + reg->size - 1; > + nid = memblock_get_region_node(reg); > > seq_printf(m, "%4d: ", i); > seq_printf(m, "%pa..%pa ", ®->base, &end); > - seq_printf(m, "%4d ", memblock_get_region_node(reg)); > + if (nid != MAX_NUMNODES) > + seq_printf(m, "%4d ", nid); > + else > + seq_printf(m, "%4c ", 'x'); > if (reg->flags) { > for (j = 0; j < count; j++) { > if (reg->flags & (1U << j)) { > > > > > > + if (reg->flags) { > > > + for (j = 0; j < count; j++) { > > > + if (reg->flags & (1U << j)) { > > > + seq_printf(m, "%s\n", flagname[j]); > > > + break; > > > + } > > > + } > > > + if (j == count) > > > + seq_printf(m, "%s\n", "UNKNOWN"); > > > + } else { > > > + seq_printf(m, "%s\n", "NONE"); > > > + } > > > } > > > return 0; > > > } > > > -- > > > 2.34.1 > > > > > > > -- > > Sincerely yours, > > Mike.
diff --git a/mm/memblock.c b/mm/memblock.c index 511d4783dcf1..10d0ddbeebc1 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) } #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) +static const char * const flagname[] = { + [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", + [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", + [ilog2(MEMBLOCK_NOMAP)] = "NOMAP", + [ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG", +}; static int memblock_debug_show(struct seq_file *m, void *private) { struct memblock_type *type = m->private; struct memblock_region *reg; - int i; + int i, j; + unsigned int count = ARRAY_SIZE(flagname); phys_addr_t end; for (i = 0; i < type->cnt; i++) { @@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size - 1; seq_printf(m, "%4d: ", i); - seq_printf(m, "%pa..%pa\n", ®->base, &end); + seq_printf(m, "%pa..%pa ", ®->base, &end); + seq_printf(m, "%4d ", memblock_get_region_node(reg)); + if (reg->flags) { + for (j = 0; j < count; j++) { + if (reg->flags & (1U << j)) { + seq_printf(m, "%s\n", flagname[j]); + break; + } + } + if (j == count) + seq_printf(m, "%s\n", "UNKNOWN"); + } else { + seq_printf(m, "%s\n", "NONE"); + } } return 0; }