Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1510603pxb; Thu, 24 Mar 2022 23:12:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4Xga1u08NiklDgAskvj24jF+SZPLW11dTu4Z9FKHE0cq5YZ+qTr01qOyBooyIKRgxUn+6 X-Received: by 2002:a17:906:3adb:b0:6b7:876c:d11b with SMTP id z27-20020a1709063adb00b006b7876cd11bmr9697335ejd.250.1648188772463; Thu, 24 Mar 2022 23:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648188772; cv=none; d=google.com; s=arc-20160816; b=y100nM4qwIk7HvWAPpERreBWLOH45ZpuuUvimsMFpKLdREW0mrMiDPIL381yv8J5Gw YUGv5iFog/gIANYgZxGce4WJOC0e6asb9IzqFNtyQngFDSjyOzQDlcGi0NJAweCk3S55 wGatZyTSfX3P8xY410NxT6lmSYU5vXnXoBFYuKG85oUjMbZ/ALrZV8eJQfb8iFDGsnAB 5jpbo+9hZO3oOoSYFBNBffrsLmEXE6/t5YGnt+PQ1Q9gmaHIjXoq21c9tPcD30vaZMj0 V49elRv8ZkX4iIaDazxyw5NnqpQmLVHAHLB+ylbPYn4P+s6LRclLlNwPt8W+/+bQrozm wWvA== 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=5rsG9toEvk+yv0gvFyF46EXgKfcd55pOCxUTFUIEcfQ=; b=GnZlAybA8Yy/+PhSnFCZFZPu5gCiqZRgBXD5RuElnH7DVBguIG+3cOCjdgvItwGCjG kX77BdrKsyyDuY6qCOPtKc9E3FYkLlvuuI0xODzqCF0HgWuziQkWPPDoCizi23SS7VRM V07/Nxzal/F+ebpmVTAGq+hVEu5qGO4tTkKVag6xp0+evQCACgwFM6d79/W5vZudH9De Nbph32Wtf+E9iIbunnLPi/LJKfX3EwS4IFdGIdqHBpDBIt8K/0Kvfgc4B9MIpRXdomqq fwylESu1j5kj2Ghgkz3DqnQYwn0dlxdsFGORK+b3w+IyEmSwfCUmzkI1Wneg6cWrcddm g5JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=R1T7Yi+S; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=wPFJ2ajH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a50fc07000000b00418f08ff113si1705680edr.456.2022.03.24.23.12.28; Thu, 24 Mar 2022 23:12:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=R1T7Yi+S; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=wPFJ2ajH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350187AbiCXMaR (ORCPT + 99 others); Thu, 24 Mar 2022 08:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350145AbiCXMaQ (ORCPT ); Thu, 24 Mar 2022 08:30:16 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B1F190CC6; Thu, 24 Mar 2022 05:28:45 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648124923; 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=5rsG9toEvk+yv0gvFyF46EXgKfcd55pOCxUTFUIEcfQ=; b=R1T7Yi+S3DRcHjAkDL6FAu+WD4xDL9h6QDVV9r1zrxBMKCxTmNj92NHeTR3Sj8/8Yd2wOf HUZiaSZibfiUvWdtXuVrL6pVX0yVKUW3Tqho59Ma3l3y/j7ooKiFxextaYh/mTtKUfs4nd s+zmqDCy0qBDHN8TpJr3NG/y1bzx/E07jHylrW7GpKYAI9Fqf0dptXMJt+MIXkDiNeslqn yqi1zVk1euW8Cll+ilmXsU4hYZaB3kA6lBeICbnJTYySwxZU+jvdYFIYtw1oC0ZabQcrk/ asYqfcETKpBjXekVLkofpACguSVfCKjuap7DsNJGOy5HmTqHJ6tAxA6KdbDrjg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648124923; 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=5rsG9toEvk+yv0gvFyF46EXgKfcd55pOCxUTFUIEcfQ=; b=wPFJ2ajHVQdzMUlIDIjJVhzfn5miyQF8sblkaQT1znvApVNRq2fffqyPxzSB705UabvkKN YUnvHEYMnhuhVxAQ== 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: <20220323111642.2517885-2-asavkov@redhat.com> References: <20220323111642.2517885-1-asavkov@redhat.com> <20220323111642.2517885-2-asavkov@redhat.com> Date: Thu, 24 Mar 2022 13:28:43 +0100 Message-ID: <87tubn8rgk.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Artem, 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. The resulting text bloat is +25% on x86/64 and a quick test case shows that this is well measurable overhead. The first ones who will complain about that are going to be - drumroll - the network people. There must be smarter ways to solve that. Let me think about it. Thanks, tglx