From patchwork Tue Dec 1 00:19:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 39869 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 747751007D2 for ; Tue, 1 Dec 2009 11:23:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752704AbZLAAWh (ORCPT ); Mon, 30 Nov 2009 19:22:37 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752668AbZLAAWh (ORCPT ); Mon, 30 Nov 2009 19:22:37 -0500 Received: from ixro-out-rtc.ixiacom.com ([92.87.192.98]:19462 "EHLO ixro-ex1.ixiacom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751712AbZLAAWg (ORCPT ); Mon, 30 Nov 2009 19:22:36 -0500 Received: from ixro-opurdila-lap.localnet ([10.205.15.12]) by ixro-ex1.ixiacom.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 1 Dec 2009 02:22:42 +0200 From: Octavian Purdila Organization: Ixia To: netdev@vger.kernel.org Subject: [RFC] sk_nulls_next_rcu Date: Tue, 1 Dec 2009 02:19:29 +0200 User-Agent: KMail/1.12.2 (Linux/2.6.31-trunk-686; KDE/4.3.2; i686; ; ) MIME-Version: 1.0 Message-Id: <200912010219.29340.opurdila@ixiacom.com> X-OriginalArrivalTime: 01 Dec 2009 00:22:42.0378 (UTC) FILETIME=[65AA22A0:01CA721C] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org I am trying to convert the LLC code to RCU, and it appears that for proc support a sk_nulls_next_rcu would be required. Is this the wrong way to do it, or is it that nobody need it yet? Thanks, tavi --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/sock.h b/include/net/sock.h index 3f1a480..989d7e9 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -351,6 +351,13 @@ static inline struct sock *sk_nulls_next(const struct sock *sk) NULL; } +static inline struct sock *sk_nulls_next_rcu(const struct sock *sk) +{ + struct hlist_nulls_node *n = rcu_dereference(sk->sk_nulls_node.next); + return !is_a_nulls(n) ? hlist_nulls_entry(n, struct sock, sk_nulls_node) : + NULL; +} + static inline int sk_unhashed(const struct sock *sk) { return hlist_unhashed(&sk->sk_node); diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c index be47ac4..7567fb9 100644 --- a/net/llc/llc_proc.c +++ b/net/llc/llc_proc.c @@ -34,19 +34,19 @@ static struct sock *llc_get_sk_idx(loff_t pos) { struct list_head *sap_entry; struct llc_sap *sap; - struct hlist_node *node; + struct hlist_nulls_node *node; struct sock *sk = NULL; list_for_each(sap_entry, &llc_sap_list) { sap = list_entry(sap_entry, struct llc_sap, node); - read_lock_bh(&sap->sk_list.lock); - sk_for_each(sk, node, &sap->sk_list.list) { + rcu_read_lock_bh(); + sk_nulls_for_each_rcu(sk, node, &sap->sk_list.list) { if (!pos) goto found; --pos; } - read_unlock_bh(&sap->sk_list.lock); + rcu_read_unlock_bh(); } sk = NULL; found: @@ -73,25 +73,25 @@ static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos) goto out; } sk = v; - next = sk_next(sk); + next = sk_nulls_next(sk); if (next) { sk = next; goto out; } llc = llc_sk(sk); sap = llc->sap; - read_unlock_bh(&sap->sk_list.lock); + rcu_read_unlock_bh(); sk = NULL; for (;;) { + struct hlist_nulls_node *node; + if (sap->node.next == &llc_sap_list) break; sap = list_entry(sap->node.next, struct llc_sap, node); - read_lock_bh(&sap->sk_list.lock); - if (!hlist_empty(&sap->sk_list.list)) { - sk = sk_head(&sap->sk_list.list); + rcu_read_lock_bh(); + sk_nulls_for_each_rcu(sk, node, &sap->sk_list.list) break; - } - read_unlock_bh(&sap->sk_list.lock); + rcu_read_unlock_bh(); } out: return sk; @@ -99,13 +99,8 @@ out: static void llc_seq_stop(struct seq_file *seq, void *v) { - if (v && v != SEQ_START_TOKEN) { - struct sock *sk = v; - struct llc_sock *llc = llc_sk(sk); - struct llc_sap *sap = llc->sap; - - read_unlock_bh(&sap->sk_list.lock); - } + if (v && v != SEQ_START_TOKEN) + rcu_read_unlock_bh(); read_unlock_bh(&llc_sap_list_lock); }