All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH 1/2] xen/lib: Introduce printk_once() and replace some opencoded examples
Date: Mon, 20 May 2019 02:24:21 -0600	[thread overview]
Message-ID: <5CE2643502000078002307B2@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <1558119524-318-1-git-send-email-andrew.cooper3@citrix.com>

>>> On 17.05.19 at 20:58, <andrew.cooper3@citrix.com> wrote:
> Reflow the ZynqMP message for grepability, and fix the omission of a newline.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
with two remarks:

> --- a/xen/include/xen/lib.h
> +++ b/xen/include/xen/lib.h
> @@ -105,6 +105,17 @@ debugtrace_printk(const char *fmt, ...) {}
>  #define _p(_x) ((void *)(unsigned long)(_x))
>  extern void printk(const char *format, ...)
>      __attribute__ ((format (printf, 1, 2)));
> +
> +#define printk_once(fmt, args...)               \
> +({                                              \
> +    static bool __read_mostly once_;            \
> +    if ( unlikely(!once_) )                     \
> +    {                                           \
> +        once_ = true;                           \
> +        printk(fmt, ## args);                   \
> +    }                                           \
> +})

Just like Linux we accept this having a small race window, i.e.
it not truly being "once" in unlikely cases. I think it would be
worthwhile to make this intention explicit in the commit
message.

Unlike Linux'es the macro doesn't have a "return value". Is
this intentional? I view this as particularly useful for the
WARN_ONCE() sort-of counterpart, but I have to admit I can't
immediately see a good use here, so I'm largely curious.
(The 2 uses I could find in x86-specific code in Linux look
to me like they'd better be WARN_ONCE().)

Jan



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

WARNING: multiple messages have this Message-ID (diff)
From: "Jan Beulich" <JBeulich@suse.com>
To: "Andrew Cooper" <andrew.cooper3@citrix.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH 1/2] xen/lib: Introduce printk_once() and replace some opencoded examples
Date: Mon, 20 May 2019 02:24:21 -0600	[thread overview]
Message-ID: <5CE2643502000078002307B2@prv1-mh.provo.novell.com> (raw)
Message-ID: <20190520082421.V_TfcxeXa-TOgL2LUQs-3jDRHgZ8RgEYl9dvqg0yQVk@z> (raw)
In-Reply-To: <1558119524-318-1-git-send-email-andrew.cooper3@citrix.com>

>>> On 17.05.19 at 20:58, <andrew.cooper3@citrix.com> wrote:
> Reflow the ZynqMP message for grepability, and fix the omission of a newline.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
with two remarks:

> --- a/xen/include/xen/lib.h
> +++ b/xen/include/xen/lib.h
> @@ -105,6 +105,17 @@ debugtrace_printk(const char *fmt, ...) {}
>  #define _p(_x) ((void *)(unsigned long)(_x))
>  extern void printk(const char *format, ...)
>      __attribute__ ((format (printf, 1, 2)));
> +
> +#define printk_once(fmt, args...)               \
> +({                                              \
> +    static bool __read_mostly once_;            \
> +    if ( unlikely(!once_) )                     \
> +    {                                           \
> +        once_ = true;                           \
> +        printk(fmt, ## args);                   \
> +    }                                           \
> +})

Just like Linux we accept this having a small race window, i.e.
it not truly being "once" in unlikely cases. I think it would be
worthwhile to make this intention explicit in the commit
message.

Unlike Linux'es the macro doesn't have a "return value". Is
this intentional? I view this as particularly useful for the
WARN_ONCE() sort-of counterpart, but I have to admit I can't
immediately see a good use here, so I'm largely curious.
(The 2 uses I could find in x86-specific code in Linux look
to me like they'd better be WARN_ONCE().)

Jan



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

  parent reply	other threads:[~2019-05-20  8:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 18:58 [PATCH 1/2] xen/lib: Introduce printk_once() and replace some opencoded examples Andrew Cooper
2019-05-17 18:58 ` [Xen-devel] " Andrew Cooper
2019-05-17 18:58 ` [PATCH 2/2] x86/mpparse: Don't print "limit reached" for every subsequent processor Andrew Cooper
2019-05-17 18:58   ` [Xen-devel] " Andrew Cooper
2019-05-20  8:26   ` Jan Beulich
2019-05-20  8:26     ` [Xen-devel] " Jan Beulich
2019-05-20  8:24 ` Jan Beulich [this message]
2019-05-20  8:24   ` [Xen-devel] [PATCH 1/2] xen/lib: Introduce printk_once() and replace some opencoded examples Jan Beulich
2019-05-31 17:20 ` Julien Grall
2019-05-31 17:20   ` [Xen-devel] " Julien Grall

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=5CE2643502000078002307B2@prv1-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wei.liu2@citrix.com \
    --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.