Skip to contentSkip to conversation

drm: add DRM_ERROR_RATELIMITED

PATCH In review Rob Clark 2 participants 3 messages Nov 21, 2013 – Nov 22, 2013

Subsystems (2)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm: add DRM_ERROR_RATELIMITED

For error traces in situations that can run away, it is nice to have a rate-limited version of DRM_ERROR() to avoid massing log flooding.

---
 include/drm/drmP.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/drm/drmP.h +17 -0
index 0a372b2..dd6699e 100644
@@ -56,6 +56,7 @@
 #include <linux/mutex.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/ratelimit.h>
 #if defined(__alpha__) || defined(__powerpc__)
 #include <asm/pgtable.h>	/* For pte_wrprotect */
 #endif
@@ -180,6 +181,22 @@ int drm_err(const char *func, const char *format, ...);
 #define DRM_ERROR(fmt, ...)				\
 	drm_err(__func__, fmt, ##__VA_ARGS__)
 
+/**
+ * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
+ *
+ * \param fmt printf() like format string.
+ * \param arg arguments
+ */
+#define DRM_ERROR_RATELIMITED(fmt, ...)				\
+({									\
+	static DEFINE_RATELIMIT_STATE(_rs,				\
+				      DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+									\
+	if (__ratelimit(&_rs))						\
+		drm_err(__func__, fmt, ##__VA_ARGS__);			\
+})
+
 #define DRM_INFO(fmt, ...)				\
 	printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
 
Signature · 1 line
1.8.4.2
author
#2 lore raw
Quoted 5 lines · Thierry Reding
Quoted 2 lines · Rob Clark

For error traces in situations that can run away, it is nice to have a rate-limited version of DRM_ERROR() to avoid massing log flooding.

s/massing/massive/?

errg, yes

Dave, let me know if you want me to resend or just smash that spelling fix in yourself

BR,
-R

Quoted 3 lines

Other than that, looks good: