All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: linux-sctp@vger.kernel.org
Subject: Re: [PATCH] sctp: avoid irq lock inversion while call sk->sk_data_ready()
Date: Wed, 03 Feb 2010 17:14:23 +0000	[thread overview]
Message-ID: <4B69AEEF.3090103@hp.com> (raw)
In-Reply-To: <4B6903D6.8070106@cn.fujitsu.com>



Wei Yongjun wrote:
> sk->sk_data_ready() of sctp socket can be called from both BH and non-BH
> contexts, but the default sk->sk_data_ready(), sock_def_readable(), can
> not be used in this case. Therefore, we have to make a new function
> sctp_data_ready() to grab sk->sk_data_ready() with BH disabling.
> 

Wouldn't the same inversion happen in TCP as well?  TCP can call that
function in _bh and user contexts as well.

-vlad

> ============================> [ INFO: possible irq lock inversion dependency detected ]
> 2.6.33-rc6 #129
> ---------------------------------------------------------
> sctp_darn/1517 just changed the state of lock:
>  (clock-AF_INET){++.?..}, at: [<c06aab60>] sock_def_readable+0x20/0x80
> but this lock took another, SOFTIRQ-unsafe lock in the past:
>  (slock-AF_INET){+.-...}
> 
> and interrupts could create inverse lock ordering between them.
> 
> other info that might help us debug this:
> 1 lock held by sctp_darn/1517:
>  #0:  (sk_lock-AF_INET){+.+.+.}, at: [<cdfe363d>] sctp_sendmsg+0x23d/0xc00 [sctp]
> 
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> ---
>  include/net/sctp/sctp.h |    1 +
>  net/sctp/endpointola.c  |    1 +
>  net/sctp/socket.c       |   10 ++++++++++
>  3 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
> index 78740ec..fa6cde5 100644
> --- a/include/net/sctp/sctp.h
> +++ b/include/net/sctp/sctp.h
> @@ -128,6 +128,7 @@ extern int sctp_register_pf(struct sctp_pf *, sa_family_t);
>  int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
>  int sctp_inet_listen(struct socket *sock, int backlog);
>  void sctp_write_space(struct sock *sk);
> +void sctp_data_ready(struct sock *sk, int len);
>  unsigned int sctp_poll(struct file *file, struct socket *sock,
>  		poll_table *wait);
>  void sctp_sock_rfree(struct sk_buff *skb);
> diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
> index 905fda5..7ec09ba 100644
> --- a/net/sctp/endpointola.c
> +++ b/net/sctp/endpointola.c
> @@ -144,6 +144,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
>  	/* Use SCTP specific send buffer space queues.  */
>  	ep->sndbuf_policy = sctp_sndbuf_policy;
>  
> +	sk->sk_data_ready = sctp_data_ready;
>  	sk->sk_write_space = sctp_write_space;
>  	sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
>  
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 67fdac9..b437e2a 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -6185,6 +6185,16 @@ do_nonblock:
>  	goto out;
>  }
>  
> +void sctp_data_ready(struct sock *sk, int len)
> +{
> +	read_lock_bh(&sk->sk_callback_lock);
> +	if (sk_has_sleeper(sk))
> +		wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN |
> +						POLLRDNORM | POLLRDBAND);
> +	sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
> +	read_unlock_bh(&sk->sk_callback_lock);
> +}
> +
>  /* If socket sndbuf has changed, wake up all per association waiters.  */
>  void sctp_write_space(struct sock *sk)
>  {

  parent reply	other threads:[~2010-02-03 17:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-03  5:04 [PATCH] sctp: avoid irq lock inversion while call sk->sk_data_ready() Wei Yongjun
2010-02-03  9:51 ` Wei Yongjun
2010-02-03 17:14 ` Vlad Yasevich [this message]
2010-02-04  0:58 ` Wei Yongjun
2010-02-04 15:58 ` Vlad Yasevich
2010-02-05 19:19 ` Vlad Yasevich
2010-02-08  1:55 ` Wei Yongjun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B69AEEF.3090103@hp.com \
    --to=vladislav.yasevich@hp.com \
    --cc=linux-sctp@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.