Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030297AbbENRKv (ORCPT ); Thu, 14 May 2015 13:10:51 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:29321 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030217AbbENRKm (ORCPT ); Thu, 14 May 2015 13:10:42 -0400 From: Sasha Levin To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, kirill@shutemov.name, Sasha Levin Subject: [PATCH 07/11] mm: debug: VM_BUG() Date: Thu, 14 May 2015 13:10:10 -0400 Message-Id: <1431623414-1905-8-git-send-email-sasha.levin@oracle.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1431623414-1905-1-git-send-email-sasha.levin@oracle.com> References: <1431623414-1905-1-git-send-email-sasha.levin@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1615 Lines: 45 VM_BUG() complements VM_BUG_ON() just like with WARN() and WARN_ON(). This lets us format custom strings to output when a VM_BUG() is hit. Signed-off-by: Sasha Levin --- include/linux/mmdebug.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index 8b3f5a0..42f41e3 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -12,7 +12,14 @@ char *format_page(struct page *page, char *buf, char *end); #ifdef CONFIG_DEBUG_VM char *format_vma(const struct vm_area_struct *vma, char *buf, char *end); char *format_mm(const struct mm_struct *mm, char *buf, char *end); -#define VM_BUG_ON(cond) BUG_ON(cond) +#define VM_BUG(cond, fmt...) \ + do { \ + if (unlikely(cond)) { \ + pr_emerg(fmt); \ + BUG(); \ + } \ + } while (0) +#define VM_BUG_ON(cond) VM_BUG(cond, "%s\n", __stringify(cond)) #define VM_BUG_ON_PAGE(cond, page) \ do { \ if (unlikely(cond)) { \ @@ -46,6 +53,7 @@ static char *format_mm(const struct mm_struct *mm, char *buf, char *end) { return buf; } +#define VM_BUG(cond, fmt...) BUILD_BUG_ON_INVALID(cond) #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond) #define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/