linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Gal Pressman <galpress@amazon.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	Doug Ledford <dledford@redhat.com>,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next 1/2] RDMA/core: Introduce ratelimited ibdev printk functions
Date: Tue, 30 Jul 2019 18:41:48 +0300	[thread overview]
Message-ID: <20190730154148.GG4878@mtr-leonro.mtl.com> (raw)
In-Reply-To: <20190730151834.70993-2-galpress@amazon.com>

On Tue, Jul 30, 2019 at 06:18:33PM +0300, Gal Pressman wrote:
> Add ratelimited helpers to the ibdev_* printk functions.
> Implementation inspired by counterpart dev_*_ratelimited functions.
>
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  include/rdma/ib_verbs.h | 51 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
>
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c5f8a9f17063..356e6a105366 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -107,6 +107,57 @@ static inline
>  void ibdev_dbg(const struct ib_device *ibdev, const char *format, ...) {}
>  #endif
>
> +#define ibdev_level_ratelimited(ibdev_level, ibdev, fmt, ...)           \
> +do {                                                                    \
> +	static DEFINE_RATELIMIT_STATE(_rs,                              \
> +				      DEFAULT_RATELIMIT_INTERVAL,       \
> +				      DEFAULT_RATELIMIT_BURST);         \
> +	if (__ratelimit(&_rs))                                          \
> +		ibdev_level(ibdev, fmt, ##__VA_ARGS__);                 \
> +} while (0)
> +
> +#define ibdev_emerg_ratelimited(ibdev, fmt, ...) \
> +	ibdev_level_ratelimited(ibdev_emerg, ibdev, fmt, ##__VA_ARGS__)
> +#define ibdev_alert_ratelimited(ibdev, fmt, ...) \
> +	ibdev_level_ratelimited(ibdev_alert, ibdev, fmt, ##__VA_ARGS__)
> +#define ibdev_crit_ratelimited(ibdev, fmt, ...) \
> +	ibdev_level_ratelimited(ibdev_crit, ibdev, fmt, ##__VA_ARGS__)
> +#define ibdev_err_ratelimited(ibdev, fmt, ...) \
> +	ibdev_level_ratelimited(ibdev_err, ibdev, fmt, ##__VA_ARGS__)
> +#define ibdev_warn_ratelimited(ibdev, fmt, ...) \
> +	ibdev_level_ratelimited(ibdev_warn, ibdev, fmt, ##__VA_ARGS__)
> +#define ibdev_notice_ratelimited(ibdev, fmt, ...) \
> +	ibdev_level_ratelimited(ibdev_notice, ibdev, fmt, ##__VA_ARGS__)
> +#define ibdev_info_ratelimited(ibdev, fmt, ...) \
> +	ibdev_level_ratelimited(ibdev_info, ibdev, fmt, ##__VA_ARGS__)
> +
> +#if defined(CONFIG_DYNAMIC_DEBUG)
> +/* descriptor check is first to prevent flooding with "callbacks suppressed" */
> +#define ibdev_dbg_ratelimited(ibdev, fmt, ...)                          \
> +do {                                                                    \
> +	static DEFINE_RATELIMIT_STATE(_rs,                              \
> +				      DEFAULT_RATELIMIT_INTERVAL,       \
> +				      DEFAULT_RATELIMIT_BURST);         \
> +	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                 \
> +	if (DYNAMIC_DEBUG_BRANCH(descriptor) && __ratelimit(&_rs))      \
> +		__dynamic_ibdev_dbg(&descriptor, ibdev, fmt,            \
> +				    ##__VA_ARGS__);                     \
> +} while (0)
> +#elif defined(DEBUG)

When will you see this CONFIG_DEBUG set? I suspect only in private
out-of-tree builds which we are not really care. Also I can't imagine
system with this CONFIG_DEBUG and without CONFIG_DYNAMIC_DEBUG.

Thanks


> +#define ibdev_dbg_ratelimited(ibdev, fmt, ...)                          \
> +do {                                                                    \
> +	static DEFINE_RATELIMIT_STATE(_rs,                              \
> +				      DEFAULT_RATELIMIT_INTERVAL,       \
> +				      DEFAULT_RATELIMIT_BURST);         \
> +	if (__ratelimit(&_rs))                                          \
> +		ibdev_printk(KERN_DEBUG, ibdev, fmt, ##__VA_ARGS__);    \
> +} while (0)
> +#else
> +__printf(2, 3) __cold
> +static inline
> +void ibdev_dbg_ratelimited(const struct ib_device *ibdev, const char *format, ...) {}
> +#endif
> +
>  union ib_gid {
>  	u8	raw[16];
>  	struct {
> --
> 2.22.0
>

  reply	other threads:[~2019-07-30 15:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 15:18 [PATCH for-next 0/2] Ratelimited ibdev printk functions Gal Pressman
2019-07-30 15:18 ` [PATCH for-next 1/2] RDMA/core: Introduce ratelimited " Gal Pressman
2019-07-30 15:41   ` Leon Romanovsky [this message]
2019-07-31  7:22     ` Gal Pressman
2019-07-31  7:41       ` Leon Romanovsky
2019-07-31 10:51         ` Gal Pressman
2019-07-31 11:46           ` Leon Romanovsky
2019-07-31 12:56             ` Gal Pressman
2019-07-31 13:33               ` Leon Romanovsky
2019-07-31 14:19                 ` Gal Pressman
2019-07-31 14:50                   ` Leon Romanovsky
2019-07-31 15:26                     ` Gal Pressman
2019-07-31 17:54                       ` Leon Romanovsky
2019-07-30 15:18 ` [PATCH for-next 2/2] RDMA/efa: Rate limit admin queue error prints Gal Pressman

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=20190730154148.GG4878@mtr-leonro.mtl.com \
    --to=leon@kernel.org \
    --cc=dledford@redhat.com \
    --cc=galpress@amazon.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).