[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 4 Apr 2022 15:22:52 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Aleksandr Nogikh <nogikh@...gle.com>
Cc: kasan-dev@...glegroups.com, linux-kernel@...r.kernel.org,
dvyukov@...gle.com, andreyknvl@...il.com, elver@...gle.com,
glider@...gle.com, tarasmadan@...gle.com, bigeasy@...utronix.de
Subject: Re: [PATCH v3] kcov: don't generate a warning on vm_insert_page()'s
failure
On Fri, 1 Apr 2022 18:25:12 +0000 Aleksandr Nogikh <nogikh@...gle.com> wrote:
> vm_insert_page()'s failure is not an unexpected condition, so don't do
> WARN_ONCE() in such a case.
>
> Instead, print a kernel message and just return an error code.
>
> ...
>
> --- a/kernel/kcov.c
> +++ b/kernel/kcov.c
> @@ -475,8 +475,11 @@ static int kcov_mmap(struct file *filep, struct vm_area_struct *vma)
> vma->vm_flags |= VM_DONTEXPAND;
> for (off = 0; off < size; off += PAGE_SIZE) {
> page = vmalloc_to_page(kcov->area + off);
> - if (vm_insert_page(vma, vma->vm_start + off, page))
> - WARN_ONCE(1, "vm_insert_page() failed");
> + res = vm_insert_page(vma, vma->vm_start + off, page);
> + if (res) {
> + pr_warn_once("kcov: vm_insert_page() failed\n");
> + return res;
> + }
> }
> return 0;
> exit:
Can you explain the rationale here? If vm_insert_page() failure is an
expected condition, why warn at all?
I'm struggling to understand why a condition is worth a printk, but not
a WARN.
Some explanation of what leads to the vm_insert_page() failure would
have been helpful.
Powered by blists - more mailing lists