All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 1/4] xen: indicate gcov in log messages
Date: Tue, 6 Sep 2016 15:06:47 +0100	[thread overview]
Message-ID: <20160906140647.GR18255@citrix.com> (raw)
In-Reply-To: <57CEE202020000780010C2AD@prv-mh.provo.novell.com>

On Tue, Sep 06, 2016 at 07:34:26AM -0600, Jan Beulich wrote:
> >>> On 06.09.16 at 14:47, <andrew.cooper3@citrix.com> wrote:
> > On 06/09/16 13:41, Wei Liu wrote:
> >> --- a/xen/drivers/char/console.c
> >> +++ b/xen/drivers/char/console.c
> >> @@ -735,10 +735,11 @@ void __init console_init_preirq(void)
> >>      spin_lock(&console_lock);
> >>      __putstr(xen_banner());
> >>      spin_unlock(&console_lock);
> >> -    printk("Xen version %d.%d%s (%s@%s) (%s) debug=%c %s\n",
> >> +    printk("Xen version %d.%d%s (%s@%s) (%s) debug=%c gcov=%c %s\n",
> > 
> > Please instead use
> > 
> > printk("Xen version %d.%d%s (%s@%s) (%s) debug=%c"
> > #ifdef CONFIG_GCOV
> > " gcov=y"
> > #endif
> > " %s\n",
> > 
> > Enabling gcov will be extremely rare in the grand scheme of things, and
> > this method causes zero overhead for the case where gcov is compiled
> > out.  (Similarly elsewhere.)
> 
> How about instead of the kind of ugly #ifdef-ery above, instead of
> 
> +#ifdef CONFIG_GCOV
> +#define gcov_build() 1
> +#else
> +#define gcov_build() 0
> +#endif
> 
> we'd have
> 
> +#ifdef CONFIG_GCOV
> +#define gcov_string "gcov=y"
> +#else
> +#define gcov_string ""
> +#endif
> 
> (with the identifier name open for improvement), which can then be
> embedded easily into any string literal?
> 

Now this patch looks like

---8<---
From 56718288f632d3a25bd3fe89777df99008a13d6e Mon Sep 17 00:00:00 2001
From: Wei Liu <wei.liu2@citrix.com>
Date: Fri, 2 Sep 2016 14:43:25 +0100
Subject: [PATCH] xen: indicate gcov in log messages

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v3: simplify code

Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/arm/traps.c        | 2 +-
 xen/arch/x86/x86_64/traps.c | 2 +-
 xen/drivers/char/console.c  | 2 +-
 xen/include/xen/lib.h       | 6 ++++++
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 9353ee7..39a05fd 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -141,7 +141,7 @@ static void print_xen_info(void)
 {
     char taint_str[TAINT_STRING_MAX_LEN];
 
-    printk("----[ Xen-%d.%d%s  %s  debug=%c  %s ]----\n",
+    printk("----[ Xen-%d.%d%s  %s  debug=%c " gcov_string "  %s ]----\n",
            xen_major_version(), xen_minor_version(), xen_extra_version(),
 #ifdef CONFIG_ARM_32
            "arm32",
diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c
index 16de0be..fc8cde6 100644
--- a/xen/arch/x86/x86_64/traps.c
+++ b/xen/arch/x86/x86_64/traps.c
@@ -31,7 +31,7 @@ static void print_xen_info(void)
 {
     char taint_str[TAINT_STRING_MAX_LEN];
 
-    printk("----[ Xen-%d.%d%s  x86_64  debug=%c  %s ]----\n",
+    printk("----[ Xen-%d.%d%s  x86_64  debug=%c " gcov_string "  %s ]----\n",
            xen_major_version(), xen_minor_version(), xen_extra_version(),
            debug_build() ? 'y' : 'n', print_tainted(taint_str));
 }
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 650035d..55ae31a 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -735,7 +735,7 @@ void __init console_init_preirq(void)
     spin_lock(&console_lock);
     __putstr(xen_banner());
     spin_unlock(&console_lock);
-    printk("Xen version %d.%d%s (%s@%s) (%s) debug=%c %s\n",
+    printk("Xen version %d.%d%s (%s@%s) (%s) debug=%c " gcov_string " %s\n",
            xen_major_version(), xen_minor_version(), xen_extra_version(),
            xen_compile_by(), xen_compile_domain(),
            xen_compiler(), debug_build() ? 'y' : 'n', xen_compile_date());
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index e518adc..d1171b7 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -26,6 +26,12 @@
 #define BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))
 #endif
 
+#ifdef CONFIG_GCOV
+#define gcov_string "gcov=y"
+#else
+#define gcov_string ""
+#endif
+
 #ifndef NDEBUG
 #define ASSERT(p) \
     do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-09-06 14:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 12:41 [PATCH v2 0/4] gcov: more cleanup Wei Liu
2016-09-06 12:41 ` [PATCH v2 1/4] xen: indicate gcov in log messages Wei Liu
2016-09-06 12:47   ` Andrew Cooper
2016-09-06 13:34     ` Jan Beulich
2016-09-06 14:06       ` Wei Liu [this message]
2016-09-06 14:16         ` Jan Beulich
2016-09-06 14:17         ` Andrew Cooper
2016-09-06 22:06   ` Stefano Stabellini
2016-09-06 12:41 ` [PATCH v2 2/4] gcov: collect more sections to constructor list Wei Liu
2016-09-06 13:35   ` Jan Beulich
2016-09-06 12:41 ` [PATCH v2 3/4] xen: replace TEST_COVERAGE with CONFIG_GCOV Wei Liu
2016-09-06 12:41 ` [PATCH v2 4/4] xen: make clear gcov support limitation in Kconfig Wei Liu
2016-09-06 13:37   ` Jan Beulich
2016-09-06 13:42     ` Andrew Cooper
2016-09-07  6:35 ` [PATCH v2 0/4] gcov: more cleanup Wei Liu

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=20160906140647.GR18255@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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.