All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: Qian Cai <quic_qiancai@quicinc.com>,
	linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
	linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] memblock: exclude NOMAP regions from kmemleak
Date: Wed, 20 Oct 2021 11:13:06 +0100	[thread overview]
Message-ID: <YW/rsjxNj+m7aL/a@arm.com> (raw)
In-Reply-To: <YW/Hb4sVWGOIxzUk@kernel.org>

On Wed, Oct 20, 2021 at 10:38:23AM +0300, Mike Rapoport wrote:
> On Tue, Oct 19, 2021 at 09:33:11PM +0300, Mike Rapoport wrote:
> > On Tue, Oct 19, 2021 at 01:59:22PM -0400, Qian Cai wrote:
> > > [	0.000000][	T0] Booting Linux on physical CPU 0x0000000000 [0x503f0002]
> > > [	0.000000][	T0] Linux version 5.15.0-rc6-next-20211019+ (root@admin5) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #104 SMP Tue Oct 19 17:36:17 UTC 2021
> > > [	0.000000][	T0] earlycon: pl11 at MMIO32 0x0000000012600000 (options '')
> > > [	0.000000][	T0] printk: bootconsole [pl11] enabled
> > > [	0.000000][	T0] efi: Getting UEFI parameters from /chosen in DT:
> > > [	0.000000][	T0] efi:   System Table     	: 0x0000009ff7de0018
> > > [	0.000000][	T0] efi:   MemMap Address   	: 0x0000009fe6dae018
> > > [	0.000000][	T0] efi:   MemMap Size      	: 0x0000000000000600
> > > [	0.000000][	T0] efi:   MemMap Desc. Size	: 0x0000000000000030
> > > [	0.000000][	T0] efi:   MemMap Desc. Version : 0x0000000000000001
> > > [	0.000000][	T0] efi: EFI v2.70 by American Megatrends
> > > [	0.000000][	T0] efi: ACPI 2.0=0x9ff5b40000 SMBIOS 3.0=0x9ff686fd98 ESRT=0x9ff1d18298 MEMRESERVE=0x9fe6dacd98  
> > > [	0.000000][	T0] efi: Processing EFI memory map:
> > > [	0.000000][	T0] efi:   0x000090000000-0x000091ffffff [Conventional|   |  |  |  |  |  |  |  |  |   |WB|WT|WC|UC]
> > > [	0.000000][	T0] efi:   0x000092000000-0x0000928fffff [Runtime Data|RUN|  |  |  |  |  |  |  |  |   |WB|WT|WC|UC]
> > > [	0.000000][	T0] ------------[ cut here ]------------
> > > [	0.000000][	T0] kernel BUG at mm/kmemleak.c:1140!
> > > [	0.000000][	T0] Internal error: Oops - BUG: 0 [#1] SMP
> > > 
> > > I did not quite figure out where this BUG() was triggered and I did not
> > 
> > This is from here:
> > arch/arm64/include/asm/memory.h:
> > 
> > #define PHYS_OFFSET         ({ VM_BUG_ON(memstart_addr & 1); memstart_addr; })
> > 
> > kmemleak_free_part_phys() does __va() which uses PHYS_OFFSET and all this
> > happens before memstart_addr is set.
> > 
> > I'll try to see how this can be untangled...
>  
> This late in the cycle I can only think of reverting kmemleak wavier from
> memblock_mark_nomap() and putting it in
> early_init_dt_alloc_reserved_memory_arch() being the only user setting
> MEMBLOCK_NOMAP to an allocated chunk rather than marking NOMAP "unusable"
> memory reported by firmware.

BTW, would something like this work:

diff --git a/mm/memblock.c b/mm/memblock.c
index aa87ff5ae2a4..7e67378a8ddf 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -939,7 +939,7 @@ int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size)
 {
 	int ret = memblock_setclr_flag(base, size, 1, MEMBLOCK_NOMAP);
 
-	if (!ret)
+	if (!ret && memblock_is_region_reserved(base, size))
 		kmemleak_free_part_phys(base, size);
 
 	return ret;

-- 
Catalin

  parent reply	other threads:[~2021-10-20 10:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13  5:47 [PATCH] memblock: exclude NOMAP regions from kmemleak Mike Rapoport
2021-10-13  7:45 ` Catalin Marinas
2021-10-13 11:35   ` Mike Rapoport
2021-10-19  3:55 ` Qian Cai
2021-10-19  5:45   ` Mike Rapoport
2021-10-19 11:37     ` Catalin Marinas
2021-10-19 15:06       ` Qian Cai
2021-10-19 15:53         ` Catalin Marinas
2021-10-19 17:59           ` Qian Cai
2021-10-19 18:33             ` Mike Rapoport
2021-10-20  7:38               ` Mike Rapoport
2021-10-20  8:18                 ` Catalin Marinas
2021-10-20  8:42                   ` Mike Rapoport
2021-10-20  9:33                     ` Catalin Marinas
2021-10-20 10:13                 ` Catalin Marinas [this message]
2021-10-20 10:39                   ` Mike Rapoport
2021-10-19  4:21 ` Anshuman Khandual

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YW/rsjxNj+m7aL/a@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=quic_qiancai@quicinc.com \
    --cc=rppt@kernel.org \
    --cc=rppt@linux.ibm.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vladimir.zapolskiy@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.