diff mbox series

[v2] use pr_warn_ratelimited() for vq_err()

Message ID 20210222112947.3697927-1-john.levon@nutanix.com (mailing list archive)
State New, archived
Headers show
Series [v2] use pr_warn_ratelimited() for vq_err() | expand

Commit Message

John Levon Feb. 22, 2021, 11:29 a.m. UTC
vq_err() is used to report various failure states in vhost code, but by
default uses pr_debug(), and as a result doesn't record anything unless
enabled via dynamic debug. We'll change this so we get something recorded
in the log in these failure cases. Guest VMs (and userspace) can trigger
some of these messages, so we want to use the pr_warn_ratelimited()
variant. However, on DEBUG kernels, we'd like to get everything, so we use
pr_warn() then.

Signed-off-by: John Levon <john.levon@nutanix.com>
---
v2: use pr_warn() for DEBUG kernels
---
 drivers/vhost/vhost.h | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

David Edmondson Feb. 23, 2021, 8:15 a.m. UTC | #1
On Monday, 2021-02-22 at 11:29:47 GMT, John Levon wrote:

> vq_err() is used to report various failure states in vhost code, but by
> default uses pr_debug(), and as a result doesn't record anything unless
> enabled via dynamic debug. We'll change this so we get something recorded
> in the log in these failure cases. Guest VMs (and userspace) can trigger
> some of these messages, so we want to use the pr_warn_ratelimited()
> variant. However, on DEBUG kernels, we'd like to get everything, so we use
> pr_warn() then.
>
> Signed-off-by: John Levon <john.levon@nutanix.com>

Reviewed-by: David Edmondson <david.edmondson@oracle.com>

> ---
> v2: use pr_warn() for DEBUG kernels
> ---
>  drivers/vhost/vhost.h | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
> index b063324c7669..10007bd49f84 100644
> --- a/drivers/vhost/vhost.h
> +++ b/drivers/vhost/vhost.h
> @@ -228,10 +228,16 @@ int vhost_init_device_iotlb(struct vhost_dev *d, bool enabled);
>  void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
>  			  struct vhost_iotlb_map *map);
>  
> -#define vq_err(vq, fmt, ...) do {                                  \
> -		pr_debug(pr_fmt(fmt), ##__VA_ARGS__);       \
> -		if ((vq)->error_ctx)                               \
> -				eventfd_signal((vq)->error_ctx, 1);\
> +#ifdef DEBUG
> +#define vq_pr_warn pr_warn
> +#else
> +#define vq_pr_warn pr_warn_ratelimited
> +#endif
> +
> +#define vq_err(vq, fmt, ...) do {                                \
> +		vq_pr_warn(pr_fmt(fmt), ##__VA_ARGS__);          \
> +		if ((vq)->error_ctx)                             \
> +			eventfd_signal((vq)->error_ctx, 1);      \
>  	} while (0)
>  
>  enum {
> -- 
> 2.25.1

dme.
diff mbox series

Patch

diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index b063324c7669..10007bd49f84 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -228,10 +228,16 @@  int vhost_init_device_iotlb(struct vhost_dev *d, bool enabled);
 void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
 			  struct vhost_iotlb_map *map);
 
-#define vq_err(vq, fmt, ...) do {                                  \
-		pr_debug(pr_fmt(fmt), ##__VA_ARGS__);       \
-		if ((vq)->error_ctx)                               \
-				eventfd_signal((vq)->error_ctx, 1);\
+#ifdef DEBUG
+#define vq_pr_warn pr_warn
+#else
+#define vq_pr_warn pr_warn_ratelimited
+#endif
+
+#define vq_err(vq, fmt, ...) do {                                \
+		vq_pr_warn(pr_fmt(fmt), ##__VA_ARGS__);          \
+		if ((vq)->error_ctx)                             \
+			eventfd_signal((vq)->error_ctx, 1);      \
 	} while (0)
 
 enum {