Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp220562imm; Tue, 17 Jul 2018 17:33:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdWLU+A3h/L17FwKj+MdoGP1wSuDcw4hRx4M016wGtPcZvwWZJple8J9XJV8GRX2GdWcbbH X-Received: by 2002:a17:902:e3:: with SMTP id a90-v6mr3712932pla.227.1531874035965; Tue, 17 Jul 2018 17:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531874035; cv=none; d=google.com; s=arc-20160816; b=HYbZiGFIwdBQh7rITFU1fnD/9TMUqQ0pSgo5Sx9qDlr9kEiIo+coG36OYDun6P734b FD1tN90gjTyzjHPigQKJ1igWNN5LHgPJH3NdkBya0GzcvcoWAzjwXM2FOdS6mfciSf+F RRvE7sBi4bZ0p3FRsDyv2QxTGNCOIny/7SCub/JZGGttoqKat+fQhJzJLmv4VlSpKUAS 9syFNPC4TMIklqvptZzsDjuqhc3mAr4UhIdLLR247Rs4mrd8XXJPzCvp6hGvv4CZsOOR PJEH7qx5mLsg+3lfxg2d8QGSZaQ4VNVDwvv2nav+7FkiMysgIAup/4BV9+gBDJRa4078 jvyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=JrzGtihrXg9m/GzAN6ahdCyeBGwkiYP0OXywZlaL17Q=; b=eOsEtND7mzEA0/NYz8a73vRhceUuCgfacNOK/locW3NAYpjRNGP5+Eudl3vCv4D1Nv jYV4hr1oUkqgI+7gnP70PR+54+vpnoioTRRqQEXUXwtJlDwv+M5cPCQ7ypQ0GgGaJu7o G7Bub4TYZi5jPnnHqYiv+gRiFIv/E/3ZBWy4fjY75EUZ77bOm8DbdcuSyQKnn1mhvzY0 MZhMDKlzoTbDdEztkvs87IlvcorSI/bUar7dhTgMeWvBbsypI94ttEtwJnwx6qZ4qKM4 u+A+i4+APBXvWmK8wVsg7WQ/QomDjF5ihZUphbxEc91ltXByIUp5FzcBMmC9o63ZGO7U j4zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ifYLrFuL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si1911372plb.27.2018.07.17.17.33.26; Tue, 17 Jul 2018 17:33:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ifYLrFuL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731327AbeGRBHh (ORCPT + 99 others); Tue, 17 Jul 2018 21:07:37 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:42348 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730040AbeGRBHg (ORCPT ); Tue, 17 Jul 2018 21:07:36 -0400 Received: by mail-pl0-f67.google.com with SMTP id f4-v6so1178287plb.9; Tue, 17 Jul 2018 17:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JrzGtihrXg9m/GzAN6ahdCyeBGwkiYP0OXywZlaL17Q=; b=ifYLrFuL8Mr445OiF5oeHZH9kr1XILTqZ+dTmx1qMHEkg0UwgPg2bfdeaneLyYlHTI D0Q8veQ2bf7hbrz+iu/nf3jZKUotorUAoVrV8cuYEzSa+P/mIDOfH8PWMA9OPKM1EE0Q PfOTInWwev4xxNA3VBJFjYWLShWMLBC94DoTTjSIiui8QFgzwy/+k0CjKnab5dt/4BWU zYb0zFidWLF7xLSCIABfZpTdfLz5rttIa6cmg8wyvjs82UeUQMhJPyRKN0TMn2Sje6+K dgwppg7uEAP8YF8R9XuSiLI3Bjfe82U3ymARMSnZk4RfMSRIlbPrLMM4aRSUyuDJ7oqU iGUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JrzGtihrXg9m/GzAN6ahdCyeBGwkiYP0OXywZlaL17Q=; b=ILUtVrc6PTXyop+Ss/7c++Gc8sQgenCwjqtbli4Kc3DKinxqimSIaBwKI19IE63M6S bgiVcjC0HbkbTkYVYJTmICB3q0lHha2q991u/sMOBK4a7DhurCsGZDUHmL+4+eobYWml 9YZ0wWTgH6e7KdxzJ0ty9bQd9aWCmonRkehc1hnw9GB5rAJybdPo55saa8wORVdX2x9D fdQ3TxVm0soxIsn6hdQ9ON3LwaBbW84xuZ2b59gBAOvw+l8Tz7du89ZpqARNGbHfPe+a GySo0fRr8x4BpljkOS4yP41/6W6+1503PJGMjpewUcwFOgZYmCAPVbmTNGtSaaLT+Ub+ 2knQ== X-Gm-Message-State: AOUpUlHig7Ft+NN1yGKv0E7WbE66RdYIGFpQPK2iPuHLLcqbfR3Zw82v dbX1Ydy/25QOsWGfhfnznRU= X-Received: by 2002:a17:902:704c:: with SMTP id h12-v6mr3613077plt.237.1531873948333; Tue, 17 Jul 2018 17:32:28 -0700 (PDT) Received: from 192-168-1-101.tpgi.com.com ([61.68.123.183]) by smtp.gmail.com with ESMTPSA id d123-v6sm3500973pfa.22.2018.07.17.17.32.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 17:32:27 -0700 (PDT) From: Jon Maxwell To: davem@davemloft.net Cc: edumazet@google.com, eric.dumazet@gmail.com, ncardwell@google.com, David.Laight@aculab.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jmaxwell@redhat.com Subject: [PATCH 0/3] tcp: improve setsockopt() TCP_USER_TIMEOUT accuracy Date: Wed, 18 Jul 2018 10:32:00 +1000 Message-Id: <20180718003203.28059-1-jmaxwell37@gmail.com> X-Mailer: git-send-email 2.13.6 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Based on: https://patchwork.kernel.org/patch/10516195/ Every time the TCP retransmission timer fires. It checks to see if there is a timeout before scheduling the next retransmit timer. The retransmit interval between each retransmission increases exponentially. The issue is that in order for the timeout to occur the retransmit timer needs to fire again. If the user timeout check happens after the 9th retransmit for example. It needs to wait for the 10th retransmit timer to fire in order to evaluate whether a timeout has occurred or not. If the interval is large enough then the timeout will be inaccurate. For example with a TCP_USER_TIMEOUT of 10 seconds without patch: 1st retransmit: 22:25:18.973488 IP host1.49310 > host2.search-agent: Flags [.] Last retransmit: 22:25:26.205499 IP host1.49310 > host2.search-agent: Flags [.] Timeout: send: Connection timed out Sun Jul 1 22:25:34 EDT 2018 We can see that last retransmit took ~7 seconds. Which pushed the total timeout to ~15 seconds instead of the expected 10 seconds. This gets more inaccurate the larger the TCP_USER_TIMEOUT value. As the interval increases. Add tcp_clamp_rto_to_user_timeout() to determine if the user rto has expired. Or whether the rto interval needs to be recalculated. Use the original interval if user rto is not set. Test results with the patch is the expected 10 second timeout: 1st retransmit: 01:37:59.022555 IP host1.49310 > host2.search-agent: Flags [.] Last retransmit: 01:38:06.486558 IP host1.49310 > host2.search-agent: Flags [.] Timeout: send: Connection timed out Mon Jul 2 01:38:09 EDT 2018 Jon Maxwell (3): tcp: convert icsk_user_timeout from jiffies to msecs tcp: Add tcp_retransmit_time() helper routine tcp: Add tcp_clamp_rto_to_user_timeout() helper to improve accuracy net/ipv4/tcp.c | 4 ++-- net/ipv4/tcp_timer.c | 51 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 15 deletions(-) -- 2.13.6