Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp200156lfu; Wed, 30 Mar 2022 20:39:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPSPSLAMFgv0LS/aw0/7FzzcuOq94I4E8mz3hSg0XcZg2YRW7Fm2cMsc+5Nsf942CTfoI5 X-Received: by 2002:a17:90b:4a88:b0:1c7:9bc:a72e with SMTP id lp8-20020a17090b4a8800b001c709bca72emr3597897pjb.112.1648697993071; Wed, 30 Mar 2022 20:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648697993; cv=none; d=google.com; s=arc-20160816; b=QBhXQRyB7Z6lHF/mCaF3ax3znzbnTqjS+tdT7dT4E0NVR2qAAe0204rR+eBEGwflyh jDcgQfDkoYzEhha+gDwywkRlsTJKRDnBZaz5BIwtoh1NfI8M2zSygEibn84SbX9qrcSl C245q5yS44ZKhtDU4jAbkaOEWm9cOwwXFFD7j1k13aWLRxJ50OdfUgXAhQX+k5qTfnaE F8pVQmZ5rfqgXCiYGt+8K1kO+Xz4Wn16wuSa2+xsMoleg074ghgDkDbiZQlYMxcx8qhd /JiGmysg7l7pHoJsEUrxezSFefe2ye3rnDT1AROkLIQZYGzwXSB/0THqg+zcDCxFUr6y /wog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qQwtpv4LSJs4oYZkfG+yHqo4mCAyzu9Mqm5FcRavI60=; b=tNyMo9OrgspmKONqZkfa5gpvCSRoDwwHANeUWRQJ12e74nY+2PeyrFIz0J1HH6AkTm T+ufHXefyG38fJW6ZcxIyDCQoWLqWs2xbM5mA+0pGFw9pK/NqlY+BtBnVxMAWWcrjeoA LpABjZYClNzKGxXTFGXBZMXPfG40iA6/c1iZlEkg0trwNAl3XbsM8YWul02FxEPNrIi4 Vg971P/yvNM+xQuO6/Dg59Z/4v3xinYq1W4DA2tVcIFZPz4a+p3CZgC/dZRX19HKCnQO 9vpxmiLKyHq9isqVdrFTUEnUv/iFvNGHhNgl7wvf8VVeFHbR4J9Cl7ajF9M3HwL+sgK3 x8FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EobXktrW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id n21-20020a62e515000000b004fa3a8dfffesi21938045pff.181.2022.03.30.20.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 20:39:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EobXktrW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 45A932E686; Wed, 30 Mar 2022 19:59:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244389AbiC3IX1 (ORCPT + 99 others); Wed, 30 Mar 2022 04:23:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244335AbiC3IW5 (ORCPT ); Wed, 30 Mar 2022 04:22:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 046DA30F75 for ; Wed, 30 Mar 2022 01:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648628471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qQwtpv4LSJs4oYZkfG+yHqo4mCAyzu9Mqm5FcRavI60=; b=EobXktrW0+gkWzx8tiaOBo7h9Vugaosu9pBImxeEgKAHo3ifFWXYJs0b/mhdt8E19tT/WG dASw+oRJDkOnT/i2Ij0fuI94mLraD55uQLHnqU20WDIOn1nR0g2l2x3nqrFFYD6Ne7N/UL j/h1n+u/Zw2UpvhDyciHjmu+ElM7Oak= 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-474-qz63oN9hMCCk3vbMmhF4qQ-1; Wed, 30 Mar 2022 04:21:07 -0400 X-MC-Unique: qz63oN9hMCCk3vbMmhF4qQ-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 4CE40100BAB1; Wed, 30 Mar 2022 08:20:56 +0000 (UTC) Received: from shodan.usersys.redhat.com (unknown [10.43.17.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD8612166B3F; Wed, 30 Mar 2022 08:20:49 +0000 (UTC) Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id B64E21C021C; Wed, 30 Mar 2022 10:20:46 +0200 (CEST) From: Artem Savkov To: netdev@vger.kernel.org, Thomas Gleixner , asavkov@redhat.com, Josh Poimboeuf Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, Anna-Maria Gleixner , dsahern@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] net: make tcp keepalive timer upper bound Date: Wed, 30 Mar 2022 10:20:46 +0200 Message-Id: <20220330082046.3512424-3-asavkov@redhat.com> In-Reply-To: <20220330082046.3512424-1-asavkov@redhat.com> References: <87zglcfmcv.ffs@tglx> <20220330082046.3512424-1-asavkov@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-2.0 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=no 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 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. 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 1e5b53c2bb267..bb2dbfb6f5b50 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); -- 2.34.1