From patchwork Thu Sep 30 04:43:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 12527243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBD66C433EF for ; Thu, 30 Sep 2021 04:43:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 49B5161353 for ; Thu, 30 Sep 2021 04:43:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49B5161353 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7D56A940088; Thu, 30 Sep 2021 00:43:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7855794003A; Thu, 30 Sep 2021 00:43:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 673C5940088; Thu, 30 Sep 2021 00:43:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 53BAA94003A for ; Thu, 30 Sep 2021 00:43:17 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 16F3039499 for ; Thu, 30 Sep 2021 04:43:17 +0000 (UTC) X-FDA: 78642995634.15.97CB4BB Received: from smtprelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by imf05.hostedemail.com (Postfix) with ESMTP id C3282506B7C3 for ; Thu, 30 Sep 2021 04:43:16 +0000 (UTC) Received: from omf18.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 6E6E0837F24A; Thu, 30 Sep 2021 04:43:16 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf18.hostedemail.com (Postfix) with ESMTPA id 9FE102EBFA4; Thu, 30 Sep 2021 04:43:15 +0000 (UTC) Message-ID: <623750dd31aa3fe5e45c416be98ab37707e2c45d.camel@perches.com> Subject: [PATCH] memblock: Neaten logging From: Joe Perches To: Mike Rapoport Cc: Andrew Morton , linux-mm , LKML Date: Wed, 29 Sep 2021 21:43:14 -0700 User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19csmIWk1lvSAhwFxDGSmuB2T445XKQSSo= X-HE-Tag: 1632976995-185363 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C3282506B7C3 X-Stat-Signature: 7o4939uf7s36t8c993phmg1qeroknuai Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=none (imf05.hostedemail.com: domain of joe@perches.com has no SPF policy when checking 216.40.44.229) smtp.mailfrom=joe@perches.com X-HE-Tag: 1632976996-268806 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use more typical kernel logging styles. o Add and use #define pr_fmt KBUILD_MODNAME ": " fmt o Neaten memblock_dbg to use %s: %pS: to output __func__ and caller o Convert existing uses of pr_ and memblock_dbg appropriately Logging output is now always prefixed with 'memblock: ' Debugging output is now prefixed with 'memblock: ', function and caller Signed-off-by: Joe Perches --- mm/memblock.c | 59 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 184dcd2e5d99..405335c966a8 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -6,6 +6,8 @@ * Copyright (C) 2001 Peter Bergner. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -146,10 +148,12 @@ static __refdata struct memblock_type *memblock_memory = &memblock.memory; i++, rgn = &memblock_type->regions[i]) #define memblock_dbg(fmt, ...) \ - do { \ - if (memblock_debug) \ - pr_info(fmt, ##__VA_ARGS__); \ - } while (0) +do { \ + if (memblock_debug) \ + pr_info("%s: %pS: " fmt, \ + __func__, __builtin_return_address(0), \ + ##__VA_ARGS__); \ +} while (0) static int memblock_debug __initdata_memblock; static bool system_has_some_mirror __initdata_memblock = false; @@ -447,14 +451,14 @@ static int __init_memblock memblock_double_array(struct memblock_type *type, new_array = addr ? __va(addr) : NULL; } if (!addr) { - pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n", + pr_err("Failed to double %s array from %ld to %ld entries !\n", type->name, type->max, type->max * 2); return -1; } new_end = addr + new_size - 1; - memblock_dbg("memblock: %s is doubled to %ld at [%pa-%pa]", - type->name, type->max * 2, &addr, &new_end); + memblock_dbg("%s is doubled to %ld at [%pa-%pa]\n", + type->name, type->max * 2, &addr, &new_end); /* * Found space, we now need to move the array over before we add the @@ -667,8 +671,7 @@ int __init_memblock memblock_add_node(phys_addr_t base, phys_addr_t size, { phys_addr_t end = base + size - 1; - memblock_dbg("%s: [%pa-%pa] nid=%d %pS\n", __func__, - &base, &end, nid, (void *)_RET_IP_); + memblock_dbg("[%pa-%pa] nid=%d\n", &base, &end, nid); return memblock_add_range(&memblock.memory, base, size, nid, 0); } @@ -688,8 +691,7 @@ int __init_memblock memblock_add(phys_addr_t base, phys_addr_t size) { phys_addr_t end = base + size - 1; - memblock_dbg("%s: [%pa-%pa] %pS\n", __func__, - &base, &end, (void *)_RET_IP_); + memblock_dbg("[%pa-%pa]\n", &base, &end); return memblock_add_range(&memblock.memory, base, size, MAX_NUMNODES, 0); } @@ -789,8 +791,7 @@ int __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size) { phys_addr_t end = base + size - 1; - memblock_dbg("%s: [%pa-%pa] %pS\n", __func__, - &base, &end, (void *)_RET_IP_); + memblock_dbg("[%pa-%pa]\n", &base, &end); return memblock_remove_range(&memblock.memory, base, size); } @@ -821,8 +822,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size) { phys_addr_t end = base + size - 1; - memblock_dbg("%s: [%pa-%pa] %pS\n", __func__, - &base, &end, (void *)_RET_IP_); + memblock_dbg("[%pa-%pa]\n", &base, &end); kmemleak_free_part_phys(base, size); return memblock_remove_range(&memblock.reserved, base, size); @@ -832,8 +832,7 @@ int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size) { phys_addr_t end = base + size - 1; - memblock_dbg("%s: [%pa-%pa] %pS\n", __func__, - &base, &end, (void *)_RET_IP_); + memblock_dbg("[%pa-%pa]\n", &base, &end); return memblock_add_range(&memblock.reserved, base, size, MAX_NUMNODES, 0); } @@ -843,8 +842,7 @@ int __init_memblock memblock_physmem_add(phys_addr_t base, phys_addr_t size) { phys_addr_t end = base + size - 1; - memblock_dbg("%s: [%pa-%pa] %pS\n", __func__, - &base, &end, (void *)_RET_IP_); + memblock_dbg("[%pa-%pa]\n", &base, &end); return memblock_add_range(&physmem, base, size, MAX_NUMNODES, 0); } @@ -1409,9 +1407,8 @@ phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size, phys_addr_t start, phys_addr_t end) { - memblock_dbg("%s: %llu bytes align=0x%llx from=%pa max_addr=%pa %pS\n", - __func__, (u64)size, (u64)align, &start, &end, - (void *)_RET_IP_); + memblock_dbg("%llu bytes align=0x%llx from=%pa max_addr=%pa\n", + (u64)size, (u64)align, &start, &end); return memblock_alloc_range_nid(size, align, start, end, NUMA_NO_NODE, false); } @@ -1510,9 +1507,8 @@ void * __init memblock_alloc_exact_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", - __func__, (u64)size, (u64)align, nid, &min_addr, - &max_addr, (void *)_RET_IP_); + memblock_dbg("%llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa\n", + (u64)size, (u64)align, nid, &min_addr, &max_addr); return memblock_alloc_internal(size, align, min_addr, max_addr, nid, true); @@ -1542,9 +1538,8 @@ void * __init memblock_alloc_try_nid_raw( phys_addr_t min_addr, phys_addr_t max_addr, int nid) { - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", - __func__, (u64)size, (u64)align, nid, &min_addr, - &max_addr, (void *)_RET_IP_); + memblock_dbg("%llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa\n", + (u64)size, (u64)align, nid, &min_addr, &max_addr); return memblock_alloc_internal(size, align, min_addr, max_addr, nid, false); @@ -1574,9 +1569,8 @@ void * __init memblock_alloc_try_nid( { void *ptr; - memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pS\n", - __func__, (u64)size, (u64)align, nid, &min_addr, - &max_addr, (void *)_RET_IP_); + memblock_dbg("%llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa\n", + (u64)size, (u64)align, nid, &min_addr, &max_addr); ptr = memblock_alloc_internal(size, align, min_addr, max_addr, nid, false); if (ptr) @@ -1599,8 +1593,7 @@ void __init __memblock_free_late(phys_addr_t base, phys_addr_t size) phys_addr_t cursor, end; end = base + size - 1; - memblock_dbg("%s: [%pa-%pa] %pS\n", - __func__, &base, &end, (void *)_RET_IP_); + memblock_dbg("[%pa-%pa]\n", &base, &end); kmemleak_free_part_phys(base, size); cursor = PFN_UP(base); end = PFN_DOWN(base + size);