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 5EDB0C433F5 for ; Mon, 4 Apr 2022 14:49:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377879AbiDDOu6 (ORCPT ); Mon, 4 Apr 2022 10:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378420AbiDDOuH (ORCPT ); Mon, 4 Apr 2022 10:50:07 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CDBF5F4D for ; Mon, 4 Apr 2022 07:47:57 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649083676; 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; bh=Hc+PPX5M4MD7sbTwM3c6soY+sh8HaVD6wZyeehgD76o=; b=tm2fv/GMfo6WffqxuaqhyObnILkQ9hdlRbLmnmQANijZo3tYvIOAtLd7/ju3oIIUMTDvLY v6tHqP/sfeMbd6F6BhcPf+uo+WtH+/f5bOXUYR55nf3osG2sEVDvoxHHYww+snDrtRFOoj 7UOhCHW4X/eExCyd1IRCol7mg65R71Q9gxZsZxcEMFepudro+21e7Dwv6sTpEWvSrXIa1w T83OlqYZ8m/TpqnDru0+iwOeTfFfi92Mpf2Mz+OjrR6+TFt9nm60BpOUtron/d41Zz7kaZ BdxJpztYGKD4KDjgUzoY5MmrdE8GfkKNSqIqXGpK2cXMmoCw7/sVOVaaQMx/NA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649083676; 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; bh=Hc+PPX5M4MD7sbTwM3c6soY+sh8HaVD6wZyeehgD76o=; b=dHCIaAemvC3N/Iidsv8X1vO6u/3vD05YNpg/b5ZukBmPVTnWjZTx5BK0PO2UiAzskt240S l1OwlcdxISILHJDw== To: LKML Cc: Anna-Maria Behnsen , Peter Zijlstra , Artem Savkov Subject: timers: Simplify calc_index() Date: Mon, 04 Apr 2022 16:47:55 +0200 Message-ID: <87h778j46c.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The level granularity round up of calc_index() does: (x + (1 << n)) >> n which is obviously equivalent to (x >> n) + 1 but compilers can't figure that out despite the fact that the input range is known to not cause an overflow. It's neither intuitive to read. Just write out the obvious. Signed-off-by: Thomas Gleixner --- kernel/time/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -502,7 +502,7 @@ static inline unsigned calc_index(unsign * * Round up with level granularity to prevent this. */ - expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); + expires = (expires >> LVL_SHIFT(lvl)) + 1; *bucket_expiry = expires << LVL_SHIFT(lvl); return LVL_OFFS(lvl) + (expires & LVL_MASK); }