Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:zhy20120210:failed_1
ofed
ofed-1.4.2-percpu-counter.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ofed-1.4.2-percpu-counter.patch of Package ofed
From: Nicolas Morey-Chaisemartin [Wed, 29 Apr 2009 14:23:04 +0000 (16:23 +0200)] Subject: sdp: change orphan_count and sockets_allocated from atomic_t to percpu_counter Patch-mainline: 28ceecd4beae4a9a7b56e7382aad7bc6b5a6cd70 As percpu_counter are huge they can be allocated on the stack without causing sdp module to crash. Both variable are now dynamically allocated at module init. Signed-off-by: Nicolas Morey-Chaisemartin <nicolas.morey-chaisemartin@ext.bull.net> Signed-off-by: Amir Vadai <amirv@mellanox.co.il> Acked-by: John Jolly <jjolly@suse.de> Index: ofa_kernel-1.4.2/drivers/infiniband/ulp/sdp/sdp_main.c =================================================================== --- ofa_kernel-1.4.2.orig/drivers/infiniband/ulp/sdp/sdp_main.c +++ ofa_kernel-1.4.2/drivers/infiniband/ulp/sdp/sdp_main.c @@ -586,7 +586,7 @@ adjudge_to_death: /* TODO: tcp_fin_time to get timeout */ sdp_dbg(sk, "%s: entering time wait refcnt %d\n", __func__, atomic_read(&sk->sk_refcnt)); - atomic_inc(sk->sk_prot->orphan_count); + percpu_counter_inc(sk->sk_prot->orphan_count); } /* TODO: limit number of orphaned sockets. @@ -859,7 +859,7 @@ void sdp_cancel_dreq_wait_timeout(struct sock_put(&ssk->isk.sk, SOCK_REF_DREQ_TO); } - atomic_dec(ssk->isk.sk.sk_prot->orphan_count); + percpu_counter_dec(ssk->isk.sk.sk_prot->orphan_count); } void sdp_destroy_work(struct work_struct *work) @@ -900,7 +900,7 @@ void sdp_dreq_wait_timeout_work(struct w sdp_sk(sk)->dreq_wait_timeout = 0; if (sk->sk_state == TCP_FIN_WAIT1) - atomic_dec(ssk->isk.sk.sk_prot->orphan_count); + percpu_counter_dec(ssk->isk.sk.sk_prot->orphan_count); sdp_exch_state(sk, TCPF_LAST_ACK | TCPF_FIN_WAIT1, TCP_TIME_WAIT); @@ -2160,9 +2160,9 @@ void sdp_urg(struct sdp_sock *ssk, struc sk->sk_data_ready(sk, 0); } -static atomic_t sockets_allocated; +static struct percpu_counter *sockets_allocated; static atomic_t memory_allocated; -static atomic_t orphan_count; +static struct percpu_counter *orphan_count; static int memory_pressure; struct proto sdp_proto = { .close = sdp_close, @@ -2180,10 +2180,8 @@ struct proto sdp_proto = { .get_port = sdp_get_port, /* Wish we had this: .listen = sdp_listen */ .enter_memory_pressure = sdp_enter_memory_pressure, - .sockets_allocated = &sockets_allocated, .memory_allocated = &memory_allocated, .memory_pressure = &memory_pressure, - .orphan_count = &orphan_count, .sysctl_mem = sysctl_tcp_mem, .sysctl_wmem = sysctl_tcp_wmem, .sysctl_rmem = sysctl_tcp_rmem, @@ -2538,6 +2536,14 @@ static int __init sdp_init(void) spin_lock_init(&sock_list_lock); spin_lock_init(&sdp_large_sockets_lock); + sockets_allocated = kmalloc(sizeof(*sockets_allocated), GFP_KERNEL); + orphan_count = kmalloc(sizeof(*orphan_count), GFP_KERNEL); + percpu_counter_init(sockets_allocated, 0); + percpu_counter_init(orphan_count, 0); + + sdp_proto.sockets_allocated = sockets_allocated; + sdp_proto.orphan_count = orphan_count; + sdp_workqueue = create_singlethread_workqueue("sdp"); if (!sdp_workqueue) { return -ENOMEM; @@ -2572,9 +2578,10 @@ static void __exit sdp_exit(void) sock_unregister(PF_INET_SDP); proto_unregister(&sdp_proto); - if (atomic_read(&orphan_count)) - printk(KERN_WARNING "%s: orphan_count %d\n", __func__, - atomic_read(&orphan_count)); + if (percpu_counter_read_positive(orphan_count)) + printk(KERN_WARNING "%s: orphan_count %lld\n", __func__, + percpu_counter_read_positive(orphan_count)); + destroy_workqueue(sdp_workqueue); flush_scheduled_work(); @@ -2587,6 +2594,10 @@ static void __exit sdp_exit(void) sdp_proc_unregister(); ib_unregister_client(&sdp_client); + percpu_counter_destroy(orphan_count); + percpu_counter_destroy(sockets_allocated); + kfree(orphan_count); + kfree(sockets_allocated); } module_init(sdp_init);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor