From patchwork Mon Apr 23 16:42:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 8054 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 160E523E22 for ; Mon, 23 Apr 2012 16:43:09 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id D286FA181B8 for ; Mon, 23 Apr 2012 16:43:08 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so23096175iag.11 for ; Mon, 23 Apr 2012 09:43:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-content-scanned:x-cbid:x-gm-message-state; bh=eKAkZL3JQU9LcHrCQcBrB4Mpvqi6GQrGJj1Ms/ACpP0=; b=V8wWFlXhd/fdumJ0CENoRB+fTmLH61dyawJvRPrSKQXQTIjUl1XSqQsLP2VMw15xN0 rd7wbPMx0TB/ZJNw6y5WOz6AoF47EnxtzLkNHv7OQex2w8gUdsSnkxP0CtRUXZRHaAJ4 M+87xQcOZL7sOkIeZt0cYLyOer6D5aVVbsNDcHTCcE1GlTY8K7Va7TIKtyHUH0kuWCLe JyU+mHjTNzE429Jwrnkzl8+hzvlfmutNKsEnTupF8rQuugzlirYS9CW7+XpNsxJj2m7k jNnXsfUJP7Ly1TG8lTM3zAQZQBbheAXDZWD6H5UDv7+Uyx5+tIzbKd5zajRslzlcl/PE 742Q== Received: by 10.50.183.225 with SMTP id ep1mr3091684igc.1.1335199388623; Mon, 23 Apr 2012 09:43:08 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp125377ibt; Mon, 23 Apr 2012 09:43:08 -0700 (PDT) Received: by 10.182.113.42 with SMTP id iv10mr5915269obb.18.1335199388075; Mon, 23 Apr 2012 09:43:08 -0700 (PDT) Received: from e37.co.us.ibm.com (e37.co.us.ibm.com. [32.97.110.158]) by mx.google.com with ESMTPS id r9si9308271oee.6.2012.04.23.09.43.07 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 09:43:08 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.158 as permitted sender) client-ip=32.97.110.158; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.158 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Apr 2012 10:43:06 -0600 Received: from d01dlp03.pok.ibm.com (9.56.224.17) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Apr 2012 10:42:45 -0600 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 4E630C90052 for ; Mon, 23 Apr 2012 12:42:43 -0400 (EDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q3NGghjN078388 for ; Mon, 23 Apr 2012 12:42:44 -0400 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q3NGgT8i018633 for ; Mon, 23 Apr 2012 10:42:31 -0600 Received: from paulmck-ThinkPad-W500 ([9.47.24.152]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q3NGgTfb018616; Mon, 23 Apr 2012 10:42:29 -0600 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id 70FB3E4D6E; Mon, 23 Apr 2012 09:42:29 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, Valdis.Kletnieks@vt.edu, dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com, fweisbec@gmail.com, patches@linaro.org, Dave Jones , "Paul E. McKenney" Subject: [PATCH RFC tip/core/rcu 2/6] rcu: List-debug variants of rcu list routines. Date: Mon, 23 Apr 2012 09:42:23 -0700 Message-Id: <1335199347-13926-2-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1335199347-13926-1-git-send-email-paulmck@linux.vnet.ibm.com> References: <20120423164159.GA13819@linux.vnet.ibm.com> <1335199347-13926-1-git-send-email-paulmck@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12042316-7408-0000-0000-0000046E79C3 X-Gm-Message-State: ALoCoQmJ9maz+nbCW/laBSxpx2Lr2nx4eHHsHe4w93DkOKfHLdOjq4qsdkAXUoWeQX0jpePKyIeI From: Dave Jones * Make __list_add_rcu check the next->prev and prev->next pointers just like __list_add does. * Make list_del_rcu use __list_del_entry, which does the same checking at deletion time. Has been running for a week here without anything being tripped up, but it seems worth adding for completeness just in case something ever does corrupt those lists. Signed-off-by: Dave Jones Signed-off-by: Paul E. McKenney --- include/linux/rculist.h | 7 ++++++- lib/list_debug.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-) diff --git a/include/linux/rculist.h b/include/linux/rculist.h index d079290..a20c050 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -30,6 +30,7 @@ * This is only for internal list manipulation where we know * the prev/next entries already! */ +#ifndef CONFIG_DEBUG_LIST static inline void __list_add_rcu(struct list_head *new, struct list_head *prev, struct list_head *next) { @@ -38,6 +39,10 @@ static inline void __list_add_rcu(struct list_head *new, rcu_assign_pointer(list_next_rcu(prev), new); next->prev = new; } +#else +extern void __list_add_rcu(struct list_head *new, + struct list_head *prev, struct list_head *next); +#endif /** * list_add_rcu - add a new entry to rcu-protected list @@ -108,7 +113,7 @@ static inline void list_add_tail_rcu(struct list_head *new, */ static inline void list_del_rcu(struct list_head *entry) { - __list_del(entry->prev, entry->next); + __list_del_entry(entry); entry->prev = LIST_POISON2; } diff --git a/lib/list_debug.c b/lib/list_debug.c index 982b850..3810b48 100644 --- a/lib/list_debug.c +++ b/lib/list_debug.c @@ -10,6 +10,7 @@ #include #include #include +#include /* * Insert a new entry between two known consecutive entries. @@ -75,3 +76,24 @@ void list_del(struct list_head *entry) entry->prev = LIST_POISON2; } EXPORT_SYMBOL(list_del); + +/* + * RCU variants. + */ +void __list_add_rcu(struct list_head *new, + struct list_head *prev, struct list_head *next) +{ + WARN(next->prev != prev, + "list_add_rcu corruption. next->prev should be " + "prev (%p), but was %p. (next=%p).\n", + prev, next->prev, next); + WARN(prev->next != next, + "list_add_rcu corruption. prev->next should be " + "next (%p), but was %p. (prev=%p).\n", + next, prev->next, prev); + new->next = next; + new->prev = prev; + rcu_assign_pointer(list_next_rcu(prev), new); + next->prev = new; +} +EXPORT_SYMBOL(__list_add_rcu);