Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp659452pxb; Tue, 12 Apr 2022 10:06:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLuXIPLzsgR7WSA+Axc7Ck4U+PtTN1K7mMO6dJYM9sIsvzRI41I8b3TSsgP5W/2sKZ19zY X-Received: by 2002:a17:907:d05:b0:6e4:49ac:9b26 with SMTP id gn5-20020a1709070d0500b006e449ac9b26mr36362250ejc.133.1649783177450; Tue, 12 Apr 2022 10:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649783177; cv=none; d=google.com; s=arc-20160816; b=XXZbVlYfx1O2QS5XpQOEZczBRyTPnWK5MBa5hfMSCREyYuVABbj9IthiY5J6QQPc4Y 4BG14gbS2oL/gTXikg6K2rgGHzhxCV9A+hbhZbU9S/MULsEA48afxf4CH3t00xI8m6F3 YAp1sKD7YxovmbAXxR5hWp5rrSZrVCLQ+XrqGGsjbP4VljDwKXfRSC2TIBv7EH3Rp4ko VzaJ7jNx+q5u6hkbskCagwNhvS572DIH4bxcisMZJYocmzflg1TE08VuSov6m9b7oRng 4X03xqowENXle/WHKg3nBxyHo8z2RkojJFct0i6s60ZxntHF6Q/+lD3fnraDcle4A54k Izkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=8zaOcmLacimZqKKgJ63XfnGyUqu5Teh+3oLuqT1XOXc=; b=ahT628c70lIy19UtqjNCZOxA+gQWKOCIjUWgyzTuJVk3BHygXTW80fhF1Ps6A8XYo6 rd6npjz9QAOc5wQaVOMACWcKYVtEg5IgX3oaBs+RdZ3RcB9lDXqxOJj3FgrSENw9W7Eh vu2k/Tq6yYC28pZvl3asW7HriAHfVpNHPAQfBc8VAjBmuATVOP1jjxyJvPQyYQiSz7RN RTdpHwY+Yd693YHddSG48lW8GLS6wWKLQl31SHY1W2PQuwWNN0d+7z494qIJtK9e2TWn QVgYeoEqJMoSW43J9sInh13s7Lpo7aEigVYJpL5/UOSj1YZCMgPHgWIzIqkeyjrd4UPd Kz/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="10RPt3/Q"; dkim=neutral (no key) header.i=@linutronix.de; 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 i10-20020a0564020f0a00b0041d94774f1asi871314eda.598.2022.04.12.10.05.49; Tue, 12 Apr 2022 10:06:17 -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="10RPt3/Q"; dkim=neutral (no key) header.i=@linutronix.de; 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 S235642AbiDIUY4 (ORCPT + 99 others); Sat, 9 Apr 2022 16:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231330AbiDIUYo (ORCPT ); Sat, 9 Apr 2022 16:24:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF2BE2BCE; Sat, 9 Apr 2022 13:22:34 -0700 (PDT) Date: Sat, 09 Apr 2022 20:22:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649535752; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8zaOcmLacimZqKKgJ63XfnGyUqu5Teh+3oLuqT1XOXc=; b=10RPt3/QkNPy1Q6lI1vM1kB0GqlGn8ye3vu+/4RbBeHFIHRMA+uO1i6Vgguvd9SDXp4QwO Egy33v8bPwmf71plab1c14WZMtth9rCTNVfP0tJpKoaMiDSnUWGsHB3W5STycLGfeBIIMv NtUKHNG7NJtL0oTvLZEZ2XE5zo5GFlqmaWdVKDH8f22i3M8pU6tdd/Kgl7fI9hNQEjaAvF iJ7YaNvzSt7yQcdHWkOQB9icb2ntyDXf3vZBUEhitsxVfcYn47TWde5pXE072M2LTT6zOE EbzvvbWc0Mu3oGpQs0lckdl2ylfzN9o9cDKRjZWaUY2bgHBEbkmnL5AnRDcMOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649535752; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8zaOcmLacimZqKKgJ63XfnGyUqu5Teh+3oLuqT1XOXc=; b=GDVrwfohIS5ekAag54Ki7/L048J1H20Hm41fBGfjdcVuRUbFnnk9JDqvKF9zC7AdyGGY58 FLA8szonjkLYfDCw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timers: Simplify calc_index() Cc: Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <87h778j46c.ffs@tglx> References: <87h778j46c.ffs@tglx> MIME-Version: 1.0 Message-ID: <164953575112.4207.4558393487753239676.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 The following commit has been merged into the timers/core branch of tip: Commit-ID: a2026e44eff5d74a83d7ffee6325a007bef85385 Gitweb: https://git.kernel.org/tip/a2026e44eff5d74a83d7ffee6325a007bef85385 Author: Thomas Gleixner AuthorDate: Mon, 04 Apr 2022 16:47:55 +02:00 Committer: Thomas Gleixner CommitterDate: Sat, 09 Apr 2022 22:19:39 +02:00 timers: Simplify calc_index() 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 Link: https://lore.kernel.org/r/87h778j46c.ffs@tglx --- kernel/time/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 204d6cd..60aebf2 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -502,7 +502,7 @@ static inline unsigned calc_index(unsigned long expires, unsigned lvl, * * 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); }