[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200819122405.88e9719e86ac7c3c44b4db32@linux-foundation.org>
Date: Wed, 19 Aug 2020 12:24:05 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Mike Rapoport <rppt@...nel.org>
Cc: Andy Lutomirski <luto@...nel.org>, Baoquan He <bhe@...hat.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Borislav Petkov <bp@...en8.de>,
Catalin Marinas <catalin.marinas@....com>,
Christoph Hellwig <hch@....de>, Daniel Axtens <dja@...ens.net>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Emil Renner Berthing <kernel@...il.dk>,
Ingo Molnar <mingo@...hat.com>,
Hari Bathini <hbathini@...ux.ibm.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Max Filippov <jcmvbkbc@...il.com>,
Michael Ellerman <mpe@...erman.id.au>,
Michal Simek <monstr@...str.eu>,
Mike Rapoport <rppt@...ux.ibm.com>,
Palmer Dabbelt <palmer@...belt.com>,
Paul Mackerras <paulus@...ba.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Peter Zijlstra <peterz@...radead.org>,
Russell King <linux@...linux.org.uk>,
Stafford Horne <shorne@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Will Deacon <will@...nel.org>,
Yoshinori Sato <ysato@...rs.sourceforge.jp>,
clang-built-linux@...glegroups.com,
iommu@...ts.linux-foundation.org, linux-arch@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-c6x-dev@...ux-c6x.org,
linux-kernel@...r.kernel.org, linux-mips@...r.kernel.org,
linux-mm@...ck.org, linux-riscv@...ts.infradead.org,
linux-s390@...r.kernel.org, linux-sh@...r.kernel.org,
linux-xtensa@...ux-xtensa.org, linuxppc-dev@...ts.ozlabs.org,
openrisc@...ts.librecores.org, sparclinux@...r.kernel.org,
uclinux-h8-devel@...ts.sourceforge.jp, x86@...nel.org
Subject: Re: [PATCH v3 09/17] memblock: make memblock_debug and related
functionality private
On Tue, 18 Aug 2020 18:16:26 +0300 Mike Rapoport <rppt@...nel.org> wrote:
> From: Mike Rapoport <rppt@...ux.ibm.com>
>
> The only user of memblock_dbg() outside memblock was s390 setup code and it
> is converted to use pr_debug() instead.
> This allows to stop exposing memblock_debug and memblock_dbg() to the rest
> of the kernel.
>
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -137,7 +137,10 @@ struct memblock_type physmem = {
> i < memblock_type->cnt; \
> i++, rgn = &memblock_type->regions[i])
>
> -int memblock_debug __initdata_memblock;
> +#define memblock_dbg(fmt, ...) \
> + if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> +
checkpatch doesn't like this much.
ERROR: Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic defects
#101: FILE: mm/memblock.c:140:
+#define memblock_dbg(fmt, ...) \
+ if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ...
#102: FILE: mm/memblock.c:141:
+ if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
ERROR: trailing statements should be on next line
#102: FILE: mm/memblock.c:141:
+ if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
The first one is significant:
if (foo)
memblock_dbg(...);
else
save_the_world();
could end up inadvertently destroying the planet.
This?
--- a/mm/memblock.c~memblock-make-memblock_debug-and-related-functionality-private-fix
+++ a/mm/memblock.c
@@ -137,8 +137,11 @@ struct memblock_type physmem = {
i < memblock_type->cnt; \
i++, rgn = &memblock_type->regions[i])
-#define memblock_dbg(fmt, ...) \
- if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+#define memblock_dbg(fmt, ...) \
+ do { \
+ if (memblock_debug) \
+ pr_info(fmt, ##__VA_ARGS__); \
+ } while (0)
static int memblock_debug __initdata_memblock;
static bool system_has_some_mirror __initdata_memblock = false;
_
Powered by blists - more mailing lists