Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2220480pxb; Wed, 30 Mar 2022 19:45:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAHR0oWrirbdk1pdVdcb31LvVHUEeDNMPWlqSe16+64/jsqBxkCcG5ctYQVJXKDFoLqooL X-Received: by 2002:a65:6e09:0:b0:380:4723:b4e9 with SMTP id bd9-20020a656e09000000b003804723b4e9mr9148190pgb.346.1648694739502; Wed, 30 Mar 2022 19:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648694739; cv=none; d=google.com; s=arc-20160816; b=M81Ch9upXwnGhy1XwwA7NB65FigQUs9nyuCqDlDL9cOS/oDgoqoQRjsGtppno3Fy25 xuQHI+kZAtmWNkPH2iEjNWuSUBEiPfZYf1z4wEHjsISdPmE6hravVgudX3rSjV0pQten 7Gb14/H5IJ5WkFX2c9hUbL+5RXJj4Lfqy9o4KH1KgamdwKJOgGRx91fGd8SiwUfyMwfe b3YqItRnY88ewWr3UliS7GQI9+qI3Bns+ZpL2ZPw4XaP8zaWVJpimqb3+Q3p4UOsxhov RYtuBTApcT1P9T+APnjKEk5bnZlbJ4bpkyWwmqqI15WyxNHaRAU88fWEnhPL9mmGaN54 rPwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:dkim-signature:dkim-signature:date; bh=URUSnCfet5e8NJSvpD2xln45464mTe5fGEeiA24K6+I=; b=lLwHaIQgJq83R4EGqR/rAgbySsBMnnWxOFkJNn6t0WcJGH8WWz7X5UDATcxiXCi4qp /oulCnwvMWdEIgh6EQSOPI4eJ3CRfop+mEsniXLu1eYJgItq1uyF/BcGjO8ZhKcCIotj /TRVobI/++Rmcu4URAMjLdw/mFOXQ/fPMp9ataNff2HLXn4gvBIPWvU92lh/PqGgLeCc 7g6Cn2xKW0ZB5N8ZjuieqX3nVnwC98cYLqs5aiW/9hYVLGzqXTXhfkBcVFu01nTyIhnv P+3iiBr2bRIfxKgBCmJu2R5WWzKZzbrXlkgwyyHqPyiIqiq05aZF+GE5mZDxKaPkiykR ZdBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CMTqNe0F; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=LCrs2EK7; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b3-20020a63eb43000000b003816043f176si22595007pgk.875.2022.03.30.19.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 19:45:39 -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=@linutronix.de header.s=2020 header.b=CMTqNe0F; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=LCrs2EK7; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0364DB0D14; Wed, 30 Mar 2022 19:35:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345576AbiC3NnW (ORCPT + 99 others); Wed, 30 Mar 2022 09:43:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346174AbiC3Nmu (ORCPT ); Wed, 30 Mar 2022 09:42:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC442253D; Wed, 30 Mar 2022 06:41:03 -0700 (PDT) Date: Wed, 30 Mar 2022 15:40:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648647661; 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=URUSnCfet5e8NJSvpD2xln45464mTe5fGEeiA24K6+I=; b=CMTqNe0Ft63H1B1W2ZKhVzkk8skP0+B/bwHc/fHamUvnXGPAXecVuz6bp/pIwiJvRGXQfX 5ovppTkkCG+SxexafagScZsN3Odewj/zkqS/OGxS7FIRnzuryp2Wi+2hnVA+CeuVYCLZZj WJAXrmvvNlcc03Jj5NnWJqaR3c/1VDn70EuOxspydTTaKxHJnWNgn2TZIdlOKg1svWpAMn IJTK8/FUa0+C2HjqSCdYYkKQ8514GrElYBWW/oRGuNRh2coIxlx+CM7GOSKRkQXSPHCzd3 V/SbKP9b6qYM6tCo6EibQLGJanYPUWBZ2N3LPtNlWNd65h+JyGY3dBMEtw5PZQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648647661; 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=URUSnCfet5e8NJSvpD2xln45464mTe5fGEeiA24K6+I=; b=LCrs2EK7xnDDzGIlyUzmvDbTXueTgY6RJHkf7LeQutVECEzdxpLKK5UJoDfCtrr43NcPrj h0uAKrrrChlv0pDg== From: Anna-Maria Behnsen To: Artem Savkov cc: netdev@vger.kernel.org, Thomas Gleixner , Josh Poimboeuf , davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] timer: add a function to adjust timeouts to be upper bound In-Reply-To: <20220330082046.3512424-2-asavkov@redhat.com> Message-ID: References: <87zglcfmcv.ffs@tglx> <20220330082046.3512424-1-asavkov@redhat.com> <20220330082046.3512424-2-asavkov@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,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 On Wed, 30 Mar 2022, Artem Savkov wrote: > Current timer wheel implementation is optimized for performance and > energy usage but lacks in precision. This, normally, is not a problem as > most timers that use timer wheel are used for timeouts and thus rarely > expire, instead they often get canceled or modified before expiration. > Even when they don't, expiring a bit late is not an issue for timeout > timers. > > TCP keepalive timer is a special case, it's aim is to prevent timeouts, > so triggering earlier rather than later is desired behavior. In a > reported case the user had a 3600s keepalive timer for preventing firewall > disconnects (on a 3650s interval). They observed keepalive timers coming > in up to four minutes late, causing unexpected disconnects. > > This commit adds upper_bound_timeout() function that takes a relative > timeout and adjusts it based on timer wheel granularity so that supplied > value effectively becomes an upper bound for the timer. > I think there is a problem with this approach. Please correct me, if I'm wrong. The timer wheel index and level calculation depends on timer_base::clk. The timeout/delta which is used for this calculation is relative to timer_base::clk (delta = expires - base::clk). timer_base::clk is not updated in sync with jiffies. It is forwarded before a new timer is queued. It is possible, that timer_base::clk is behind jiffies after forwarding because of a not yet expired timer. When calculating the level/index with a relative timeout, there is no guarantee that the result is the same when actual enqueueing the timer with expiry = jiffies + timeout . Thanks, Anna-Maria