linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: replace BUG_ON in vm_insert_page with a return of an error
@ 2021-02-03  0:31 Suren Baghdasaryan
  2021-02-03  0:31 ` [PATCH v2 2/2] dma-buf: heaps: Map system heap pages as managed by linux vm Suren Baghdasaryan
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Suren Baghdasaryan @ 2021-02-03  0:31 UTC (permalink / raw)
  To: sumit.semwal
  Cc: akpm, hch, lmark, labbott, Brian.Starkey, john.stultz,
	christian.koenig, cgoldswo, orjan.eide, robin.murphy, jajones,
	minchan, hridya, sspatil, linux-media, dri-devel, linaro-mm-sig,
	linux-mm, linux-kernel, kernel-team, surenb

Replace BUG_ON(vma->vm_flags & VM_PFNMAP) in vm_insert_page with
WARN_ON_ONCE and returning an error. This is to ensure users of the
vm_insert_page that set VM_PFNMAP are notified of the wrong flag usage
and get an indication of an error without panicing the kernel.
This will help identifying drivers that need to clear VM_PFNMAP before
using dmabuf system heap which is moving to use vm_insert_page.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
 mm/memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index feff48e1465a..e503c9801cd9 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1827,7 +1827,8 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
 		return -EINVAL;
 	if (!(vma->vm_flags & VM_MIXEDMAP)) {
 		BUG_ON(mmap_read_trylock(vma->vm_mm));
-		BUG_ON(vma->vm_flags & VM_PFNMAP);
+		if (WARN_ON_ONCE(vma->vm_flags & VM_PFNMAP))
+			return -EINVAL;
 		vma->vm_flags |= VM_MIXEDMAP;
 	}
 	return insert_page(vma, addr, page, vma->vm_page_prot);
-- 
2.30.0.365.g02bc693789-goog


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-02-05  3:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03  0:31 [PATCH 1/2] mm: replace BUG_ON in vm_insert_page with a return of an error Suren Baghdasaryan
2021-02-03  0:31 ` [PATCH v2 2/2] dma-buf: heaps: Map system heap pages as managed by linux vm Suren Baghdasaryan
2021-02-03  1:39   ` Minchan Kim
2021-02-03  2:02     ` Suren Baghdasaryan
2021-02-03  8:05       ` Christian König
2021-02-03 19:53         ` Suren Baghdasaryan
2021-02-03  2:07   ` John Stultz
2021-02-03  2:13     ` Suren Baghdasaryan
2021-02-03  1:27 ` [PATCH 1/2] mm: replace BUG_ON in vm_insert_page with a return of an error Miaohe Lin
2021-02-03  1:31 ` Minchan Kim
2021-02-03  1:55   ` Suren Baghdasaryan
2021-02-03  1:55 ` Matthew Wilcox
2021-02-03  2:26   ` Suren Baghdasaryan
2021-02-03  8:52   ` [Linaro-mm-sig] " Daniel Vetter
2021-02-03 20:20     ` Suren Baghdasaryan
2021-02-03 20:29       ` Daniel Vetter
2021-02-03 21:25         ` Daniel Vetter
2021-02-03 21:41           ` Suren Baghdasaryan
2021-02-04  8:16             ` Christian König
2021-02-04 15:22               ` Daniel Vetter
2021-02-04 15:54               ` Alex Deucher
2021-02-05  3:39                 ` Suren Baghdasaryan
2021-02-04  7:53       ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).