From patchwork Mon Aug 30 23:10:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo F. Padovan" X-Patchwork-Id: 63143 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 60602B70FF for ; Tue, 31 Aug 2010 09:11:16 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754186Ab0H3XKl (ORCPT ); Mon, 30 Aug 2010 19:10:41 -0400 Received: from mail-gy0-f174.google.com ([209.85.160.174]:59605 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751421Ab0H3XKk (ORCPT ); Mon, 30 Aug 2010 19:10:40 -0400 Received: by gyd8 with SMTP id 8so2193328gyd.19 for ; Mon, 30 Aug 2010 16:10:39 -0700 (PDT) Received: by 10.100.121.6 with SMTP id t6mr5442673anc.141.1283209839286; Mon, 30 Aug 2010 16:10:39 -0700 (PDT) Received: from localhost.localdomain ([187.75.148.141]) by mx.google.com with ESMTPS id f22sm13429065anh.4.2010.08.30.16.10.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 30 Aug 2010 16:10:38 -0700 (PDT) From: "Gustavo F. Padovan" To: linux-bluetooth@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, marcel@holtmann.org Subject: [PATCH] Bluetooth: Simplify L2CAP Streaming mode sending Date: Mon, 30 Aug 2010 20:10:24 -0300 Message-Id: <1283209824-8795-2-git-send-email-padovan@profusion.mobi> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1283209824-8795-1-git-send-email-padovan@profusion.mobi> References: <1283209824-8795-1-git-send-email-padovan@profusion.mobi> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org As we don't have any error control on the Streaming mode, i.e., we don't need to keep a copy of the skb for later resending we don't need to call skb_clone() on it. Then we can go one further here, and dequeue the skb before sending it, that also means we don't need to look to sk->sk_send_head anymore. This patch fixes a bug in Streaming mode sending procedure, the call to skb_clone() was making the system run into OOM condition. I never got that before 2.6.36, so I'm think that we acctually have regression there. Anyway, the patch saves memory and time when sending Streaming mode data, so it is good to mainline. Signed-off-by: Gustavo F. Padovan --- net/bluetooth/l2cap.c | 24 +++++++----------------- 1 files changed, 7 insertions(+), 17 deletions(-) diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index fadf26b..80e98cd 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c @@ -1441,33 +1441,23 @@ static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb) static void l2cap_streaming_send(struct sock *sk) { - struct sk_buff *skb, *tx_skb; + struct sk_buff *skb; struct l2cap_pinfo *pi = l2cap_pi(sk); u16 control, fcs; - while ((skb = sk->sk_send_head)) { - tx_skb = skb_clone(skb, GFP_ATOMIC); - - control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); + while ((skb = skb_dequeue(TX_QUEUE(sk)))) { + control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); control |= pi->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; - put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); + put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); if (pi->fcs == L2CAP_FCS_CRC16) { - fcs = crc16(0, (u8 *)tx_skb->data, tx_skb->len - 2); - put_unaligned_le16(fcs, tx_skb->data + tx_skb->len - 2); + fcs = crc16(0, (u8 *)skb->data, skb->len - 2); + put_unaligned_le16(fcs, skb->data + skb->len - 2); } - l2cap_do_send(sk, tx_skb); + l2cap_do_send(sk, skb); pi->next_tx_seq = (pi->next_tx_seq + 1) % 64; - - if (skb_queue_is_last(TX_QUEUE(sk), skb)) - sk->sk_send_head = NULL; - else - sk->sk_send_head = skb_queue_next(TX_QUEUE(sk), skb); - - skb = skb_dequeue(TX_QUEUE(sk)); - kfree_skb(skb); } }