diff mbox series

[v12,03/13] mm: Introduce VM_WARN_ON_PAGE macro

Message ID 20210106141931.73931-4-songmuchun@bytedance.com (mailing list archive)
State New, archived
Headers show
Series Free some vmemmap pages of HugeTLB page | expand

Commit Message

Muchun Song Jan. 6, 2021, 2:19 p.m. UTC
Very similar to VM_WARN_ON_ONCE_PAGE and VM_BUG_ON_PAGE, add
VM_WARN_ON_PAGE macro.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 include/linux/mmdebug.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Mike Kravetz Jan. 13, 2021, 10:30 p.m. UTC | #1
On 1/6/21 6:19 AM, Muchun Song wrote:
> Very similar to VM_WARN_ON_ONCE_PAGE and VM_BUG_ON_PAGE, add
> VM_WARN_ON_PAGE macro.
> 
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
>  include/linux/mmdebug.h | 8 ++++++++
>  1 file changed, 8 insertions(+)

I was going to question the use/need for this macro in the following
patch.  Looks like Oscar has already done that, and free_bootmem_page
will now use VM_BUG_ON_PAGE.  So, this patch can be dropped.
Muchun Song Jan. 14, 2021, 2:50 a.m. UTC | #2
On Thu, Jan 14, 2021 at 6:31 AM Mike Kravetz <mike.kravetz@oracle.com> wrote:
>
> On 1/6/21 6:19 AM, Muchun Song wrote:
> > Very similar to VM_WARN_ON_ONCE_PAGE and VM_BUG_ON_PAGE, add
> > VM_WARN_ON_PAGE macro.
> >
> > Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> > ---
> >  include/linux/mmdebug.h | 8 ++++++++
> >  1 file changed, 8 insertions(+)
>
> I was going to question the use/need for this macro in the following
> patch.  Looks like Oscar has already done that, and free_bootmem_page
> will now use VM_BUG_ON_PAGE.  So, this patch can be dropped.

In the previous version, Oscar suggested I use WARN_ON instead of
BUG_ON. But he realised we actually should use BUG_ON in this
version. So I will drop this in the next version. Thanks.

>
> --
> Mike Kravetz
diff mbox series

Patch

diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
index 5d0767cb424a..eff5b13a6945 100644
--- a/include/linux/mmdebug.h
+++ b/include/linux/mmdebug.h
@@ -37,6 +37,13 @@  void dump_mm(const struct mm_struct *mm);
 			BUG();						\
 		}							\
 	} while (0)
+#define VM_WARN_ON_PAGE(cond, page)					\
+	do {								\
+		if (unlikely(cond)) {					\
+			dump_page(page, "VM_WARN_ON_PAGE(" __stringify(cond)")");\
+			WARN_ON(1);					\
+		}							\
+	} while (0)
 #define VM_WARN_ON_ONCE_PAGE(cond, page)	({			\
 	static bool __section(".data.once") __warned;			\
 	int __ret_warn_once = !!(cond);					\
@@ -60,6 +67,7 @@  void dump_mm(const struct mm_struct *mm);
 #define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond)
 #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond)
 #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
+#define VM_WARN_ON_PAGE(cond, page) BUILD_BUG_ON_INVALID(cond)
 #define VM_WARN_ON_ONCE_PAGE(cond, page)  BUILD_BUG_ON_INVALID(cond)
 #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
 #define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond)