diff options
author | Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com> | 2016-02-02 04:52:16 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-02-06 03:41:58 -0500 |
commit | ae245557f87fffe2e1c39ba07524024e650e822b (patch) | |
tree | 73a16eb24a35386f5b86e02a1381eb73777c01af /net/tipc | |
parent | f3ad288c56d21e3b8ec77e13ab9aa06dbbfa3577 (diff) |
tipc: donot create timers if subscription timeout = TIPC_WAIT_FOREVER
Until now, we create timers even for the subscription requests
with timeout = TIPC_WAIT_FOREVER.
This can be improved by avoiding timer creation when the timeout
is set to TIPC_WAIT_FOREVER.
In this commit, we introduce a check to creates timers only
when timeout != TIPC_WAIT_FOREVER.
Acked-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/subscr.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 7d226ecb0490..22963cafd5ed 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -188,12 +188,14 @@ static struct tipc_subscriber *tipc_subscrb_create(int conid) | |||
188 | static void tipc_subscrb_delete(struct tipc_subscriber *subscriber) | 188 | static void tipc_subscrb_delete(struct tipc_subscriber *subscriber) |
189 | { | 189 | { |
190 | struct tipc_subscription *sub, *temp; | 190 | struct tipc_subscription *sub, *temp; |
191 | u32 timeout; | ||
191 | 192 | ||
192 | spin_lock_bh(&subscriber->lock); | 193 | spin_lock_bh(&subscriber->lock); |
193 | /* Destroy any existing subscriptions for subscriber */ | 194 | /* Destroy any existing subscriptions for subscriber */ |
194 | list_for_each_entry_safe(sub, temp, &subscriber->subscrp_list, | 195 | list_for_each_entry_safe(sub, temp, &subscriber->subscrp_list, |
195 | subscrp_list) { | 196 | subscrp_list) { |
196 | if (del_timer(&sub->timer)) { | 197 | timeout = htohl(sub->evt.s.timeout, sub->swap); |
198 | if ((timeout == TIPC_WAIT_FOREVER) || del_timer(&sub->timer)) { | ||
197 | tipc_subscrp_delete(sub); | 199 | tipc_subscrp_delete(sub); |
198 | tipc_subscrb_put(subscriber); | 200 | tipc_subscrb_put(subscriber); |
199 | } | 201 | } |
@@ -217,13 +219,16 @@ static void tipc_subscrp_cancel(struct tipc_subscr *s, | |||
217 | struct tipc_subscriber *subscriber) | 219 | struct tipc_subscriber *subscriber) |
218 | { | 220 | { |
219 | struct tipc_subscription *sub, *temp; | 221 | struct tipc_subscription *sub, *temp; |
222 | u32 timeout; | ||
220 | 223 | ||
221 | spin_lock_bh(&subscriber->lock); | 224 | spin_lock_bh(&subscriber->lock); |
222 | /* Find first matching subscription, exit if not found */ | 225 | /* Find first matching subscription, exit if not found */ |
223 | list_for_each_entry_safe(sub, temp, &subscriber->subscrp_list, | 226 | list_for_each_entry_safe(sub, temp, &subscriber->subscrp_list, |
224 | subscrp_list) { | 227 | subscrp_list) { |
225 | if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { | 228 | if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { |
226 | if (del_timer(&sub->timer)) { | 229 | timeout = htohl(sub->evt.s.timeout, sub->swap); |
230 | if ((timeout == TIPC_WAIT_FOREVER) || | ||
231 | del_timer(&sub->timer)) { | ||
227 | tipc_subscrp_delete(sub); | 232 | tipc_subscrp_delete(sub); |
228 | tipc_subscrb_put(subscriber); | 233 | tipc_subscrb_put(subscriber); |
229 | } | 234 | } |
@@ -267,7 +272,6 @@ static struct tipc_subscription *tipc_subscrp_create(struct net *net, | |||
267 | sub->swap = swap; | 272 | sub->swap = swap; |
268 | memcpy(&sub->evt.s, s, sizeof(*s)); | 273 | memcpy(&sub->evt.s, s, sizeof(*s)); |
269 | atomic_inc(&tn->subscription_count); | 274 | atomic_inc(&tn->subscription_count); |
270 | setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub); | ||
271 | return sub; | 275 | return sub; |
272 | } | 276 | } |
273 | 277 | ||
@@ -290,6 +294,10 @@ static void tipc_subscrp_subscribe(struct net *net, struct tipc_subscr *s, | |||
290 | spin_unlock_bh(&subscriber->lock); | 294 | spin_unlock_bh(&subscriber->lock); |
291 | 295 | ||
292 | timeout = htohl(sub->evt.s.timeout, swap); | 296 | timeout = htohl(sub->evt.s.timeout, swap); |
297 | if (timeout == TIPC_WAIT_FOREVER) | ||
298 | return; | ||
299 | |||
300 | setup_timer(&sub->timer, tipc_subscrp_timeout, (unsigned long)sub); | ||
293 | mod_timer(&sub->timer, jiffies + msecs_to_jiffies(timeout)); | 301 | mod_timer(&sub->timer, jiffies + msecs_to_jiffies(timeout)); |
294 | } | 302 | } |
295 | 303 | ||