From patchwork Sat Dec 3 19:14:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 702359 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 3tWLNr4Yffz9t0q for ; Sun, 4 Dec 2016 06:16:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="S3FMs0EP"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752247AbcLCTQi (ORCPT ); Sat, 3 Dec 2016 14:16:38 -0500 Received: from mail-pf0-f177.google.com ([209.85.192.177]:34926 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751638AbcLCTQ2 (ORCPT ); Sat, 3 Dec 2016 14:16:28 -0500 Received: by mail-pf0-f177.google.com with SMTP id i88so57214454pfk.2 for ; Sat, 03 Dec 2016 11:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cGPGBbErJHMHmr4OYW0aFyAGw1eaoaPb5ulOpyx77Dk=; b=S3FMs0EPjgPImK4y7MjwObybf2Whb9l+rG4uFnVb3qGB0RG+kq+QwcgUJXyEkv/axu TTquBs4NWp5Jw2/GiborzyT4qIceEuBD90Fft7ztJDcMadHuDNiM1JGJ+F8p0x1iJC1a znHZbcLP0TmC5WWJOHWyhKgT6LLquWWhM7IPrWnOAWbO2auFDCXdDbQ+zaihLP3kDsuQ PyIYZsJ3p41DJ1G0sPaAbsAQJAKrtqHIZEM6y+D6pfxSb9iIC+YhMnavFoC+vj6X/R+2 atBu/tORYq/zJUqrqJvAduB87ym7+6bULLw46a3raYc+R1vl/G+bWrpe785H13ZpDgPM jXNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cGPGBbErJHMHmr4OYW0aFyAGw1eaoaPb5ulOpyx77Dk=; b=LvxQmrT648/fJUUy0DiNxhvsUugsx+cSl8KUYaVV1oYAM+u+bvv9bh8xkWS8sri4pM tOjpOPhiuTuRo2kFSXvAIzciRVHH7/Jp7S2AJk9M/4gZetPo31eaQJqu85+gIZ7Vyc23 u9mkoYE/IpxK73IWFkVHT4mQutgWINIBC8wfW/ZWCCRSd4TGmbuKMzJgOpfQuYuRBkyO 8u82cVSJhtArE00w1PRZ5sngaheNyOM34+5CNorjLRA2rTf/uHP9OLZT2CO908nssCKt ajKT9/py7PDrFsC3YZyI6zJmZHtHREGtS2KmZ/TGTTYiqhZiCW9iXFyb75HXQhlX7dnN YG9w== X-Gm-Message-State: AKaTC032RrUKxBrHZkstCpMAK80/M97i7NLlxvPh7Orq23vFd0ggBwS3QoJtjK3d9jOzlag3 X-Received: by 10.84.206.37 with SMTP id f34mr109264903ple.35.1480792512249; Sat, 03 Dec 2016 11:15:12 -0800 (PST) Received: from localhost ([2620:0:1000:3012:74ef:f267:5512:d54e]) by smtp.gmail.com with ESMTPSA id x2sm16524394pfx.65.2016.12.03.11.15.11 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sat, 03 Dec 2016 11:15:11 -0800 (PST) From: Eric Dumazet To: "David S . Miller" Cc: netdev , Eric Dumazet , Yuchung Cheng , Eric Dumazet Subject: [PATCH v2 net-next 5/8] tcp: tsq: add a shortcut in tcp_small_queue_check() Date: Sat, 3 Dec 2016 11:14:54 -0800 Message-Id: <1480792497-16607-6-git-send-email-edumazet@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1480792497-16607-1-git-send-email-edumazet@google.com> References: <1480792497-16607-1-git-send-email-edumazet@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Always allow the two first skbs in write queue to be sent, regardless of sk_wmem_alloc/sk_pacing_rate values. This helps a lot in situations where TX completions are delayed either because of driver latencies or softirq latencies. Test is done with no cache line misses. Signed-off-by: Eric Dumazet --- net/ipv4/tcp_output.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 0db63efe5b8b..d5c46749adab 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2091,6 +2091,15 @@ static bool tcp_small_queue_check(struct sock *sk, const struct sk_buff *skb, limit <<= factor; if (atomic_read(&sk->sk_wmem_alloc) > limit) { + /* Always send the 1st or 2nd skb in write queue. + * No need to wait for TX completion to call us back, + * after softirq/tasklet schedule. + * This helps when TX completions are delayed too much. + */ + if (skb == sk->sk_write_queue.next || + skb->prev == sk->sk_write_queue.next) + return false; + set_bit(TSQ_THROTTLED, &tcp_sk(sk)->tsq_flags); /* It is possible TX completion already happened * before we set TSQ_THROTTLED, so we must