[ofa-general] [PATCH] sdp: Fixed SDP to work on 2.6.29+ as sk_prot->orphan_count is a percpu_counter and not a atomic_t anymore

Nicolas Morey-Chaisemartin devel-ofed at morey-chaisemartin.com
Wed Apr 29 07:22:40 PDT 2009


Patch makes build OK but still fails due to percpu_counters being too large to be allocated on the stack
Posting a fixed version.

Le 29/04/2009 11:35, Nicolas Morey-Chaisemartin a écrit :
> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas.morey-chaisemartin at ext.bull.net>
> ---
> this patch goes on ofed_1_5/linux-2.6
> 
>  drivers/infiniband/ulp/sdp/sdp_main.c |   16 ++++++++--------
>  1 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c
> index 51801e0..c457b37 100644
> --- a/drivers/infiniband/ulp/sdp/sdp_main.c
> +++ b/drivers/infiniband/ulp/sdp/sdp_main.c
> @@ -580,7 +580,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.
> @@ -861,7 +861,7 @@ void sdp_cancel_dreq_wait_timeout(struct sdp_sock *ssk)
>  		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)
> @@ -902,7 +902,7 @@ void sdp_dreq_wait_timeout_work(struct work_struct *work)
>  	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);
>  
> @@ -2162,9 +2162,9 @@ void sdp_urg(struct sdp_sock *ssk, struct sk_buff *skb)
>  		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,
> @@ -2574,9 +2574,9 @@ 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();
>  




More information about the general mailing list