Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp705921pxy; Wed, 5 May 2021 11:43:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztBvXnPiiZA+emJVYLl1wdlBb8pu2lYl19TObgXPfG3C1LkCgZx9nk1rU+PBmpMpDcnglX X-Received: by 2002:a17:90a:3042:: with SMTP id q2mr12835895pjl.21.1620240182993; Wed, 05 May 2021 11:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620240182; cv=none; d=google.com; s=arc-20160816; b=jdlJ33zRIBZqbDlwm67Dlv/tSv4PK3P5w2loDEkAKi39shfs41d2vZQhVMjKC5TLyU z25MUrfDJmUsT971ciZXEaVbtEjV3gP9rwh41qwX9yVfR7ITnt4N9qpxISvwhqN/wuAW L1D/mAT76hHNAb4pQ67FyISn6Q+sXtkMIT2hNNSkTzejT1rIqAFeknsXYdKkq79miiSO CVv1vMCugCwFQjAZTMYgJHLhy9Z7bT5GMjsL84tjThGpoN1I4ovyl9/inxZt4C5yzjlV sYLzogQ/hFBcuZN3yprVYaDv8MxlG9zM91Te61+wHKvZRYC7Ex+VJKvJlmD81SNR0IjC 19aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=xPiqDUobm90PwEQWaNvmZpAUGE8LEPZKn4LE1Dhhu88=; b=Itm4ibaTj6ndWmZM6T0+B2fxK/YvreLRsgcRkfWAq4EvFhW5aFU4maoSJIbHtO7MKJ mwi/y700cEj/MA8SjTtUoN5/pl9Ir2TBYdbKzXx7WhlT8dCeIinCe/5eOBno5tuvJC2H Oxe7FxdS0dGtgVErrI41uQshcNGf3EhlTYlQR5Np5uNjrYs8mXOdNFhkiAAus9rJrCQJ ISTmvGhZzfN4QnkTjpCzVqGAQSAQwv9PS5uRi/mdcu6gIxCnwW26tJXLPCOcrn3qUev2 f2OdJDYrrhxRPo4yCn6lRNP2HVHU8W3NLDWY5sFrtG5ht+pPBHIzERBfTxnmW58QYlT7 QC8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fMNsg1SJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e124si35813pgc.395.2021.05.05.11.42.49; Wed, 05 May 2021 11:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fMNsg1SJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S235050AbhEESlo (ORCPT + 99 others); Wed, 5 May 2021 14:41:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234140AbhEESlo (ORCPT ); Wed, 5 May 2021 14:41:44 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DE05C061574 for ; Wed, 5 May 2021 11:40:47 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id g65so2003598wmg.2 for ; Wed, 05 May 2021 11:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=xPiqDUobm90PwEQWaNvmZpAUGE8LEPZKn4LE1Dhhu88=; b=fMNsg1SJ+gZkYd5zRGwWKYszUpZVsEgoh1d3VdwmOTitwIdCoUQ5RwuzEWrucNy8Gb 2dUEIxTv15YNpEDIBFuFHfE0X4bhlbuFQK9y3tDTGHsspKJ1doqK9fP+rytuMALuehkm macLrDJYZQDDYL8TlFhUTPwrLUjf3FB8RvNkWup4sg3KVnMF+/PkTNeGr1koxUi9htsK fBbMMtyeqp98F+v6/G8qPW/BXlcSd3KK749lFvLl5Md1XlAnRNuZb7ZG/NTOuUAKwK3r yXh8+KwbWuAK2psXM1hafo/mrYgNib/zApqJGdLGI8HqHhNjIyzKnLSf0UC7ZtquXc7d 8UIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xPiqDUobm90PwEQWaNvmZpAUGE8LEPZKn4LE1Dhhu88=; b=Bo1LdlqKdtU4ml3AAzzU5xOMf0hE0AARQdoHbRdHN3YA7B/2CCZr3nnulTUgpFIsm5 1mZUn6+Y9BK/MWZ6NXnOmxpKNWeQC9oo6LfiPd+gEwj3NeQCr1z0bUZo2+EWMGwSvYUG ePtLfKG+rAc4Sx7rcQu6dfH4k/hy+HrdtBWVJZV9Iu4YPhERuAHAAPXWpUnvwVX/0S3Y tEIzvAg9F4Ampud9UPWnCs3HT+JNZGipts3Cs0NqI1feEokrv2AvnVKJVKJmTWJGSmJe ZeklmoTry2DwANB5E4kQ+gitamYoMQvGqGkbCEvGSvC5yIMjaJzb6ujLSxa+XgYh+e+L 6few== X-Gm-Message-State: AOAM533CE+leB/hA/52TQwnmRxpYNPVdnlDpUkV0k50vnxXJSLGfWUqu 3K5xvf+PCr1l9cyFV3zXpHwL8CHMkX0mVg== X-Received: by 2002:a1c:2786:: with SMTP id n128mr11713522wmn.82.1620240045965; Wed, 05 May 2021 11:40:45 -0700 (PDT) Received: from ?IPv6:2003:ea:8f38:4600:e1a9:6a7f:ee3b:8d0b? (p200300ea8f384600e1a96a7fee3b8d0b.dip0.t-ipconnect.de. [2003:ea:8f38:4600:e1a9:6a7f:ee3b:8d0b]) by smtp.googlemail.com with ESMTPSA id r36sm7119139wmp.18.2021.05.05.11.40.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 May 2021 11:40:45 -0700 (PDT) To: Jason Baron , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: Linux Kernel Mailing List References: <6d55670d-2f06-d768-699f-5a79cece6ce0@gmail.com> From: Heiner Kallweit Subject: Re: [PATCH 2/2] x86/e820: Use pr_debug to avoid spamming dmesg log with debug messages Message-ID: <59985635-665b-773f-de8f-b15fe3f60196@gmail.com> Date: Wed, 5 May 2021 20:40:36 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.05.2021 18:58, Jason Baron wrote: > > > On 5/3/21 3:40 PM, Heiner Kallweit wrote: >> e820 emits quite some debug messages to the dmesg log. Let's restrict >> this to cases where the debug output is actually requested. Switch to >> pr_debug() for this purpose and make sure by checking the return code >> that pr_cont() is only called if applicable. >> >> Signed-off-by: Heiner Kallweit >> --- >> arch/x86/kernel/e820.c | 27 ++++++++++++++++----------- >> 1 file changed, 16 insertions(+), 11 deletions(-) >> >> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c >> index bc0657f0d..67ad4d8f0 100644 >> --- a/arch/x86/kernel/e820.c >> +++ b/arch/x86/kernel/e820.c >> @@ -465,6 +465,7 @@ __e820__range_update(struct e820_table *table, u64 start, u64 size, enum e820_ty >> u64 end; >> unsigned int i; >> u64 real_updated_size = 0; >> + int printed; >> >> BUG_ON(old_type == new_type); >> >> @@ -472,11 +473,13 @@ __e820__range_update(struct e820_table *table, u64 start, u64 size, enum e820_ty >> size = ULLONG_MAX - start; >> >> end = start + size; >> - printk(KERN_DEBUG "e820: update [mem %#010Lx-%#010Lx] ", start, end - 1); >> - e820_print_type(old_type); >> - pr_cont(" ==> "); >> - e820_print_type(new_type); >> - pr_cont("\n"); >> + printed = pr_debug("e820: update [mem %#010Lx-%#010Lx] ", start, end - 1); >> + if (printed > 0) { >> + e820_print_type(old_type); >> + pr_cont(" ==> "); >> + e820_print_type(new_type); >> + pr_cont("\n"); >> + } > > > Hi Heiner, > > We've been doing these like: > > DEFINE_DYNAMIC_DEBUG_METADATA(e820_dbg, "e820 verbose mode"); > > . > . > . > > if (DYNAMIC_DEBUG_BRANCH(e820_debg)) { > printk(KERN_DEBUG "e820: update [mem %#010Lx-%#010Lx] ", start, end - 1); > e820_print_type(old_type); > pr_cont(" ==> "); > e820_print_type(new_type); > pr_cont("\n"); > } > > > You could then have one DEFINE_DYNAMIC_DEBUG_METADATA statement - such that it enables > it all in one go, or do separate ones that enable it how you see fit. > > Would that work here? > How would we handle the case that CONFIG_DYNAMIC_DEBUG_CORE isn't defined? Then also DEFINE_DYNAMIC_DEBUG_METADATA isn't defined and we'd need to duplicate the logic used here: #if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) #include #define pr_debug(fmt, ...) \ dynamic_pr_debug(fmt, ##__VA_ARGS__) #elif defined(DEBUG) #define pr_debug(fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #define pr_debug(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #endif IMO it's better to have the complexity of using DEFINE_DYNAMIC_DEBUG_METADATA only once in the implementation of dynamic_pr_debug(), and not in every code that wants to use pr_debug() in combination with pr_cont(). Also I think that to a certain extent pr_debug() is broken currently in case of dynamic debugging because it has no return value, one drawback of using not type-safe macros. This doesn't hurt so far because no caller seems to check the return value or very few people have dynamic debugging enabled. > Thanks, > > -Jason > Heiner >> >> for (i = 0; i < table->nr_entries; i++) { >> struct e820_entry *entry = &table->entries[i]; >> @@ -540,7 +543,7 @@ static u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type o >> /* Remove a range of memory from the E820 table: */ >> u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type) >> { >> - int i; >> + int printed, i; >> u64 end; >> u64 real_removed_size = 0; >> >> @@ -548,10 +551,12 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool >> size = ULLONG_MAX - start; >> >> end = start + size; >> - printk(KERN_DEBUG "e820: remove [mem %#010Lx-%#010Lx] ", start, end - 1); >> - if (check_type) >> - e820_print_type(old_type); >> - pr_cont("\n"); >> + printed = pr_debug("e820: remove [mem %#010Lx-%#010Lx] ", start, end - 1); >> + if (printed > 0) { >> + if (check_type) >> + e820_print_type(old_type); >> + pr_cont("\n"); >> + } >> >> for (i = 0; i < e820_table->nr_entries; i++) { >> struct e820_entry *entry = &e820_table->entries[i]; >> @@ -1230,7 +1235,7 @@ void __init e820__reserve_resources_late(void) >> if (start >= end) >> continue; >> >> - printk(KERN_DEBUG "e820: reserve RAM buffer [mem %#010llx-%#010llx]\n", start, end); >> + pr_debug("e820: reserve RAM buffer [mem %#010llx-%#010llx]\n", start, end); >> reserve_region_with_split(&iomem_resource, start, end, "RAM buffer"); >> } >> } >>