netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesse Gross <jesse@nicira.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, dev@openvswitch.org,
	Pravin B Shelar <pshelar@nicira.com>,
	Jesse Gross <jesse@nicira.com>
Subject: [PATCH net-next 02/11] openvswitch: Use RCU lock for dp dump operation.
Date: Tue, 27 Aug 2013 13:20:39 -0700	[thread overview]
Message-ID: <1377634848-34327-3-git-send-email-jesse@nicira.com> (raw)
In-Reply-To: <1377634848-34327-1-git-send-email-jesse@nicira.com>

From: Pravin B Shelar <pshelar@nicira.com>

RCUfy dp-dump operation which is already read-only. This
makes all ovs dump operations lockless.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
---
 net/openvswitch/datapath.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index e6fb866..9d97ef3 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -951,9 +951,10 @@ static struct genl_ops dp_packet_genl_ops[] = {
 
 static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats)
 {
+	struct flow_table *table;
 	int i;
-	struct flow_table *table = ovsl_dereference(dp->table);
 
+	table = rcu_dereference_check(dp->table, lockdep_ovsl_is_held());
 	stats->n_flows = ovs_flow_tbl_count(table);
 
 	stats->n_hit = stats->n_missed = stats->n_lost = 0;
@@ -1665,7 +1666,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
 		goto err_destroy_local_port;
 
 	ovs_net = net_generic(ovs_dp_get_net(dp), ovs_net_id);
-	list_add_tail(&dp->list_node, &ovs_net->dps);
+	list_add_tail_rcu(&dp->list_node, &ovs_net->dps);
 
 	ovs_unlock();
 
@@ -1703,7 +1704,7 @@ static void __dp_destroy(struct datapath *dp)
 				ovs_dp_detach_port(vport);
 	}
 
-	list_del(&dp->list_node);
+	list_del_rcu(&dp->list_node);
 
 	/* OVSP_LOCAL is datapath internal port. We need to make sure that
 	 * all port in datapath are destroyed first before freeing datapath.
@@ -1808,8 +1809,8 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
 	int skip = cb->args[0];
 	int i = 0;
 
-	ovs_lock();
-	list_for_each_entry(dp, &ovs_net->dps, list_node) {
+	rcu_read_lock();
+	list_for_each_entry_rcu(dp, &ovs_net->dps, list_node) {
 		if (i >= skip &&
 		    ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid,
 					 cb->nlh->nlmsg_seq, NLM_F_MULTI,
@@ -1817,7 +1818,7 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
 			break;
 		i++;
 	}
-	ovs_unlock();
+	rcu_read_unlock();
 
 	cb->args[0] = i;
 
-- 
1.8.1.2

  reply	other threads:[~2013-08-27 20:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-27 20:20 [GIT net-next] Open vSwitch Jesse Gross
2013-08-27 20:20 ` Jesse Gross [this message]
2013-08-27 20:20 ` [PATCH net-next 03/11] openvswitch: Use non rcu hlist_del() flow table entry Jesse Gross
2013-08-27 20:20 ` [PATCH net-next 04/11] openvswitch:: link upper device for port devices Jesse Gross
     [not found] ` <1377634848-34327-1-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2013-08-27 20:20   ` [PATCH net-next 01/11] openvswitch: Use RCU lock for flow dump operation Jesse Gross
2013-08-27 20:20   ` [PATCH net-next 05/11] openvswitch: Fix argument descriptions in vport.c Jesse Gross
2013-08-27 20:20 ` [PATCH net-next 06/11] openvswitch: check CONFIG_OPENVSWITCH_GRE in makefile Jesse Gross
2013-08-27 20:20 ` [PATCH net-next 07/11] openvswitch: Mega flow implementation Jesse Gross
2013-08-27 20:20 ` [PATCH net-next 08/11] net: Add NEXTHDR_SCTP to ipv6.h Jesse Gross
2013-08-27 20:20 ` [PATCH net-next 09/11] openvswitch: Add SCTP support Jesse Gross
2013-08-27 20:20 ` [PATCH net-next 10/11] openvswitch: Rename key_len to key_end Jesse Gross
2013-08-27 20:20 ` [PATCH net-next 11/11] openvswitch: optimize flow compare and mask functions Jesse Gross
2013-08-28  2:11 ` [GIT net-next] Open vSwitch David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377634848-34327-3-git-send-email-jesse@nicira.com \
    --to=jesse@nicira.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@nicira.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).