Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2499245imm; Mon, 16 Jul 2018 09:01:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpepPUZX3+Pz9/KIhn/yDVjTiztjq70buA6PGiUoEPPABpaLqCROkw3rRF6gXD+mhBAL01gV X-Received: by 2002:a62:d444:: with SMTP id u4-v6mr18750696pfl.142.1531756885230; Mon, 16 Jul 2018 09:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531756885; cv=none; d=google.com; s=arc-20160816; b=g3LvftSVCQU2vwcu6gy3/ovmKwQ/xM+0QTtn147hoHCAJjIVqhso7biFWUlXfXIL4m Ac9MHL7DsxHiiAGh6BK/2xUDso3RhGkN+ysOkcsUv95BoSbJVsAh2nztOGkp7Nbb+uRB xAft6og9cJb4MQpgfbtuzro0KQziXRqmhwxj24S2B52R1BIy5miwmdBFJU5mZDoxl0XL thnqiGXcchzjhWn8LLRGxAmJon6/ue6gKwaD4WVLwRleOEDJMyO1k1I2BvgDZJIurLGg pNi5lejQjWQX3E72SPsga8JxzqZPkqVcRAQqrl4/1FdL3sXa+fn9EE2RsWP5Kltgk/r3 8PMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=sxxkZr3VF/56EjFQW1QrcKwsTV4FRk+Enwi8KLAb6Ko=; b=pAVFJollyMgu9DUB6KYeHFO3JamXQnHooAZxLpsIppHrUB/wnSX6rTgcZuewQc7v19 vEhXL4l4raLoA0jKA0kGuxk0WJsfVtSH0O3LlPMTpBbynVBsNqsLWwMAWhMpMZlC6GvF hNqdq8eZY0YsbeyC2i291fDm+6mvBgTyIQ0XPpC2CHIHlBt50rM5cflVMbqSyqsO7Gbn 4Rayrc6pPE5sE8FV7T+WnOmggzZHDzuRxxJs8dgRqsjuf9bDJ4tzB6siSxwXQsoxnWRd A59vo7Sj9GIQFieJNtul5+xGHC1NKi7r1Ud7P8Tsya+NRwSWgDYu4mN3TOdfBeAj8Vgw utiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Zsc8rGE3; 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 y65-v6si29418899pgb.199.2018.07.16.09.01.09; Mon, 16 Jul 2018 09:01:25 -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=Zsc8rGE3; 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 S1729814AbeGPQ2P (ORCPT + 99 others); Mon, 16 Jul 2018 12:28:15 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40268 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728023AbeGPQ2O (ORCPT ); Mon, 16 Jul 2018 12:28:14 -0400 Received: by mail-pf0-f196.google.com with SMTP id e13-v6so13124023pff.7; Mon, 16 Jul 2018 09:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=sxxkZr3VF/56EjFQW1QrcKwsTV4FRk+Enwi8KLAb6Ko=; b=Zsc8rGE3xDoXhvMlSmglsrHvdX+K1IFnst0DAOEnwpCbIWS2900kYJBGJQVFIu18Ny VjXl6E/sJVvMqtq/7J59uuTnP4/WnXPhiKUA2wDP+BSHCUf6VImkuTPDjXVDTsbXcUmE FLk28fNp2GYCuCd45yghqBrsuifUZkxUTostlpPgrY+fsGjZnoFQfdLTL0hsd0P0/1cI gvgCF6jnfxbRhd5fAQuswTdNwW26qjDOTGEj6fTIosxw319iY9DyykV+ukguG1hr2JbB M9IKHwjPEZJJ4UJflFcgNY/AI97u7Q4Tk7BOIfIjxlYl8qhDQIvC9kUXO5OyBEXNUDDt 9lDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sxxkZr3VF/56EjFQW1QrcKwsTV4FRk+Enwi8KLAb6Ko=; b=mgXi22PbztepkSjCFUBSHwcYjVcNGA4KIIh4drfZjRtiOs26222n8smeEF3Pe+4Bl9 GJg8bhrdOeomlWZnHiNw36A0pmEZl+EhTxdjdmiCdCKEGgGlvD/6KP46Krh2EYXN3dCU 15252pIOFwr8CSOUhcXbbEzUPTUBfeICRJzNlRpZ0c9ciu6ZM7aozeWdyhaVuw/dQL8J Vb6BUFmn7v8tns++un1+nm7KJi8V4WwCY9Ye5Ifk31nwMVfYzHQcTBaxDZ8YIRZ7si2v Fl4/JiGflaHQDgt9SlDGbOPunwnck5ch3b7t7ZW5P8cFKM4QL5Edsz+j3g60Rymx2jG/ GMsw== X-Gm-Message-State: AOUpUlEt5nwPUwYVOtoBdxvaf687kNjlED1ecuwkF6q2rRYQzE/h+YI7 Vc24Cf3TZpsbQUoW9xgkuJE= X-Received: by 2002:a63:bf43:: with SMTP id i3-v6mr16070071pgo.342.1531756811256; Mon, 16 Jul 2018 09:00:11 -0700 (PDT) Received: from ?IPv6:2620:15c:2c1:200:55c7:81e6:c7d8:94b? ([2620:15c:2c1:200:55c7:81e6:c7d8:94b]) by smtp.gmail.com with ESMTPSA id j71-v6sm10998169pgd.23.2018.07.16.09.00.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 09:00:10 -0700 (PDT) Subject: Re: [net-next, 3/3] tcp: convert icsk_user_timeout from jiffies to msecs To: Jon Maxwell , davem@davemloft.net Cc: edumazet@google.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 References: <20180713004919.18608-1-jmaxwell37@gmail.com> From: Eric Dumazet Message-ID: <9a96cc7d-e7bd-5be2-9ce4-e74918773560@gmail.com> Date: Mon, 16 Jul 2018 09:00:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180713004919.18608-1-jmaxwell37@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/12/2018 05:49 PM, Jon Maxwell wrote: > The final patch in this series. Create the tcp_clamp_rto_to_user_timeout() > helper routine. To calculate the correct rto, so that the TCP_USER_TIMEOUT > socket option is more accurate. Taking suggestions and feedback into account > from Eric Dumazet, Neal Cardwell and David Laight. Due to the 1st commit we > can avoid the msecs_to_jiffies() and jiffies_to_msecs() dance. > > Signed-off-by: Jon Maxwell > --- > net/ipv4/tcp_timer.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c > index 8ab8c9645294..d4d4b30a6bec 100644 > --- a/net/ipv4/tcp_timer.c > +++ b/net/ipv4/tcp_timer.c > @@ -36,6 +36,22 @@ u32 tcp_retransmit_stamp(const struct sock *sk) > return start_ts; > } > > +static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk) > +{ > + struct inet_connection_sock *icsk = inet_csk(sk); > + u32 elapsed, 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; > + if (elapsed >= icsk->icsk_user_timeout) > + return 1; /* user timeout has passed; fire ASAP */ > + else > + return min_t(u32, icsk->icsk_rto, msecs_to_jiffies(icsk->icsk_user_timeout - > + elapsed)); if (elapsed >= icsk->icsk_user_timeout) return 1; /* user timeout has passed; fire ASAP */ return min_t(u32, icsk->icsk_rto, msecs_to_jiffies(icsk->icsk_user_timeout - elapsed)); Thanks !