* [PATCH net-next v1 0/2] tipc: subscription refcount simplifications
@ 2017-03-28 10:28 Parthasarathy Bhuvaragan
2017-03-28 10:28 ` [PATCH net-next v1 1/2] tipc: advance the time of deleting subscription from subscriber->subscrp_list Parthasarathy Bhuvaragan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Parthasarathy Bhuvaragan @ 2017-03-28 10:28 UTC (permalink / raw)
To: netdev; +Cc: jon.maloy, tipc-discussion
The first patch makes the subscription refcount cleanup lockless and
the second updates the subscription refcount policy.
Ying Xue (2):
tipc: advance the time of deleting subscription from
subscriber->subscrp_list
tipc: adjust the policy of holding subscription kref
net/tipc/name_table.c | 2 ++
net/tipc/subscr.c | 17 ++++-------------
net/tipc/subscr.h | 3 +++
3 files changed, 9 insertions(+), 13 deletions(-)
--
2.1.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v1 1/2] tipc: advance the time of deleting subscription from subscriber->subscrp_list
2017-03-28 10:28 [PATCH net-next v1 0/2] tipc: subscription refcount simplifications Parthasarathy Bhuvaragan
@ 2017-03-28 10:28 ` Parthasarathy Bhuvaragan
2017-03-28 10:28 ` [PATCH net-next v1 2/2] tipc: adjust the policy of holding subscription kref Parthasarathy Bhuvaragan
2017-03-29 1:03 ` [PATCH net-next v1 0/2] tipc: subscription refcount simplifications David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Parthasarathy Bhuvaragan @ 2017-03-28 10:28 UTC (permalink / raw)
To: netdev; +Cc: jon.maloy, tipc-discussion
From: Ying Xue <ying.xue@windriver.com>
After a subscription object is created, it's inserted into its
subscriber subscrp_list list under subscriber lock protection,
similarly, before it's destroyed, it should be first removed from
its subscriber->subscrp_list. Since the subscription list is
accessed with subscriber lock, all the subscriptions are valid
during the lock duration. Hence in tipc_subscrb_subscrp_delete(), we
remove subscription get/put and the extra subscriber unlock/lock.
After this change, the subscriptions refcount cleanup is very simple
and does not access any lock.
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
---
net/tipc/subscr.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 271cd66e4b3b..0649bc29c6bb 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -145,6 +145,7 @@ static void tipc_subscrp_timeout(unsigned long data)
spin_lock_bh(&subscriber->lock);
tipc_nametbl_unsubscribe(sub);
+ list_del(&sub->subscrp_list);
spin_unlock_bh(&subscriber->lock);
/* Notify subscriber of timeout */
@@ -177,10 +178,7 @@ static void tipc_subscrp_kref_release(struct kref *kref)
struct tipc_net *tn = net_generic(sub->net, tipc_net_id);
struct tipc_subscriber *subscriber = sub->subscriber;
- spin_lock_bh(&subscriber->lock);
- list_del(&sub->subscrp_list);
atomic_dec(&tn->subscription_count);
- spin_unlock_bh(&subscriber->lock);
kfree(sub);
tipc_subscrb_put(subscriber);
}
@@ -210,11 +208,8 @@ static void tipc_subscrb_subscrp_delete(struct tipc_subscriber *subscriber,
continue;
tipc_nametbl_unsubscribe(sub);
- tipc_subscrp_get(sub);
- spin_unlock_bh(&subscriber->lock);
+ list_del(&sub->subscrp_list);
tipc_subscrp_delete(sub);
- tipc_subscrp_put(sub);
- spin_lock_bh(&subscriber->lock);
if (s)
break;
--
2.1.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next v1 2/2] tipc: adjust the policy of holding subscription kref
2017-03-28 10:28 [PATCH net-next v1 0/2] tipc: subscription refcount simplifications Parthasarathy Bhuvaragan
2017-03-28 10:28 ` [PATCH net-next v1 1/2] tipc: advance the time of deleting subscription from subscriber->subscrp_list Parthasarathy Bhuvaragan
@ 2017-03-28 10:28 ` Parthasarathy Bhuvaragan
2017-03-29 1:03 ` [PATCH net-next v1 0/2] tipc: subscription refcount simplifications David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Parthasarathy Bhuvaragan @ 2017-03-28 10:28 UTC (permalink / raw)
To: netdev; +Cc: tipc-discussion, jon.maloy, maloy, ying.xue
From: Ying Xue <ying.xue@windriver.com>
When a new subscription object is inserted into name_seq->subscriptions
list, it's under name_seq->lock protection; when a subscription is
deleted from the list, it's also under the same lock protection;
similarly, when accessing a subscription by going through subscriptions
list, the entire process is also protected by the name_seq->lock.
Therefore, if subscription refcount is increased before it's inserted
into subscriptions list, and its refcount is decreased after it's
deleted from the list, it will be unnecessary to hold refcount at all
before accessing subscription object which is obtained by going through
subscriptions list under name_seq->lock protection.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/name_table.c | 2 ++
net/tipc/subscr.c | 8 ++------
net/tipc/subscr.h | 3 +++
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 9be6592e4a6f..bd0aac87b41a 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -416,6 +416,7 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq,
tipc_subscrp_convert_seq(&s->evt.s.seq, s->swap, &ns);
+ tipc_subscrp_get(s);
list_add(&s->nameseq_list, &nseq->subscriptions);
if (!sseq)
@@ -787,6 +788,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
if (seq != NULL) {
spin_lock_bh(&seq->lock);
list_del_init(&s->nameseq_list);
+ tipc_subscrp_put(s);
if (!seq->first_free && list_empty(&seq->subscriptions)) {
hlist_del_init_rcu(&seq->ns_list);
kfree(seq->sseqs);
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 0649bc29c6bb..0bf91cd3733c 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -54,8 +54,6 @@ struct tipc_subscriber {
static void tipc_subscrp_delete(struct tipc_subscription *sub);
static void tipc_subscrb_put(struct tipc_subscriber *subscriber);
-static void tipc_subscrp_put(struct tipc_subscription *subscription);
-static void tipc_subscrp_get(struct tipc_subscription *subscription);
/**
* htohl - convert value to endianness used by destination
@@ -125,7 +123,6 @@ void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower,
{
struct tipc_name_seq seq;
- tipc_subscrp_get(sub);
tipc_subscrp_convert_seq(&sub->evt.s.seq, sub->swap, &seq);
if (!tipc_subscrp_check_overlap(&seq, found_lower, found_upper))
return;
@@ -135,7 +132,6 @@ void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower,
tipc_subscrp_send_event(sub, found_lower, found_upper, event, port_ref,
node);
- tipc_subscrp_put(sub);
}
static void tipc_subscrp_timeout(unsigned long data)
@@ -183,12 +179,12 @@ static void tipc_subscrp_kref_release(struct kref *kref)
tipc_subscrb_put(subscriber);
}
-static void tipc_subscrp_put(struct tipc_subscription *subscription)
+void tipc_subscrp_put(struct tipc_subscription *subscription)
{
kref_put(&subscription->kref, tipc_subscrp_kref_release);
}
-static void tipc_subscrp_get(struct tipc_subscription *subscription)
+void tipc_subscrp_get(struct tipc_subscription *subscription)
{
kref_get(&subscription->kref);
}
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h
index ffdc214c117a..ee52957dc952 100644
--- a/net/tipc/subscr.h
+++ b/net/tipc/subscr.h
@@ -78,4 +78,7 @@ u32 tipc_subscrp_convert_seq_type(u32 type, int swap);
int tipc_topsrv_start(struct net *net);
void tipc_topsrv_stop(struct net *net);
+void tipc_subscrp_put(struct tipc_subscription *subscription);
+void tipc_subscrp_get(struct tipc_subscription *subscription);
+
#endif
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v1 0/2] tipc: subscription refcount simplifications
2017-03-28 10:28 [PATCH net-next v1 0/2] tipc: subscription refcount simplifications Parthasarathy Bhuvaragan
2017-03-28 10:28 ` [PATCH net-next v1 1/2] tipc: advance the time of deleting subscription from subscriber->subscrp_list Parthasarathy Bhuvaragan
2017-03-28 10:28 ` [PATCH net-next v1 2/2] tipc: adjust the policy of holding subscription kref Parthasarathy Bhuvaragan
@ 2017-03-29 1:03 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-03-29 1:03 UTC (permalink / raw)
To: parthasarathy.bhuvaragan
Cc: netdev, tipc-discussion, jon.maloy, maloy, ying.xue
From: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Date: Tue, 28 Mar 2017 12:28:26 +0200
> The first patch makes the subscription refcount cleanup lockless and
> the second updates the subscription refcount policy.
Series applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-29 1:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-28 10:28 [PATCH net-next v1 0/2] tipc: subscription refcount simplifications Parthasarathy Bhuvaragan
2017-03-28 10:28 ` [PATCH net-next v1 1/2] tipc: advance the time of deleting subscription from subscriber->subscrp_list Parthasarathy Bhuvaragan
2017-03-28 10:28 ` [PATCH net-next v1 2/2] tipc: adjust the policy of holding subscription kref Parthasarathy Bhuvaragan
2017-03-29 1:03 ` [PATCH net-next v1 0/2] tipc: subscription refcount simplifications David Miller
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).