From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BACF1A9B24 for ; Mon, 24 Aug 2026 15:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787584521; cv=none; b=fPnQOmFbOsNItrEgcy4ycXxoBj6JZNVidIGs4up8gd+RvBBFT3YdhR198f7MiS3nzNlD0V9/9avHANjY17f3IdWDTZsGMGSt0IGOpirYczkg6KKg98JDRXwpsyB3Ymo2SlZgBJWF5RpqYvs0vo7r80V0dBWlssERoKmreLGEyE0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787584521; c=relaxed/simple; bh=fpgw6xtJpRcYOqbiGQAA5PuysEMA3Cbr0eiM/C0P26o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PRpIeU/YFhm8wTv6xcIbBCLVWqfOSxfIgF5URak3zm0PFFVQpgMwdEavOViAaSebrZKNxBmBAVXSeGOs7WT+qq7syWD9HwPwZ9yJFUDvmfOPZiE0pv5GkZkb1KspkxNodlDwJB/wdtuIbfvgogGNTA1xDucQXkCJfNF3WaOVAZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fMmZABfg; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fMmZABfg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0AD81F000E9; Mon, 24 Aug 2026 15:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787584519; bh=dnL3NIui6/xO3HGPt06qkNh1ukWzVG67kuq9rhxtTII=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=fMmZABfgdEK6C8vXUApy+4qYu+g50cCS7qrqCWXLuhVwRMnSZQZV/xkO18HUGV7uO d7D5iT3XcCNgEdCv5dpkZ93oovNDBrQgg4AQGb3KqFB94p2IQGIsp3rsWt1AG3nCWl h736aBexqYknhhQVo9M7RdcFLM5WqXmH+EQdADh253UMENMP9yPCXVPXr/n0Ld1eWY 25kO5ZaWjHNZNxXPumEQZ0HYHC02yz7GQCBqoYJ7k5oQYJkLx3RpjnznyohfSqo4fM sKPeW7DFyRzsTNhEKfG/LwvTA1SZ7eG/UpPgeABKZlN4fyz3SAz+UNsky+bwJUNBTh SUJvbf9GwySug== Date: Mon, 24 Aug 2026 18:15:13 +0300 From: Mike Rapoport To: Meijing Zhao Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wandun Chen , Meijing Zhao Subject: Re: [PATCH v2 RESEND 2/3] mm: memblock: show all region flags in debugfs Message-ID: References: <20260821020910.3428585-1-zhaomeijing100@gmail.com> <20260821020910.3428585-3-zhaomeijing100@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260821020910.3428585-3-zhaomeijing100@gmail.com> On Fri, Aug 21, 2026 at 10:09:09AM +0800, Meijing Zhao wrote: > From: Meijing Zhao > > Commit 493f349e38d0 ("memblock: Add flags and nid info in memblock > debugfs") made memblock_debug_show() stop after finding the first set > flag. A memblock region can carry multiple flags, so the remaining flags > are hidden from debugfs. > > In particular, memory allocated for HugeTLB pages is reserved with both > MEMBLOCK_RSRV_KERN and MEMBLOCK_RSRV_HUGETLB, but debugfs only reports > RSV_KERN. > > Walk all bits in the region flags and print every set flag separated by > "|". Keep walking beyond flagname[] so that a set flag without a known > name is reported as UNKNOWN rather than silently ignored. > > A HugeTLB reservation is now shown as: > > RSV_KERN|RSV_HUGETLB > > instead of: > > RSV_KERN > > Fixes: 493f349e38d0 ("memblock: Add flags and nid info in memblock debugfs") > Signed-off-by: Meijing Zhao > --- > mm/memblock.c | 22 ++++++++++++++-------- > 1 file changed, 14 insertions(+), 8 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index f2952d725c10..36a8d2a9378d 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2895,7 +2895,9 @@ static int memblock_debug_show(struct seq_file *m, void *private) > struct memblock_region *reg; > int i, j, nid; > unsigned int count = ARRAY_SIZE(flagname); > + unsigned int flags; > phys_addr_t end; > + bool first; > > for (i = 0; i < type->cnt; i++) { > reg = &type->regions[i]; > @@ -2909,16 +2911,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) > else > seq_printf(m, "%4c ", 'x'); > if (reg->flags) { > - for (j = 0; j < count; j++) { > - if (reg->flags & (1U << j)) { > - seq_printf(m, "%s\n", flagname[j]); > - break; > - } > + flags = reg->flags; > + first = true; first and flags can be declared here. > + for (j = 0; flags; j++, flags >>= 1) { > + if (!(flags & 1)) > + continue; > + if (!first) > + seq_putc(m, '|'); > + seq_puts(m, j < count && flagname[j] ? > + flagname[j] : "UNKNOWN"); Can we really have both j < count and !flagname[j]? > + first = false; > } > - if (j == count) > - seq_printf(m, "%s\n", "UNKNOWN"); > + seq_putc(m, '\n'); > } else { > - seq_printf(m, "%s\n", "NONE"); > + seq_puts(m, "NONE\n"); No need to change this > } > } > return 0; > -- > 2.25.1 > -- Sincerely yours, Mike.