From patchwork Thu Dec 10 02:38:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 7814291 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0E8A99F349 for ; Thu, 10 Dec 2015 02:39:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AF8320524 for ; Thu, 10 Dec 2015 02:39:25 +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 7E90C204FB for ; Thu, 10 Dec 2015 02:39:24 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6CFFB1A1F34; Wed, 9 Dec 2015 18:39:24 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id C64291A1FBC for ; Wed, 9 Dec 2015 18:39:22 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 09 Dec 2015 18:39:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,406,1444719600"; d="scan'208";a="838120018" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.136]) by orsmga001.jf.intel.com with ESMTP; 09 Dec 2015 18:39:23 -0800 Subject: [-mm PATCH v2 19/25] list: introduce list_del_poison() From: Dan Williams To: akpm@linux-foundation.org Date: Wed, 09 Dec 2015 18:38:55 -0800 Message-ID: <20151210023855.30368.37457.stgit@dwillia2-desk3.jf.intel.com> In-Reply-To: <20151210023708.30368.92962.stgit@dwillia2-desk3.jf.intel.com> References: <20151210023708.30368.92962.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 Cc: linux-mm@kvack.org, linux-nvdimm@lists.01.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: , 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 | 17 +++++++++++++++++ lib/list_debug.c | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index 5356f4d661a7..0d07bc1387aa 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -108,9 +108,26 @@ static inline void list_del(struct list_head *entry) entry->next = LIST_POISON1; entry->prev = LIST_POISON2; } + +#define list_del_poison list_del #else extern void __list_del_entry(struct list_head *entry); extern void list_del(struct list_head *entry); +extern struct list_head list_force_poison; + +/** + * 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_force_poison; + entry->prev = &list_force_poison; +} #endif /** diff --git a/lib/list_debug.c b/lib/list_debug.c index 3859bf63561c..d730c064a4df 100644 --- a/lib/list_debug.c +++ b/lib/list_debug.c @@ -12,6 +12,8 @@ #include #include +struct list_head list_force_poison; + /* * Insert a new entry between two known consecutive entries. * @@ -23,6 +25,8 @@ void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { + WARN(new->next == &list_force_poison || new->prev == &list_force_poison, + "list_add attempted on force-poisoned entry\n"); WARN(next->prev != prev, "list_add corruption. next->prev should be " "prev (%p), but was %p. (next=%p).\n",