From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADB9B3ACA53 for ; Tue, 24 Feb 2026 16:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771951125; cv=none; b=kXYIaha9Xpxwu2N25WG6pHWcjiTXw5Imspv+RswOKy6t+68/7bgANdo857W/HAK/Ib0iGL1gGbrBXrefimVlJpL/KDbo9Q64nsDUglCKYhOQRTUB6vG8oROc3X2jJxm4ElhKY/Amjhr7hNaJCR2L6onk+69FD8M96MI2mP48RIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771951125; c=relaxed/simple; bh=6fDl7jGUwqF0HXeZoXbzJc6gvvPqvyoTJsnltVER2lI=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=aLd0rGSIK251sx4O6fYjks4Pl+oaxIShDwG6mv1Xo0GhigEq49SXWsamXKTd4lAR92Qlqiku6nnWHRCvSldNs3//lPwYWXP2wvfUp6g87IVzzgumBFlHejmzTDsr13xtZksiKbMfj1OfxqpKu2W+O+jRsXC8lbbs3lLFYnOHP7g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jIL4L3GI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jIL4L3GI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3BB8C116D0; Tue, 24 Feb 2026 16:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771951125; bh=6fDl7jGUwqF0HXeZoXbzJc6gvvPqvyoTJsnltVER2lI=; h=Date:From:To:Cc:Subject:References:From; b=jIL4L3GIkKG3P17ujrA1RzVKlD57iwJz7C/ptNdkyKu9f04FSOR7S5xXxr3tuURbD Cj8oAZ2WdZz3nw8CE8JlchtBTUTsX+lrwFVEhN1NjZWIJCuSUrWizyfgABHeEhK8bN PCUYC9/wFFS1Tj2Gpn7KRsVZcK+8CPgb+ofZMAv4p9geBbqKG8j7opzyzlJm9Nl5xi ymW5iLAu0iUr5tk7wHXDDahdwPZ8veRtJgdUUvfD70Llz07aFjw5qjTc9rxjvdWlPm COu+DFFRkyN4OA7qs832t0bye10hbSAB6oNSX8aQOAzlZDRQ4PfDdpKvnjk8XnVAyr hqvJzs1yfmElA== Date: Tue, 24 Feb 2026 17:38:42 +0100 Message-ID: <20260224163431.599804894@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , John Stultz , Stephen Boyd , Daniel Lezcano , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , x86@kernel.org, Peter Zijlstra , Frederic Weisbecker , Eric Dumazet Subject: [patch 43/48] hrtimer: Optimize for_each_active_base() References: <20260224163022.795809588@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Give the compiler some help to emit way better code. Signed-off-by: Thomas Gleixner --- kernel/time/hrtimer.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -529,22 +529,10 @@ static inline void debug_activate(struct trace_hrtimer_start(timer, mode, was_armed); } -static struct hrtimer_clock_base * -__next_base(struct hrtimer_cpu_base *cpu_base, unsigned int *active) -{ - unsigned int idx; - - if (!*active) - return NULL; - - idx = __ffs(*active); - *active &= ~(1U << idx); - - return &cpu_base->clock_base[idx]; -} - -#define for_each_active_base(base, cpu_base, active) \ - while ((base = __next_base((cpu_base), &(active)))) +#define for_each_active_base(base, cpu_base, active) \ + for (unsigned int idx = ffs(active); idx--; idx = ffs((active))) \ + for (bool done = false; !done; active &= ~(1U << idx)) \ + for (base = &cpu_base->clock_base[idx]; !done; done = true) #if defined(CONFIG_NO_HZ_COMMON) /*