From patchwork Fri Jun 28 14:50:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 2799621 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 818C2BF4A1 for ; Fri, 28 Jun 2013 14:50:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4094F201CB for ; Fri, 28 Jun 2013 14:50:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7798201C1 for ; Fri, 28 Jun 2013 14:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753571Ab3F1OuU (ORCPT ); Fri, 28 Jun 2013 10:50:20 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:53474 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531Ab3F1OuT (ORCPT ); Fri, 28 Jun 2013 10:50:19 -0400 Received: by mail-ee0-f46.google.com with SMTP id d41so1075356eek.5 for ; Fri, 28 Jun 2013 07:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:content-transfer-encoding:mime-version; bh=uUxmjGznUm7ppBk+wQ5XunMGs3HH/W17V0CxsMPxSDU=; b=iOY1H5P2obPpW5yNBSQrxADJSwK14V7FOeCqhKLf41odZkeOYuF6drNWfgjShb4o9N WFGykXFcLyT97puJu91rnnLhhQMq5Q7uujBltcQAuCKTdkPIK4cuEbiSOpgNI52yuPsS 4uJjhB94mJ/Qs04hsyg+A4Y1Ulstcn6+z032hQK/V4kx4rG0lbQBwDtWvke00r6E1Byk UWBBYyeuaFJagdVwgwGS7yc2ndr2pzO0q5508xAm0zXuW0pCaESPUZDSL8jWLPsrYppE cJULlXx9JAEuyuM29iqGIZDg0JvMrADkKOCw4l9+3/id0pQSUjhy6+UGRZQuq26aXMDJ /ZsA== X-Received: by 10.14.203.8 with SMTP id e8mr4230979eeo.96.1372431017485; Fri, 28 Jun 2013 07:50:17 -0700 (PDT) Received: from [172.28.88.231] ([172.28.88.231]) by mx.google.com with ESMTPSA id n5sm10959239eed.9.2013.06.28.07.50.15 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Fri, 28 Jun 2013 07:50:16 -0700 (PDT) Message-ID: <1372431024.3301.277.camel@edumazet-glaptop> Subject: Re: [PATCH] iwl3945: better skb management in rx path From: Eric Dumazet To: Paul Stewart Cc: "John W. Linville" , "Steinar H. Gunderson" , linux-wireless , netdev Date: Fri, 28 Jun 2013 07:50:24 -0700 In-Reply-To: References: <1372421021.3301.263.camel@edumazet-glaptop> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Dumazet On Fri, 2013-06-28 at 07:38 -0700, Paul Stewart wrote: > Presumably this 256 is related to the "dev_alloc_skb(256)"? It might > be worth making this a constant of some sort so they don't > inadvertently drift apart in the future. Hi Paul ! Well, I can do that, but the 128 was not a constant to begin with ;) Thanks [PATCH v2] iwl3945: better skb management in rx path Steinar reported reallocations of skb->head with IPv6, leading to a warning in skb_try_coalesce() It turns out iwl3945 has several problems : 1) skb->truesize is underestimated. We really consume PAGE_SIZE bytes for a fragment, not the frame length. 2) 128 bytes of initial headroom is a bit low and forces reallocations. 3) We can avoid consuming a full page for small enough frames. Reported-by: Steinar H. Gunderson Signed-off-by: Eric Dumazet Cc: Paul Stewart --- v2: use a SMALL_PACKET_SIZE macro drivers/net/wireless/iwlegacy/3945.c | 32 +++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index c092033..38e6be6 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -475,6 +475,8 @@ il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header) } } +#define SMALL_PACKET_SIZE 256 + static void il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, struct ieee80211_rx_status *stats) @@ -483,14 +485,13 @@ il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); - u16 len = le16_to_cpu(rx_hdr->len); + u32 len = le16_to_cpu(rx_hdr->len); struct sk_buff *skb; __le16 fc = hdr->frame_control; + u32 fraglen = PAGE_SIZE << il->hw_params.rx_page_order; /* We received data from the HW, so stop the watchdog */ - if (unlikely - (len + IL39_RX_FRAME_SIZE > - PAGE_SIZE << il->hw_params.rx_page_order)) { + if (unlikely(len + IL39_RX_FRAME_SIZE > fraglen)) { D_DROP("Corruption detected!\n"); return; } @@ -506,26 +507,33 @@ il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, D_INFO("Woke queues - frame received on passive channel\n"); } - skb = dev_alloc_skb(128); + skb = dev_alloc_skb(SMALL_PACKET_SIZE); if (!skb) { IL_ERR("dev_alloc_skb failed\n"); return; } if (!il3945_mod_params.sw_crypto) - il_set_decrypted_flag(il, (struct ieee80211_hdr *)rxb_addr(rxb), + il_set_decrypted_flag(il, (struct ieee80211_hdr *)pkt, le32_to_cpu(rx_end->status), stats); - skb_add_rx_frag(skb, 0, rxb->page, - (void *)rx_hdr->payload - (void *)pkt, len, - len); - + /* If frame is small enough to fit into skb->head, copy it + * and do not consume a full page + */ + if (len <= SMALL_PACKET_SIZE) { + skb_copy_to_linear_data(skb, rx_hdr->payload, len); + skb->tail += len; + } else { + skb_add_rx_frag(skb, 0, rxb->page, + (void *)rx_hdr->payload - (void *)pkt, len, + fraglen); + il->alloc_rxb_page--; + rxb->page = NULL; + } il_update_stats(il, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); ieee80211_rx(il->hw, skb); - il->alloc_rxb_page--; - rxb->page = NULL; } #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)