Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4651749iob; Sun, 8 May 2022 20:39:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxFsv8oJt4hGnnq0h+2U83DH+nfcMOjS2UjNletTJjmr0g/Ym6bxGBZzNcy0FVXbEFlTG5 X-Received: by 2002:a05:6a00:238f:b0:4f6:b09a:4c63 with SMTP id f15-20020a056a00238f00b004f6b09a4c63mr13885464pfc.35.1652067578348; Sun, 08 May 2022 20:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652067578; cv=none; d=google.com; s=arc-20160816; b=gKVqmVztKbqnBDI+IftUSaEtfs4AUuFGJ8lAOaC8wAyC8yC6i9JuH2kB/sh3yLg3HF gXW3B3UmzpNWCkEs8ga0USQQA76VqVsmWdPz+dVw80oA9CK4H9VDzRCy5C4qWfJFcO7y 9ibL+02NkUfpXKBquQh/x9s//nQ2EMEbFi8ZqZMXWKJf00vp4ImFX2pe+A+Zin33363i 90uAKhkDwaWiEBaAHS/QE8MnrMYiqU91QNnQCaNaPRv0XeL3dLePA9I9LWNj+wKq90JE P0sp/lIKImhBbw9XJwgGEMMxf/eL/qWUpQ9MSMhjKLfNaWWoiziy6Cvzde4TIPWPohC+ 4Q1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=xb5hsCR6vYhEn6zB3BaM7s+6s3NgLuWsFQFQ8PP7p2o=; b=J+jLQToQov8NztYNdxB7NcJk7s+mgxEygYOo+Fq1D3crIMuJNElv9kpAhwVqBKPMcy HOc2IeaX8f9DukJ8/olSg2w+KL/KhnAvw2aOTE+NxCjtTUNh5dlwZPZfDgq1u46JGO4l WgbyGXLfgPhSwF9Q4NZ6dNj8AiVYjDgh+ITkHgT+y9er4DkoQdnMMxXha0m/h1ik0e1Y yfWg0smk9MQJeoqrEmGhLEnz0q6qV2Fmr8IeQbYMv4TGAM6qhkl+taySTtXPm7jO2K9O drFMbyXqW7owGuf7XmsrJlaofbrg7VhwjoYaokvlIa23fHZRSYLHsA8s7RDpsPcNoh1J +jQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dxunkiyN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r138-20020a632b90000000b003820d821f00si12284899pgr.473.2022.05.08.20.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:39:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dxunkiyN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ECB28AD103; Sun, 8 May 2022 20:39:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238067AbiEFGm7 (ORCPT + 99 others); Fri, 6 May 2022 02:42:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235721AbiEFGm5 (ORCPT ); Fri, 6 May 2022 02:42:57 -0400 Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.133.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C794466220 for ; Thu, 5 May 2022 23:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651819154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xb5hsCR6vYhEn6zB3BaM7s+6s3NgLuWsFQFQ8PP7p2o=; b=dxunkiyNi5YBtnYne6r2s9X3VJTLdMfBxqNU4lLH4Ogd7PXI4psEjDCPeG8h12xUO5x8OC OqWYum8jWqxvlr721J3zOFAtvL6zwsMoBulIhfi+a1x2ChiZjgWF9Spy7lr0FwdVdi9WSV lqXRRQ2oOUEMdPtfMBfYNRW8DABOrgs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-MMEcz8QbMauv4T_PH7qIZA-1; Fri, 06 May 2022 02:39:11 -0400 X-MC-Unique: MMEcz8QbMauv4T_PH7qIZA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18123833961; Fri, 6 May 2022 06:39:11 +0000 (UTC) Received: from samus.usersys.redhat.com (unknown [10.43.17.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46E1E2166B2D; Fri, 6 May 2022 06:39:09 +0000 (UTC) Received: by samus.usersys.redhat.com (Postfix, from userid 1000) id 30EE960A; Fri, 6 May 2022 08:39:08 +0200 (CEST) Date: Fri, 6 May 2022 08:39:08 +0200 From: Artem Savkov To: Josh Poimboeuf Cc: Thomas Gleixner , Josh Poimboeuf , Anna-Maria Behnsen , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 2/2] net: make tcp keepalive timer upper bound Message-ID: Mail-Followup-To: Josh Poimboeuf , Thomas Gleixner , Josh Poimboeuf , Anna-Maria Behnsen , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <87zgkwjtq2.ffs@tglx> <20220505131811.3744503-1-asavkov@redhat.com> <20220505131811.3744503-3-asavkov@redhat.com> <20220505175654.jhu3zldboxdcjifr@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220505175654.jhu3zldboxdcjifr@treble> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 05, 2022 at 10:56:54AM -0700, Josh Poimboeuf wrote: > On Thu, May 05, 2022 at 03:18:11PM +0200, Artem Savkov wrote: > > Make sure TCP keepalive timer does not expire late. Switching to upper > > bound timers means it can fire off early but in case of keepalive > > tcp_keepalive_timer() handler checks elapsed time and resets the timer > > if it was triggered early. This results in timer "cascading" to a > > higher precision and being just a couple of milliseconds off it's > > original mark. > > This adds minimal overhead as keepalive timers are never re-armed and > > are usually quite long. > > > > Signed-off-by: Artem Savkov > > --- > > net/ipv4/inet_connection_sock.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c > > index 1e5b53c2bb26..bb2dbfb6f5b5 100644 > > --- a/net/ipv4/inet_connection_sock.c > > +++ b/net/ipv4/inet_connection_sock.c > > @@ -589,7 +589,7 @@ EXPORT_SYMBOL(inet_csk_delete_keepalive_timer); > > > > void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long len) > > { > > - sk_reset_timer(sk, &sk->sk_timer, jiffies + len); > > + sk_reset_timer(sk, &sk->sk_timer, jiffies + upper_bound_timeout(len)); > > } > > EXPORT_SYMBOL(inet_csk_reset_keepalive_timer); > > As I mentioned before, there might be two sides to the same coin, > depending on whether the keepalive is detecting vs preventing the > disconnect. So this might possibly fix one case, while breaking > another. But cascading is still there in the handler so it will fire off quite close to original timer in any case. -- Artem