Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1730789 > unrolled thread

[PATCH] drm: qxl: ratelimit pr_info message, reduce log spamming

Started byColin King <colin.king@canonical.com>
First post2017-09-12 11:50 +0200
Last post2017-09-12 16:30 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] drm: qxl: ratelimit pr_info message, reduce log spamming Colin King <colin.king@canonical.com> - 2017-09-12 11:50 +0200
    Re: [PATCH] drm: qxl: ratelimit pr_info message, reduce log spamming Emil Velikov <emil.l.velikov@gmail.com> - 2017-09-12 16:10 +0200
      Re: [PATCH] drm: qxl: ratelimit pr_info message, reduce log spamming Dan Carpenter <dan.carpenter@oracle.com> - 2017-09-12 16:10 +0200
        Re: [PATCH] drm: qxl: ratelimit pr_info message, reduce log spamming Gerd Hoffmann <kraxel@redhat.com> - 2017-09-12 16:30 +0200

#1730789 — [PATCH] drm: qxl: ratelimit pr_info message, reduce log spamming

FromColin King <colin.king@canonical.com>
Date2017-09-12 11:50 +0200
Subject[PATCH] drm: qxl: ratelimit pr_info message, reduce log spamming
Message-ID<uoPZn-7ZB-3@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

Simply mmap'ing /dev/dri/card0 repeatedly will spam the kernel
log with qxl_mmap information messages. The following example code
illustrates this:

int main(void)
{
	int fd = open("/dev/dri/card0", O_RDONLY);
	if (fd == -1)
		err(1, "open failed");

	for (;;) {
		void *m = mmap(NULL, 4096, PROT_READ,
			MAP_SHARED, fd, 0);
		if (m != MAP_FAILED)
			munmap(m, 4096);
	}
}

Reduce the spamming by ratelimiting the pr_info messages.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/qxl/qxl_ttm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 7ecf8a4b9fe6..6502e699f462 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -124,7 +124,7 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
 	int r;
 
 	if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET)) {
-		pr_info("%s: vma->vm_pgoff (%ld) < DRM_FILE_PAGE_OFFSET\n",
+		pr_info_ratelimited("%s: vma->vm_pgoff (%ld) < DRM_FILE_PAGE_OFFSET\n",
 			__func__, vma->vm_pgoff);
 		return -EINVAL;
 	}
-- 
2.14.1

[toc] | [next] | [standalone]


#1730867

FromEmil Velikov <emil.l.velikov@gmail.com>
Date2017-09-12 16:10 +0200
Message-ID<uoU2Z-2g5-7@gated-at.bofh.it>
In reply to#1730789
Hi Colin,

On 12 September 2017 at 10:45, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Simply mmap'ing /dev/dri/card0 repeatedly will spam the kernel
> log with qxl_mmap information messages. The following example code
> illustrates this:
>
> int main(void)
> {
>         int fd = open("/dev/dri/card0", O_RDONLY);
>         if (fd == -1)
>                 err(1, "open failed");
>
>         for (;;) {
>                 void *m = mmap(NULL, 4096, PROT_READ,
>                         MAP_SHARED, fd, 0);
>                 if (m != MAP_FAILED)
>                         munmap(m, 4096);
>         }
> }
>
> Reduce the spamming by ratelimiting the pr_info messages.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpu/drm/qxl/qxl_ttm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index 7ecf8a4b9fe6..6502e699f462 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -124,7 +124,7 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
>         int r;
>
>         if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET)) {
> -               pr_info("%s: vma->vm_pgoff (%ld) < DRM_FILE_PAGE_OFFSET\n",
> +               pr_info_ratelimited("%s: vma->vm_pgoff (%ld) < DRM_FILE_PAGE_OFFSET\n",
Quick grep suggests that only qxl and vmwgfx produce any output in
this case, likely for the reasons you mentioned.

That said, I'm not sure how useful the information is - perhaps it's
better to drop it all together? Regardless of the route taken, vmwgfx
could use a similar fix.

HTH
Emil

[toc] | [prev] | [next] | [standalone]


#1730868

FromDan Carpenter <dan.carpenter@oracle.com>
Date2017-09-12 16:10 +0200
Message-ID<uoU2Z-2g5-5@gated-at.bofh.it>
In reply to#1730867
On Tue, Sep 12, 2017 at 03:02:04PM +0100, Emil Velikov wrote:
> That said, I'm not sure how useful the information is - perhaps it's
> better to drop it all together?

Or a WARN_ONCE().

regards,
dan carpenter

[toc] | [prev] | [next] | [standalone]


#1730888

FromGerd Hoffmann <kraxel@redhat.com>
Date2017-09-12 16:30 +0200
Message-ID<uoUmn-2nc-31@gated-at.bofh.it>
In reply to#1730868
On Tue, 2017-09-12 at 17:09 +0300, Dan Carpenter wrote:
> On Tue, Sep 12, 2017 at 03:02:04PM +0100, Emil Velikov wrote:
> > That said, I'm not sure how useful the information is - perhaps
> > it's
> > better to drop it all together?
> 
> Or a WARN_ONCE().

It's userspace calling into the driver with invalid parameters.

IMO we should never WARN_ONCE() on something userspace can trigger.

I'd suggest to just drop the message altogether, simply throwing EINVAL
at userspace is perfectly fine IMHO.

cheers,
  Gerd

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web