<div dir="ltr">Thanks,<br><br>I committed the fix to ofed-1.5 tree<br><br>- Amir<br><br><div class="gmail_quote">On Wed, Apr 29, 2009 at 5:23 PM, Nicolas Morey-Chaisemartin <span dir="ltr"><<a href="mailto:nicolas.morey-chaisemartin@ext.bull.net">nicolas.morey-chaisemartin@ext.bull.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">orphan_count and sockets_allocated have been changed from atomic_t to percpu_counter.<br>
As percpu_counter are huge they can be allocated on the stack without causing sdp module to crash.<br>
Both variable are now dynamically allocated at module init.<br>
<br>
Signed-off-by: Nicolas Morey-Chaisemartin <<a href="mailto:nicolas.morey-chaisemartin@ext.bull.net">nicolas.morey-chaisemartin@ext.bull.net</a>><br>
---<br>
drivers/infiniband/ulp/sdp/sdp_main.c | 29 +++++++++++++++++++----------<br>
1 files changed, 19 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c<br>
index 51801e0..7a38c47 100644<br>
--- a/drivers/infiniband/ulp/sdp/sdp_main.c<br>
+++ b/drivers/infiniband/ulp/sdp/sdp_main.c<br>
@@ -580,7 +580,7 @@ adjudge_to_death:<br>
/* TODO: tcp_fin_time to get timeout */<br>
sdp_dbg(sk, "%s: entering time wait refcnt %d\n", __func__,<br>
atomic_read(&sk->sk_refcnt));<br>
- atomic_inc(sk->sk_prot->orphan_count);<br>
+ percpu_counter_inc(sk->sk_prot->orphan_count);<br>
}<br>
<br>
/* TODO: limit number of orphaned sockets.<br>
@@ -861,7 +861,7 @@ void sdp_cancel_dreq_wait_timeout(struct sdp_sock *ssk)<br>
sock_put(&ssk-><a href="http://isk.sk" target="_blank">isk.sk</a>, SOCK_REF_DREQ_TO);<br>
}<br>
<br>
- atomic_dec(ssk->isk.sk.sk_prot->orphan_count);<br>
+ percpu_counter_dec(ssk->isk.sk.sk_prot->orphan_count);<br>
}<br>
<br>
void sdp_destroy_work(struct work_struct *work)<br>
@@ -902,7 +902,7 @@ void sdp_dreq_wait_timeout_work(struct work_struct *work)<br>
sdp_sk(sk)->dreq_wait_timeout = 0;<br>
<br>
if (sk->sk_state == TCP_FIN_WAIT1)<br>
- atomic_dec(ssk->isk.sk.sk_prot->orphan_count);<br>
+ percpu_counter_dec(ssk->isk.sk.sk_prot->orphan_count);<br>
<br>
sdp_exch_state(sk, TCPF_LAST_ACK | TCPF_FIN_WAIT1, TCP_TIME_WAIT);<br>
<br>
@@ -2162,9 +2162,9 @@ void sdp_urg(struct sdp_sock *ssk, struct sk_buff *skb)<br>
sk->sk_data_ready(sk, 0);<br>
}<br>
<br>
-static atomic_t sockets_allocated;<br>
+static struct percpu_counter *sockets_allocated;<br>
static atomic_t memory_allocated;<br>
-static atomic_t orphan_count;<br>
+static struct percpu_counter *orphan_count;<br>
static int memory_pressure;<br>
struct proto sdp_proto = {<br>
.close = sdp_close,<br>
@@ -2182,10 +2182,8 @@ struct proto sdp_proto = {<br>
.get_port = sdp_get_port,<br>
/* Wish we had this: .listen = sdp_listen */<br>
.enter_memory_pressure = sdp_enter_memory_pressure,<br>
- .sockets_allocated = &sockets_allocated,<br>
.memory_allocated = &memory_allocated,<br>
.memory_pressure = &memory_pressure,<br>
- .orphan_count = &orphan_count,<br>
.sysctl_mem = sysctl_tcp_mem,<br>
.sysctl_wmem = sysctl_tcp_wmem,<br>
.sysctl_rmem = sysctl_tcp_rmem,<br>
@@ -2540,6 +2538,15 @@ static int __init sdp_init(void)<br>
spin_lock_init(&sock_list_lock);<br>
spin_lock_init(&sdp_large_sockets_lock);<br>
<br>
+ sockets_allocated = kmalloc(sizeof(*sockets_allocated), GFP_KERNEL);<br>
+ orphan_count = kmalloc(sizeof(*orphan_count), GFP_KERNEL);<br>
+ percpu_counter_init(sockets_allocated, 0);<br>
+ percpu_counter_init(orphan_count, 0);<br>
+<br>
+ sdp_proto.sockets_allocated = sockets_allocated;<br>
+ sdp_proto.orphan_count = orphan_count;<br>
+<br>
+<br>
sdp_workqueue = create_singlethread_workqueue("sdp");<br>
if (!sdp_workqueue) {<br>
return -ENOMEM;<br>
@@ -2574,9 +2581,9 @@ static void __exit sdp_exit(void)<br>
sock_unregister(PF_INET_SDP);<br>
proto_unregister(&sdp_proto);<br>
<br>
- if (atomic_read(&orphan_count))<br>
- printk(KERN_WARNING "%s: orphan_count %d\n", __func__,<br>
- atomic_read(&orphan_count));<br>
+ if (percpu_counter_read_positive(orphan_count))<br>
+ printk(KERN_WARNING "%s: orphan_count %lld\n", __func__,<br>
+ percpu_counter_read_positive(orphan_count));<br>
destroy_workqueue(sdp_workqueue);<br>
flush_scheduled_work();<br>
<br>
@@ -2589,6 +2596,8 @@ static void __exit sdp_exit(void)<br>
sdp_proc_unregister();<br>
<br>
ib_unregister_client(&sdp_client);<br>
+ kfree(orphan_count);<br>
+ kfree(sockets_allocated);<br>
}<br>
<br>
module_init(sdp_init);<br>
--<br>
1.6.2.GIT<br>
<br>
_______________________________________________<br>
general mailing list<br>
<a href="mailto:general@lists.openfabrics.org">general@lists.openfabrics.org</a><br>
<a href="http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general" target="_blank">http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general</a><br>
<br>
To unsubscribe, please visit <a href="http://openib.org/mailman/listinfo/openib-general" target="_blank">http://openib.org/mailman/listinfo/openib-general</a><br>
</blockquote></div><br></div>