Linux bluetooth development
 help / color / mirror / Atom feed
From: Mat Martineau <mathewm@codeaurora.org>
To: "Gustavo F. Padovan" <padovan@profusion.mobi>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 1/2] Bluetooth: set sk_sndbuf and sk_rcvbuf properly in ERTM
Date: Mon, 27 Sep 2010 14:22:07 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.00.1009271355090.27215@linux-sea-02> (raw)
In-Reply-To: <1285618609-11499-1-git-send-email-padovan@profusion.mobi>


Gustavo -

On Mon, 27 Sep 2010, Gustavo F. Padovan wrote:

> Setting both this value to MPS * TxWin * 1.2 guarantees that we are
> reserving space to fit the whole txwindow in the memory, and that
> sendmsg() will block when the transmission window is full avoid
> overloading the system memory.
> I don't have a strong reason about the 1.2 constant in the account, we
> can do another tests in the future and change that value.
>
> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
> net/bluetooth/l2cap_core.c |   10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 44aa034..1e2ab05 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -3129,9 +3129,17 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
> 		l2cap_pi(sk)->next_tx_seq = 0;
> 		l2cap_pi(sk)->expected_tx_seq = 0;
> 		__skb_queue_head_init(TX_QUEUE(sk));
> -		if (l2cap_pi(sk)->mode ==  L2CAP_MODE_ERTM)
> +		if (l2cap_pi(sk)->mode ==  L2CAP_MODE_ERTM) {
> 			l2cap_ertm_init(sk);
>
> +			sk->sk_sndbuf = (l2cap_pi(sk)->remote_tx_win * 1.2 *
> +						(sizeof(struct l2cap_pinfo) +
> +						l2cap_pi(sk)->mps));
> +			sk->sk_rcvbuf = (l2cap_pi(sk)->tx_win * 1.2 *
> +						(sizeof(struct l2cap_pinfo) +
> +						l2cap_pi(sk)->remote_mps));
> +		}
> +
> 		l2cap_chan_ready(sk);
> 	}
>
> -- 
> 1.7.3

I think sizeof(struct sk_buff) would be better than
sizeof(struct l2cap_pinfo), since these limits apply to data buffers, 
not per-socket overhead.

The 1.2 constant would need to be increased if we allow ERTM MPS
bigger than the HCI MTU, since there would be multiple sk_buffs per 
PDU.  However, the calculation could be updated when those MPS changes 
are made.

It would also help to enforce some limits:
SOCK_MIN_SNDBUF < sk->sk_sndbuf < sysctl_wmem_max
SOCK_MIN_RCVBUF < sk->sk_rcvbuf < sysctl_rmem_max


Regards,

--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


  parent reply	other threads:[~2010-09-27 21:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-27 20:16 [PATCH 1/2] Bluetooth: set sk_sndbuf and sk_rcvbuf properly in ERTM Gustavo F. Padovan
2010-09-27 20:16 ` [PATCH 2/2] Bluetooth: Use the proper error value from bt_skb_send_alloc() Gustavo F. Padovan
2010-09-27 21:22 ` Mat Martineau [this message]
2010-09-29  0:32   ` [PATCH 1/2] Bluetooth: set sk_sndbuf and sk_rcvbuf properly in ERTM Gustavo F. Padovan

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=alpine.DEB.2.00.1009271355090.27215@linux-sea-02 \
    --to=mathewm@codeaurora.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=padovan@profusion.mobi \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox