Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp20017imm; Wed, 4 Jul 2018 16:36:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeY6ITO9XOtlLgX20APka7+R+5cw9nrZqTzx5Soq7mO7V+zvRZZFJ+FsuOP07XKCqMFcBW9 X-Received: by 2002:a17:902:9a08:: with SMTP id v8-v6mr3879049plp.148.1530747362931; Wed, 04 Jul 2018 16:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530747362; cv=none; d=google.com; s=arc-20160816; b=KVZIiSTgXj9V/CDqXgJ0d7nlKNoZtXgg0v4G+MQpIAC8AbdE8E7jJKMJBGhFhtaeSr IKMYg15qsG6WdvzZD+Mjl+hhb8XLBb/CybyflSx9fqsvcCddrwW537zp1x7zpbHv8qBk BlZMNcOh3H2V3vmqpi077ueUEV4EXY8bdZ9xlA+qrmr+sKjCSaQGU7CH+gkVuRjFQHyW 5lYzjZZs862fKxwmE14EUhZPKZMoYO9VOI8ERsI32E9UJ0dZNW26ARW4FLojOO2vCFIl f6sfrKlkzNHGrQvLbYjjPLCoWCnK3e+kllSWterP+f/Ns6yS1DCCmXFySVWduWJ686hz pVkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=p9opAcSO0RnsCyqZl5PK1gPkL6JVP02xw58FUbGrMsM=; b=lYkj1pVVk/V07Ui+B6ocMql4X0NF673UjjrhwMhvSFbaCJy03LYPopecg7cGXMQsY9 KAPdLclbijViWabZijEgW20MVe580pbJ1pzMNnY/jPaDgJIxKnLBYAnOvCPernKGKKyy 3fVytGS/FxypRXoAEaVz+kWpRCf+dtjOmCEo7Ia0DQUsAkukCs9uQACIv+6RIan0MoEX vvmG/wXuVcc7QhtdG0t4OlE7XO2cx192jzukSanS5xQavtG3aRP0hFL5R3ad1yXR5Syv ynwGaw/eHuT9wP/Dd5foQv9kfrm/DKgfIONJxrfjdpJa1uDAazRL+3gyAAeTW19JDjHp YsRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uNlIWmL5; 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 h185-v6si2475736pfc.172.2018.07.04.16.35.46; Wed, 04 Jul 2018 16:36:02 -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=uNlIWmL5; 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 S1753013AbeGDXfH (ORCPT + 99 others); Wed, 4 Jul 2018 19:35:07 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38957 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752937AbeGDXfF (ORCPT ); Wed, 4 Jul 2018 19:35:05 -0400 Received: by mail-wr1-f66.google.com with SMTP id h10-v6so114867wre.6; Wed, 04 Jul 2018 16:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=p9opAcSO0RnsCyqZl5PK1gPkL6JVP02xw58FUbGrMsM=; b=uNlIWmL5RhbJYWG3nZa58oQ1ZxzBLbHDdkGpE6QjK1kFz9hhANegn6q1pwBpxhKWk3 CZbOeCjEvDSj2wdhHVXpf0ukKyyKv8frfJ+LE7m55Wnu58Zwu5Q3ieDUzD28hWCa6zho nXSDrZ5WRljUo9R+rHdmsP3CfojE8HRIf9etvgdtaxcYYWgaibmpbxDI1kZjfDwrkFMC wJ9hvUpBd4um/aowyDnb5tZ/Ef/Qr7yRib9KJNh3RqgX1opqYtlYf56aWHLbd3WhBta5 ZF+17e3Usf7KqMU3C7E/ukV0LVPtguUPUkjnTQvpT/LqptDy+M6OORqYGNgjMTNk7CPo eq0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=p9opAcSO0RnsCyqZl5PK1gPkL6JVP02xw58FUbGrMsM=; b=QeZ1uCc2/c2fqzAwJ3DfpX028F6D+LlMW5EoL9HkkWYcbngf9VTdlmoXg8QnY7aSri +qm+0bX68k5kGNfa3DTqbNT9hr24VyMAo+ijE/JPwtBx+Z63uirgz+zMS3UddraczuUA z1pRL/GEx6EX7Awfkg8tau7kytin0omWRfo8XXwXixoJhZsg3L7jyxBdwhvFIQaIeXo7 1u1QGigzVMNjXtft1GZfk/mMWkndHHaX8jagcS/ok7hXlj1RMtaZiJ86GpKfu6c4jO7M r5uQ261Bh6ck8MG/+HNt6HTIj+jNUMPswNu7S5XRrx+54srXB9IJB+8Ty4mpz7tzRs5Y O7pA== X-Gm-Message-State: APt69E0BeNR7O4E+sgRJNzqvCsFXnkm7zOC7EkLOpSjBUF9M1wZQY0PU YR5EMZVE+/Br2SmsOEpzdlV8/GPk0/8lqAWfBJg= X-Received: by 2002:adf:e78d:: with SMTP id n13-v6mr2792347wrm.136.1530747304517; Wed, 04 Jul 2018 16:35:04 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:8a8a:0:0:0:0:0 with HTTP; Wed, 4 Jul 2018 16:34:23 -0700 (PDT) In-Reply-To: <2a78c5cbb53248289b54505aece15584@AcuMS.aculab.com> References: <20180704000608.17360-1-jmaxwell37@gmail.com> <2a78c5cbb53248289b54505aece15584@AcuMS.aculab.com> From: Jonathan Maxwell Date: Thu, 5 Jul 2018 09:34:23 +1000 Message-ID: Subject: Re: [net-next,v2] tcp: Improve setsockopt() TCP_USER_TIMEOUT accuracy To: David Laight Cc: Neal Cardwell , David Miller , Eric Dumazet , Alexey Kuznetsov , Hideaki YOSHIFUJI , Netdev , LKML , "jmaxwell@redhat.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's wait for Eric to review. Then I'll put together the next version. Regards Jon On Thu, Jul 5, 2018 at 12:57 AM, David Laight wrote: > From: Neal Cardwell >> Sent: 04 July 2018 15:14 >> >> On Tue, Jul 3, 2018 at 8:06 PM Jon Maxwell wrote: >> > >> > Signed-off-by: Jon Maxwell >> > --- >> > net/ipv4/tcp_timer.c | 48 +++++++++++++++++++++++++++++++++++++++--------- >> > 1 file changed, 39 insertions(+), 9 deletions(-) >> > >> > diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c >> > index 3b3611729928..d129e670d02a 100644 >> > --- a/net/ipv4/tcp_timer.c >> > +++ b/net/ipv4/tcp_timer.c > ... >> > +static __u32 tcp_clamp_rto_to_user_timeout(struct sock *sk) >> > +{ >> > + struct inet_connection_sock *icsk = inet_csk(sk); >> > + __u32 rto = icsk->icsk_rto; > > Why cache rto past all the function calls until it is needed? > >> > + __u32 elapsed, user_timeout; >> > + unsigned int start_ts; >> >> I'd suggest u32 here for start_ts (per the rationale above). >> >> > + >> > + start_ts = tcp_retransmit_stamp(sk); >> > + if (!icsk->icsk_user_timeout || !start_ts) >> > + return rto; >> > + elapsed = tcp_time_stamp(tcp_sk(sk)) - start_ts; >> > + user_timeout = jiffies_to_msecs(icsk->icsk_user_timeout); >> > + if (elapsed >= user_timeout) >> > + rto = 1; /* user timeout has passed; fire ASAP */ >> > + else >> > + rto = min(rto, (__u32)msecs_to_jiffies(user_timeout - elapsed)); >> >> My sense is that min_t would be preferred here, e.g: >> >> rto = min_t(__u32, rto, msecs_to_jiffies(user_timeout - elapsed)); > > Think I'd just write the conditional... > >> > + return rto; >> > +} > > Looks to me like it doesn't correctly allow for the conversions > between millisecond and jiffies either. > I suspect the msecs_to_jiffies() call can return zero (unless it rounds up). > Coding with a signed 'time until user timeout' might make it simpler. > > David > >