From patchwork Tue Nov 29 08:41:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 128236 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 CC2A9B6F62 for ; Tue, 29 Nov 2011 19:42:01 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753451Ab1K2Ily (ORCPT ); Tue, 29 Nov 2011 03:41:54 -0500 Received: from mail-lpp01m010-f46.google.com ([209.85.215.46]:37908 "EHLO mail-lpp01m010-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814Ab1K2Ilx (ORCPT ); Tue, 29 Nov 2011 03:41:53 -0500 Received: by lahl5 with SMTP id l5so854263lah.19 for ; Tue, 29 Nov 2011 00:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:subject:from:to:cc:date:content-type:x-mailer :content-transfer-encoding:mime-version; bh=oVtc3Whhj0Uyi4POTm7jU+tkANPO6HT+3dEtZ5bGzAI=; b=SsQkLjWXt8shC4wydIO0VC6pEH8AHm0d/+Pzjc1qkJE3lXToXqlch5R9nr3ngQRjWg 44xXqXHns727U1DLPLM6Ibx1H8lfYAaNWmZ5LvsUlY3irEB1qSS25C7hz/ul2i9SWWfK RvZ0uf9EqFWTdYX5/dNXzHQGYrwOj150tJLZ4= Received: by 10.152.113.101 with SMTP id ix5mr30696540lab.23.1322556111246; Tue, 29 Nov 2011 00:41:51 -0800 (PST) Received: from [192.168.1.21] (94.144.72.86.rev.sfr.net. [86.72.144.94]) by mx.google.com with ESMTPS id jb5sm34247994lab.15.2011.11.29.00.41.49 (version=SSLv3 cipher=OTHER); Tue, 29 Nov 2011 00:41:50 -0800 (PST) Message-ID: <1322556107.2970.82.camel@edumazet-laptop> Subject: [PATCH net-next] tcp: avoid frag allocation for small frames From: Eric Dumazet To: David Miller Cc: netdev , subramanian.vijay@gmail.com Date: Tue, 29 Nov 2011 09:41:47 +0100 X-Mailer: Evolution 3.2.1- Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org tcp_sendmsg() uses select_size() helper to choose skb head size when a new skb must be allocated. If GSO is enabled for the socket, current strategy is to force all payload data to be outside of headroom, in PAGE fragments. This strategy is not welcome for small packets, wasting memory. Experiments show that best results are obtained when using 2048 bytes for skb head (This includes the skb overhead and various headers) This patch provides better len/truesize ratios for packets sent to loopback device, and reduce memory needs for in-flight loopback packets, particularly on arches with big pages. If a sender sends many 1-byte packets to an unresponsive application, receiver rmem_alloc will grow faster and will stop queuing these packets sooner, or will collapse its receive queue to free excess memory. netperf -t TCP_RR results are improved by ~4 %, and many workloads are improved as well (tbench, mysql...) Signed-off-by: Eric Dumazet --- net/ipv4/tcp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" 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/net/ipv4/tcp.c b/net/ipv4/tcp.c index 704adad..cd45b44 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -897,9 +897,12 @@ static inline int select_size(const struct sock *sk, int sg) int tmp = tp->mss_cache; if (sg) { - if (sk_can_gso(sk)) - tmp = 0; - else { + if (sk_can_gso(sk)) { + /* Small frames wont use a full page: + * Payload will immediately follow tcp header. + */ + tmp = SKB_WITH_OVERHEAD(2048 - MAX_TCP_HEADER); + } else { int pgbreak = SKB_MAX_HEAD(MAX_TCP_HEADER); if (tmp >= pgbreak &&