From patchwork Sat Oct 10 00:56:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 7365131 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 37570BF90C for ; Sat, 10 Oct 2015 01:02:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4DEDF2060D for ; Sat, 10 Oct 2015 01:02:35 +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 54B8D20830 for ; Sat, 10 Oct 2015 01:02:34 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 473EE61BE6; Fri, 9 Oct 2015 18:02:34 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id 1785861BC2 for ; Fri, 9 Oct 2015 18:02:33 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 09 Oct 2015 18:02:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,660,1437462000"; d="scan'208";a="661421596" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.39]) by orsmga003.jf.intel.com with ESMTP; 09 Oct 2015 18:02:32 -0700 Subject: [PATCH v2 16/20] list: introduce list_poison() and LIST_POISON3 From: Dan Williams To: linux-nvdimm@lists.01.org Date: Fri, 09 Oct 2015 20:56:50 -0400 Message-ID: <20151010005650.17221.59540.stgit@dwillia2-desk3.jf.intel.com> In-Reply-To: <20151010005522.17221.87557.stgit@dwillia2-desk3.jf.intel.com> References: <20151010005522.17221.87557.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, hch@lst.de 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: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_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 ZONE_DEVICE pages always have an elevated count and will never be on an lru reclaim list. That space in 'struct page' can be redirected for other uses, but for safety introduce a poison value that will always trip __list_add() to assert. This allows half of the struct list_head storage to be reclaimed with some assurance to back up the assumption that the page count never goes to zero and a list_add() is never attempted. Signed-off-by: Dan Williams --- include/linux/list.h | 14 ++++++++++++++ include/linux/poison.h | 1 + lib/list_debug.c | 2 ++ 3 files changed, 17 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index 3e3e64a61002..af38cc80ae4c 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -114,6 +114,20 @@ extern void list_del(struct list_head *entry); #endif /** + * list_del_poison - poison an entry to always assert on list_add + * @entry: the element to delete and poison + * + * Note: the assertion on list_add() only occurs when CONFIG_DEBUG_LIST=y, + * otherwise this is identical to list_del() + */ +static inline void list_del_poison(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + entry->next = LIST_POISON3; + entry->prev = LIST_POISON3; +} + +/** * list_replace - replace old entry by new one * @old : the element to be replaced * @new : the new element to insert diff --git a/include/linux/poison.h b/include/linux/poison.h index 317e16de09e5..31d048b3ba06 100644 --- a/include/linux/poison.h +++ b/include/linux/poison.h @@ -21,6 +21,7 @@ */ #define LIST_POISON1 ((void *) 0x100 + POISON_POINTER_DELTA) #define LIST_POISON2 ((void *) 0x200 + POISON_POINTER_DELTA) +#define LIST_POISON3 ((void *) 0x300 + POISON_POINTER_DELTA) /********** include/linux/timer.h **********/ /* diff --git a/lib/list_debug.c b/lib/list_debug.c index c24c2f7e296f..ec69e2b8e0fc 100644 --- a/lib/list_debug.c +++ b/lib/list_debug.c @@ -23,6 +23,8 @@ void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { + WARN(new->next == LIST_POISON3 || new->prev == LIST_POISON3, + "list_add attempted on poisoned entry\n"); WARN(next->prev != prev, "list_add corruption. next->prev should be " "prev (%p), but was %p. (next=%p).\n",