Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1468991imm; Tue, 10 Jul 2018 02:17:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpedUBujIRC0s//4Csk3D5lnP0wRabHcr57G7wzUhi5Ag5UIr84y4ABXQZINEUI0Qzmfkott X-Received: by 2002:a17:902:294a:: with SMTP id g68-v6mr24422807plb.58.1531214237410; Tue, 10 Jul 2018 02:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531214237; cv=none; d=google.com; s=arc-20160816; b=ydryN8YeVM8VA4iZCwknIN0z8YzD/rMkcqMSAmjZ282bYtXRkLJZB7YFke3BgqtWop cJDQJ1i4HXbPo2d7cXkixRAHE07QEuIQqJlOWneqpJQ89PODor6awYAcWIXHBHEu5Vxp u1/p9cEHEpMOip8C7rXYCFrXjTm/2LMdO/0FyNN4WR4epyDpiU8B1Ba4vxaoXoSwuM0g de/sgr1iinkJQCsnLDu6UTssqNrQWdR9FkQJUjzzpCJa/aftIiNk7ejLqGXchcFjN1RW YhYPu66yYBivXGHDwZMb+4ERc77yEJDfKdZaK2+fS3EQUhdEQCcCriYwh4B29+i1wXat SIYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=4PPWMJNcL3fH84NBkc4Nxk/qXygkyHPKVgx29ULo+sE=; b=hzsPk4TKaJHsc0yc9EMONkMAQ183SWM2xOnG7Fo7USPNeXQLnrX3m73b7g96i7TjG+ Pxi8RjNPmb0Q3ioHt/IfMOuluotKkHRgLMbJr39wQvCHiwMwasYsnkiGvUMXIjSqG/Yb ANSRTJk0Jq9tbWkIHAWayZLYjrLrUpouF2Auv2QTacwIHGslbtHIZbcLLYv7RDMuj+qF B+xwmuDYVCK1VCgMRc/oCXtzaLvgUxXZk8SPC2oZJHmvFxM9gSarLiGyuMVEPptr5Dvl xUPw8EyBHGLMxlo74bgJB0LShUbrA7h20EkkPgHUOdC7rupW12xyHKYH75ZMQGCi7u0i qInA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11-v6si15919521pll.89.2018.07.10.02.16.52; Tue, 10 Jul 2018 02:17:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751312AbeGJJQC convert rfc822-to-8bit (ORCPT + 99 others); Tue, 10 Jul 2018 05:16:02 -0400 Received: from smtp-out4.electric.net ([192.162.216.195]:59096 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbeGJJQB (ORCPT ); Tue, 10 Jul 2018 05:16:01 -0400 Received: from 1fcokO-0008Db-UM by out4c.electric.net with emc1-ok (Exim 4.90_1) (envelope-from ) id 1fcokY-0000mU-TF; Tue, 10 Jul 2018 02:15:58 -0700 Received: by emcmailer; Tue, 10 Jul 2018 02:15:58 -0700 Received: from [156.67.243.126] (helo=AcuMS.aculab.com) by out4c.electric.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fcokO-0008Db-UM; Tue, 10 Jul 2018 02:15:48 -0700 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 10 Jul 2018 10:17:27 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 10 Jul 2018 10:17:27 +0100 From: David Laight To: 'Jon Maxwell' , "davem@davemloft.net" CC: "edumazet@google.com" , "eric.dumazet@gmail.com" , "ncardwell@google.com" , "kuznet@ms2.inr.ac.ru" , "yoshfuji@linux-ipv6.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jmaxwell@redhat.com" Subject: RE: [net-next,v3] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy Thread-Topic: [net-next,v3] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy Thread-Index: AQHUGBrUFQL61i2aaU+ln/VrOCot4aSIK9yQ Date: Tue, 10 Jul 2018 09:17:27 +0000 Message-ID: <5f34e43135ed4948bbc32849289aeb20@AcuMS.aculab.com> References: <20180710065147.27647-1-jmaxwell37@gmail.com> In-Reply-To: <20180710065147.27647-1-jmaxwell37@gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuMS.aculab.com X-TLS: TLSv1.2:ECDHE-RSA-AES256-SHA384:256 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 X-Virus-Status: Scanned by VirusSMART (c) X-Virus-Status: Scanned by VirusSMART (s) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jon Maxwell > Sent: 10 July 2018 07:52 ... > +static __u32 tcp_clamp_rto_to_user_timeout(struct sock *sk) > +{ > + struct inet_connection_sock *icsk = inet_csk(sk); > + __u32 elapsed, user_timeout; > + u32 start_ts; > + > + start_ts = tcp_retransmit_stamp(sk); > + if (!icsk->icsk_user_timeout || !start_ts) > + return icsk->icsk_rto; > + elapsed = tcp_time_stamp(tcp_sk(sk)) - start_ts; > + user_timeout = jiffies_to_msecs(icsk->icsk_user_timeout); > + if (elapsed >= user_timeout) > + return 1; /* user timeout has passed; fire ASAP */ > + else > + return (icsk->icsk_rto < msecs_to_jiffies(user_timeout - elapsed)) ? > + icsk->icsk_rto : msecs_to_jiffies(user_timeout - elapsed); You've not looked at what the above actually does - something like: msecs_to_jiffies() probably rounds up, the old code rounded down so dividing by HZ is probably right. int new_tmo = icsk->icsk_user_timeout - (tcp_time_stamp(tcp_sk(sk)) - start_ts)/HZ; if (new_tmo > (int) icsk->icsk_rto; return icsk->icsk_rto; return new_tmo <= 0 ? 1 : new_tmo; }