All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm: Add DRM_DEV_INFO_RATELIMITED
@ 2019-01-18 18:06 Kristian H. Kristensen
       [not found] ` <20190118180717.163547-1-hoegsberg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2019-01-21 17:22 ` [PATCH 1/2] drm: Add DRM_DEV_INFO_RATELIMITED kbuild test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Kristian H. Kristensen @ 2019-01-18 18:06 UTC (permalink / raw)
  To: dri-devel; +Cc: Kristian H. Kristensen

Refactor the ratelimit printk to a helper macro and implement
DRM_DEV_INFO_RATELIMITED and DRM_DEV_ERROR_RATELIMITED using the helper.

Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
---
 include/drm/drm_print.h | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index afbc3beef089a..6a592f8e1ebd6 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -285,6 +285,22 @@ void drm_err(const char *format, ...);
 #define _DRM_PRINTK(once, level, fmt, ...)				\
 	printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
 
+/**
+ * Rate limited output.  Like _DRM_PRINTK() but won't flood the log.
+ *
+ * @dev: device pointer
+ * @fmt: printf() like format string.
+ */
+#define _DRM_DEV_PRINTK_RATELIMITED(dev, level, fmt, ...)		\
+({									\
+	static DEFINE_RATELIMIT_STATE(_rs,				\
+				      DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+									\
+	if (__ratelimit(&_rs))						\
+		drm_dev_printk(dev, level, fmt, ##__VA_ARGS__);		\
+})
+
 #define DRM_INFO(fmt, ...)						\
 	_DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
 #define DRM_NOTE(fmt, ...)						\
@@ -317,20 +333,17 @@ void drm_err(const char *format, ...);
  * @fmt: printf() like format string.
  */
 #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...)			\
-({									\
-	static DEFINE_RATELIMIT_STATE(_rs,				\
-				      DEFAULT_RATELIMIT_INTERVAL,	\
-				      DEFAULT_RATELIMIT_BURST);		\
-									\
-	if (__ratelimit(&_rs))						\
-		DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__);			\
-})
+	_DRM_DEV_PRINTK_RATELIMITED(dev, KERN_ERR, "*ERROR*" fmt, ##__VA_ARGS__)
+
 #define DRM_ERROR_RATELIMITED(fmt, ...)					\
 	DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
 
 #define DRM_DEV_INFO(dev, fmt, ...)					\
 	drm_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__)
 
+#define DRM_DEV_INFO_RATELIMITED(dev, fmt, ...)				\
+	_DRM_DEV_PRINTK_RATELIMITED(dev, KERN_INFO, fmt, ##__VA_ARGS__)
+
 #define DRM_DEV_INFO_ONCE(dev, fmt, ...)				\
 ({									\
 	static bool __print_once __read_mostly;				\
-- 
2.20.1.321.g9e740568ce-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-01-24  0:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-18 18:06 [PATCH 1/2] drm: Add DRM_DEV_INFO_RATELIMITED Kristian H. Kristensen
     [not found] ` <20190118180717.163547-1-hoegsberg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2019-01-18 18:07   ` [PATCH 2/2] drm/msm: Use DRM_DEV_INFO_RATELIMITED for shrinker messages Kristian H. Kristensen
     [not found]     ` <20190118180717.163547-2-hoegsberg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2019-01-21  9:37       ` Jani Nikula
     [not found]         ` <87tvi24ah7.fsf-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2019-01-23 17:39           ` Kristian Kristensen
2019-01-24  0:30           ` Rob Clark
2019-01-21 17:22 ` [PATCH 1/2] drm: Add DRM_DEV_INFO_RATELIMITED kbuild test robot

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.