From patchwork Thu Mar 10 23:55:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilcox, Matthew R" X-Patchwork-Id: 8560461 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 71A8CC0554 for ; Thu, 10 Mar 2016 23:55:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6EE892038A for ; Thu, 10 Mar 2016 23:55:40 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8AC1320377 for ; Thu, 10 Mar 2016 23:55:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 18A131A1F64; Thu, 10 Mar 2016 15:55:54 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ml01.01.org (Postfix) with ESMTP id 767101A1EF8 for ; Thu, 10 Mar 2016 15:55:53 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 10 Mar 2016 15:55:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,317,1455004800"; d="scan'208";a="63912464" Received: from jduan1-mobl2.amr.corp.intel.com (HELO thog.int.wil.cx) ([10.252.134.213]) by fmsmga004.fm.intel.com with SMTP; 10 Mar 2016 15:55:36 -0800 Received: by thog.int.wil.cx (Postfix, from userid 1000) id 25C1F5F9AD; Thu, 10 Mar 2016 18:55:36 -0500 (EST) From: Matthew Wilcox To: Andrew Morton Subject: [PATCH v5 01/14] mmdebug: Always evaluate the arguments to VM_BUG_ON_* Date: Thu, 10 Mar 2016 18:55:18 -0500 Message-Id: <1457654131-4562-2-git-send-email-matthew.r.wilcox@intel.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457654131-4562-1-git-send-email-matthew.r.wilcox@intel.com> References: <1457654131-4562-1-git-send-email-matthew.r.wilcox@intel.com> Cc: linux-nvdimm@lists.01.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox , linux-fsdevel@vger.kernel.org X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I recently got the order of arguments to VM_BUG_ON_VMA the wrong way around, which was only noticable when compiling with CONFIG_DEBUG_VM. Prevent the next mistake of this kind by making the macros evaluate both their arguments at compile time (this has no effect on the built kernel). Signed-off-by: Matthew Wilcox --- include/linux/mmdebug.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index de7be78..abfc316 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -41,9 +41,24 @@ void dump_mm(const struct mm_struct *mm); #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format) #else #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) -#define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond) +#define VM_BUG_ON_PAGE(cond, page) \ + do { \ + if (0) dump_page(page, ""); \ + VM_BUG_ON(cond); \ + } while (0) + +#define VM_BUG_ON_VMA(cond, vma) \ + do { \ + if (0) dump_vma(vma); \ + VM_BUG_ON(cond); \ + } while (0) + +#define VM_BUG_ON_MM(cond, mm) \ + do { \ + if (0) dump_mm(mm); \ + VM_BUG_ON(cond); \ + } while (0) + #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond) #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)