Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756849AbYFZApq (ORCPT ); Wed, 25 Jun 2008 20:45:46 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754651AbYFZApR (ORCPT ); Wed, 25 Jun 2008 20:45:17 -0400 Received: from host36-195-149-62.serverdedicati.aruba.it ([62.149.195.36]:33722 "EHLO mx.cpushare.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754306AbYFZApO (ORCPT ); Wed, 25 Jun 2008 20:45:14 -0400 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [PATCH 1 of 3] list_del_init_rcu X-Mercurial-Node: 5e8c41d283ccef7c739b609a30d7f194d9907f43 Message-Id: <5e8c41d283ccef7c739b.1214440017@duo.random> In-Reply-To: Date: Thu, 26 Jun 2008 02:26:57 +0200 From: Andrea Arcangeli To: Linus Torvalds , Andrew Morton , Christoph Lameter , Jack Steiner , Robin Holt , Nick Piggin , Peter Zijlstra , kvm@vger.kernel.org, Kanoj Sarcar , Roland Dreier , Steve Wise , linux-kernel@vger.kernel.org, Avi Kivity , linux-mm@kvack.org, general@lists.openfabrics.org, Hugh Dickins , Rusty Russell , Anthony Liguori , Chris Wright , Marcelo Tosatti , Eric Dumazet , "Paul E. McKenney" , Izik Eidus , Anthony Liguori , Rik van Riel Cc: andrea@qumranet.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2242 Lines: 61 From: Andrea Arcangeli Introduces list_del_init_rcu and documents it (fixes a comment for list_del_rcu too). Signed-off-by: Andrea Arcangeli Acked-by: Linus Torvalds --- diff -r 98f755616212 -r 5e8c41d283cc include/linux/list.h --- a/include/linux/list.h Tue Jun 24 11:23:35 2008 -0700 +++ b/include/linux/list.h Wed Jun 25 03:34:11 2008 +0200 @@ -747,7 +747,7 @@ static inline void hlist_del(struct hlis * or hlist_del_rcu(), running on this same list. * However, it is perfectly legal to run concurrently with * the _rcu list-traversal primitives, such as - * hlist_for_each_entry(). + * hlist_for_each_entry_rcu(). */ static inline void hlist_del_rcu(struct hlist_node *n) { @@ -760,6 +760,34 @@ static inline void hlist_del_init(struct if (!hlist_unhashed(n)) { __hlist_del(n); INIT_HLIST_NODE(n); + } +} + +/** + * hlist_del_init_rcu - deletes entry from hash list with re-initialization + * @n: the element to delete from the hash list. + * + * Note: list_unhashed() on the node return true after this. It is + * useful for RCU based read lockfree traversal if the writer side + * must know if the list entry is still hashed or already unhashed. + * + * In particular, it means that we can not poison the forward pointers + * that may still be used for walking the hash list and we can only + * zero the pprev pointer so list_unhashed() will return true after + * this. + * + * The caller must take whatever precautions are necessary (such as + * holding appropriate locks) to avoid racing with another + * list-mutation primitive, such as hlist_add_head_rcu() or + * hlist_del_rcu(), running on this same list. However, it is + * perfectly legal to run concurrently with the _rcu list-traversal + * primitives, such as hlist_for_each_entry_rcu(). + */ +static inline void hlist_del_init_rcu(struct hlist_node *n) +{ + if (!hlist_unhashed(n)) { + __hlist_del(n); + n->pprev = NULL; } } -- 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/