[PATCH] mm: do not use VM_WARN_ON_ONCE as if condition

From: Minchan Kim
Date: Thu Mar 09 2017 - 00:58:23 EST


Sergey reported VM_WARN_ON_ONCE returns void with !CONFIG_DEBUG_VM
so we cannot use it as if's condition unlike WARN_ON.

This patch fixes it.

Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>
---
mm/rmap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 1d82057144ba..7d24bb93445b 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1413,12 +1413,11 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
* Store the swap location in the pte.
* See handle_pte_fault() ...
*/
- if (VM_WARN_ON_ONCE(PageSwapBacked(page) !=
- PageSwapCache(page))) {
+ if (unlikely(PageSwapBacked(page) != PageSwapCache(page))) {
+ WARN_ON_ONCE(1);
ret = SWAP_FAIL;
page_vma_mapped_walk_done(&pvmw);
break;
-
}

/* MADV_FREE page check */
--
2.7.4