Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2190302pxb; Fri, 25 Mar 2022 12:42:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZQulJatSunH2flyoyTY8OyTjQfbRLBm/CrMjuf8gxeGWGWQpE9LZ5Hg/EU8WQLnVIRkXn X-Received: by 2002:a17:90b:1c88:b0:1b8:a77e:c9cb with SMTP id oo8-20020a17090b1c8800b001b8a77ec9cbmr26383668pjb.205.1648237359617; Fri, 25 Mar 2022 12:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648237359; cv=none; d=google.com; s=arc-20160816; b=qPwRcvUnV/QijTH8NervLaFsCctqBx/vwzTnr56C2xomdxj/pIL5nYGEtE2bUi1pLR 8ndLi8WEPvo5ytF77k9IOcQCK3LdS/JN+O8Wu+1xQ/loK9F8tHLwDQz3ZoKrGTvEk09/ mc5El4wkGRz0L+DtH2e9YxTPgAX9VmG9A+VcdHj1aAFsuoyBBM+nkD8VtM7e696w4/bi 5vr22UMpWOglWA7ubRK8bBIp9QUk/eMIWz+GqOoMs8pYA5Up8lWSAzOBtrdM4WOwi/sx FtM6iw+j8d1P+bHLqnBrClHeuNtiZjEL6A7Dh7J1ZBUSPHKVlpQ5vXPzrkJkuS7YTGKD NmAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=bo4oh0xgueLYq/ZucSpzqDXmdQwXHyaJwvL+CGmcSVg=; b=cDDulALoh7HamMWpH6iJSQovuWDzsHFddxoR0SsAM9HxjTIekmHu8JJEZcAc+3hWIc i8EP1sFP+J6kPpTnMmASXdGWAzpfdRPumieofSGI5NnTiAl0a/dH1H4gs2Iqbam64/8Z d5WqwGckfhZHpcpwDfk0aKMreQC+vZOOd2kr4OaulIAgKAL99f0HsLkHIRTRFxCO/ZwN EK+kzgbX2I5PYNq1/ZVK78fMABTzuer58C0wTExT2yP40c8AsxRQGElqwguZkRZTFXDw JKGIqoSw7etEu+n0EAOdTR0cac8wH8QfduTfOLkXaIQzDwvyrwQUDKLmIr/6wrYNs7Iu vtCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=n2mkfR5E; dkim=neutral (no key) header.i=@linutronix.de; 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 c4-20020a63ea04000000b00397ff5a487asi2361744pgi.189.2022.03.25.12.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:42: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=n2mkfR5E; dkim=neutral (no key) header.i=@linutronix.de; 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 B77C4292B84; Fri, 25 Mar 2022 11:32:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350691AbiCXN4B (ORCPT + 99 others); Thu, 24 Mar 2022 09:56:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350682AbiCXNzy (ORCPT ); Thu, 24 Mar 2022 09:55:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF9B23AA51; Thu, 24 Mar 2022 06:54:22 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648130061; 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=bo4oh0xgueLYq/ZucSpzqDXmdQwXHyaJwvL+CGmcSVg=; b=n2mkfR5ErnTI17aWRsmxHA4JLR70o7LNo8nMWo2Hywde6OoRxPhE7FuBCehyVUYtmN1G3g LR69WNhbDCcQwHUYLpAxW19+Yc/BnbOU/OsuSluiKrwmemkwt6mR+R2itDPNa0/SXryA+B kCuS8YmjEQrNRnveOh/6t0UHL91YvI35yh2Pu6lqcJO8BJsbIOsDDUXFO2khgvrNNM0+9w jliDisJJX7RvpVHMGLBZEW83gKb8a7IiUz9oIeVSVCMotpU9dVh6fBO4kvchAtuQaFb7LW bG0sUHiw20ALTFPSI6hAg2iGJsbHDgHEWqn2n0kpsbXQygbXETVImIoVuGE4MA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648130061; 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=bo4oh0xgueLYq/ZucSpzqDXmdQwXHyaJwvL+CGmcSVg=; b=PgKBGTgT2lglTNsJjTiAMUa7pDuUgUiyaQyd3SQh17Ir3RDl04oCLL//HuioEWtDSfDyJ5 vBr0yD/TANvOkDCA== To: Artem Savkov , jpoimboe@redhat.com, netdev@vger.kernel.org Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, linux-kernel@vger.kernel.org, Artem Savkov , Anna-Maria Gleixner Subject: Re: [PATCH 1/2] timer: introduce upper bound timers In-Reply-To: <87tubn8rgk.ffs@tglx> References: <20220323111642.2517885-1-asavkov@redhat.com> <20220323111642.2517885-2-asavkov@redhat.com> <87tubn8rgk.ffs@tglx> Date: Thu, 24 Mar 2022 14:54:21 +0100 Message-ID: <87h77ncv76.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain 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 Thu, Mar 24 2022 at 13:28, Thomas Gleixner wrote: > On Wed, Mar 23 2022 at 12:16, Artem Savkov wrote: >> Add TIMER_UPPER_BOUND flag which allows creation of timers that would >> expire at most at specified time or earlier. >> >> This was previously discussed here: >> https://lore.kernel.org/all/20210302001054.4qgrvnkltvkgikzr@treble/T/#u > > please add the context to the changelog. A link is only supplemental > information and does not replace content. > >> static inline unsigned calc_index(unsigned long expires, unsigned lvl, >> - unsigned long *bucket_expiry) >> + unsigned long *bucket_expiry, bool upper_bound) >> { >> >> /* >> @@ -501,34 +501,39 @@ static inline unsigned calc_index(unsigned long expires, unsigned lvl, >> * - Truncation of the expiry time in the outer wheel levels >> * >> * Round up with level granularity to prevent this. >> + * Do not perform round up in case of upper bound timer. >> */ >> - expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); >> + if (upper_bound) >> + expires = expires >> LVL_SHIFT(lvl); >> + else >> + expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); > > While this "works", I fundamentally hate this because it adds an extra > conditional into the common case. That affects every user of the timer > wheel. We went great length to optimize that code and I'm not really enthused > to sacrifice that just because of _one_ use case. Aside of that this is not mathematically correct. Why? The level selection makes the cutoff at: LEVEL_MAX(lvl) - 1. E.g. 62 instead of 63 for the first level. The reason is that this accomodates for the + LVL_GRAN(lvl). Now with surpressing the roundup this creates a gap. Not a horrible problem, but not correct either. Thanks, tglx