From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BF44C433F5 for ; Thu, 5 May 2022 13:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379119AbiEENWG (ORCPT ); Thu, 5 May 2022 09:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379004AbiEENV6 (ORCPT ); Thu, 5 May 2022 09:21:58 -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 DF11A36E28 for ; Thu, 5 May 2022 06:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651756698; 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=dZYBN09igH8LtCAZWzaFJ4ayRRE7BNTVPZW2OM3YADI=; b=hCfPgJthobgLCk7MVI5YbbDazH/msf9MQISysUUXVDrZAPhKJ0lUNXZAaUI3tITEOPKIsj 18NWWPPm6ze/g9Ml5qT/7hj70gdxtprBOQ3/LzTXJplsUWf+aTTmzZMQLq4n65yHpSqVY0 qOU3Mtn45nVnTDeDAU3Ra7DhwiuR0XY= 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-668-Vc_JEwU5P8Oa5jz7d530gA-1; Thu, 05 May 2022 09:18:15 -0400 X-MC-Unique: Vc_JEwU5P8Oa5jz7d530gA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5355C185A79C; Thu, 5 May 2022 13:18:14 +0000 (UTC) Received: from shodan.usersys.redhat.com (unknown [10.43.17.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 159057AE3; Thu, 5 May 2022 13:18:14 +0000 (UTC) Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id 105471C0242; Thu, 5 May 2022 15:18:13 +0200 (CEST) From: Artem Savkov To: Thomas Gleixner , Josh Poimboeuf Cc: Anna-Maria Behnsen , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Savkov Subject: [PATCH v5 2/2] net: make tcp keepalive timer upper bound Date: Thu, 5 May 2022 15:18:11 +0200 Message-Id: <20220505131811.3744503-3-asavkov@redhat.com> In-Reply-To: <20220505131811.3744503-1-asavkov@redhat.com> References: <87zgkwjtq2.ffs@tglx> <20220505131811.3744503-1-asavkov@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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. 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); -- 2.34.1