kcov: don't generate a warning on vm_insert_page()'s failure
PATCH v2 1/1 kcov: don't generate a warning on vm_insert_page()'s failure
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.
PATCH v2:
* Added a newline at the end of pr_warn_once().
PATCH v1: https://lkml.org/lkml/2022/3/31/909
--- kernel/kcov.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/kcov.c +5 -2
@@ -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:
Signature · 1 line
2.35.1.1094.g7c7d902a7c-goog
Quoted 7 lines · Aleksandr Nogikh
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.
Signed-off-by Aleksandr Nogikh <[email protected]>
Just minor "process" comments:
1) There should be a '---' so that the below doesn't appear in the commit message on 'git am' and maintainers don't have to manually remove it.
Quoted 4 lines
PATCH v2:
* Added a newline at the end ofpr_warn_once().PATCH v1: https://lkml.org/lkml/2022/3/31/909
2) We should use lore permalinks, because lkml.org isn't official and was actually down most of this week. v1 was
https://lore.kernel.org/all/[email protected]/
Quoted 25 lines
--- kernel/kcov.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)kernel/kcov.c +5
-3@@ -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: --2.35.1.1094.g7c7d902a7c-goog