From nobody Sun Feb 8 03:27:34 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B6E6C135A47; Mon, 26 Feb 2024 22:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708986284; cv=none; b=lXy2JGziAmiuuD4bsxTK+W7hEXN0tDCSQK6UHNdjPg9rFWhH03+lCSMSmecDFYxgCxeNwinuDGG66ckp8pv9IvfjnpY5uATj252tpQpQYrX754EQ0KkEmrUjm0U0zkesmlpX5ImP+9blYSV60s17mE1oU1sFwndhHsn7szKPAvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708986284; c=relaxed/simple; bh=zsiin/e9DCCAHFYVmvc8VlxYCJKmc7/so4tlT/LafQI=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=gPzuyRzWMW9a3SZIG8tMGMeEKHsd4xeMxfRmj4IqWVU3BDsWuXZc8flVY111Z7aSl3uUSGP4sfYcCfgtdCW0LTM//uzYA3nPKAaQjYnv9QZTxgUbhiOYcRZQ0vhEO49d9TFjFgsePXfPVcF+SSzNltRTjrwymwmXYK2OUYP/hhY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XyBM4C3x; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=L9Yf1rvE; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XyBM4C3x"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="L9Yf1rvE" Date: Mon, 26 Feb 2024 22:24:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708986281; 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=j6L7KZYYUOJiap7pCXaChkuCbO1qvcGQt3YWzNUKv4o=; b=XyBM4C3xF73HOVQvE/mYombPc7rQD/sYcHPKfDKP76nPkGAGIDZI50/UFtTMgPKZ+DQVt3 QDFIPUUDVeVqmQDTwZzj9GG4UkeYQw6HRw68MMqwg7CGMUsgzrxns92HbLL/BGwgGjx0rs vEL6opIXP/leQDV5DrI4qNLvwFQLriai7DGPjT3WSdX8P43vMcWw4HYyeSsuG8sYFZ6B1S HqXrsAHdqPRBZw4NGdBsi1mQ5HMw9YvtL4cSdFpLjlh4sQShaahiz+cZoPIyzlgzemHq2c njBVnrzxULbGpyVHhuNIoYu6d8vfjzOdvf8DNbKsm/71S1X9Bwm6ZwY8NqaZeg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708986281; 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=j6L7KZYYUOJiap7pCXaChkuCbO1qvcGQt3YWzNUKv4o=; b=L9Yf1rvEkjtzg7CB+jUNoy9iexNd2gBWZ83XZYOYmDKYfkz4Dug/ruS4jNyNP3wfTRBQ4J znzjGmUfgf0zjJBQ== From: "tip-bot2 for Peng Liu" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] tick/nohz: Remove duplicate between lowres and highres handlers Cc: Peng Liu , Frederic Weisbecker , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240225225508.11587-3-frederic@kernel.org> References: <20240225225508.11587-3-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170898628040.398.17292804624941572167.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/core branch of tip: Commit-ID: 37263ba0c44b13b2025398ac81919df9f0a91368 Gitweb: https://git.kernel.org/tip/37263ba0c44b13b2025398ac81919df9f= 0a91368 Author: Peng Liu AuthorDate: Sun, 25 Feb 2024 23:54:54 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 26 Feb 2024 11:37:31 +01:00 tick/nohz: Remove duplicate between lowres and highres handlers tick_nohz_lowres_handler() does the same work as tick_nohz_highres_handler() plus the clockevent device reprogramming, so make the former reuse the latter and rename it accordingly. Signed-off-by: Peng Liu Signed-off-by: Frederic Weisbecker Signed-off-by: Thomas Gleixner Reviewed-by: Thomas Gleixner Link: https://lore.kernel.org/r/20240225225508.11587-3-frederic@kernel.org --- kernel/time/tick-sched.c | 96 ++++++++++++++------------------------- 1 file changed, 36 insertions(+), 60 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index d490165..88c992f 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -255,6 +255,40 @@ static void tick_sched_handle(struct tick_sched *ts, s= truct pt_regs *regs) update_process_times(user_mode(regs)); profile_tick(CPU_PROFILING); } + +/* + * We rearm the timer until we get disabled by the idle code. + * Called with interrupts disabled. + */ +static enum hrtimer_restart tick_nohz_handler(struct hrtimer *timer) +{ + struct tick_sched *ts =3D container_of(timer, struct tick_sched, sched_ti= mer); + struct pt_regs *regs =3D get_irq_regs(); + ktime_t now =3D ktime_get(); + + tick_sched_do_timer(ts, now); + + /* + * Do not call when we are not in IRQ context and have + * no valid 'regs' pointer + */ + if (regs) + tick_sched_handle(ts, regs); + else + ts->next_tick =3D 0; + + /* + * In dynticks mode, tick reprogram is deferred: + * - to the idle task if in dynticks-idle + * - to IRQ exit if in full-dynticks. + */ + if (unlikely(ts->tick_stopped)) + return HRTIMER_NORESTART; + + hrtimer_forward(timer, now, TICK_NSEC); + + return HRTIMER_RESTART; +} #endif =20 #ifdef CONFIG_NO_HZ_FULL @@ -1429,31 +1463,15 @@ void tick_nohz_idle_exit(void) * at the clockevent level. hrtimer can't be used instead, because its * infrastructure actually relies on the tick itself as a backend in * low-resolution mode (see hrtimer_run_queues()). - * - * This low-resolution handler still makes use of some hrtimer APIs meanwh= ile - * for convenience with expiration calculation and forwarding. */ static void tick_nohz_lowres_handler(struct clock_event_device *dev) { struct tick_sched *ts =3D this_cpu_ptr(&tick_cpu_sched); - struct pt_regs *regs =3D get_irq_regs(); - ktime_t now =3D ktime_get(); =20 dev->next_event =3D KTIME_MAX; =20 - tick_sched_do_timer(ts, now); - tick_sched_handle(ts, regs); - - /* - * In dynticks mode, tick reprogram is deferred: - * - to the idle task if in dynticks-idle - * - to IRQ exit if in full-dynticks. - */ - if (likely(!ts->tick_stopped)) { - hrtimer_forward(&ts->sched_timer, now, TICK_NSEC); + if (likely(tick_nohz_handler(&ts->sched_timer) =3D=3D HRTIMER_RESTART)) tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1); - } - } =20 static inline void tick_nohz_activate(struct tick_sched *ts, int mode) @@ -1522,48 +1540,6 @@ void tick_irq_enter(void) tick_nohz_irq_enter(); } =20 -/* - * High resolution timer specific code - */ -#ifdef CONFIG_HIGH_RES_TIMERS -/* - * We rearm the timer until we get disabled by the idle code. - * Called with interrupts disabled. - */ -static enum hrtimer_restart tick_nohz_highres_handler(struct hrtimer *time= r) -{ - struct tick_sched *ts =3D - container_of(timer, struct tick_sched, sched_timer); - struct pt_regs *regs =3D get_irq_regs(); - ktime_t now =3D ktime_get(); - - tick_sched_do_timer(ts, now); - - /* - * Do not call when we are not in IRQ context and have - * no valid 'regs' pointer - */ - if (regs) - tick_sched_handle(ts, regs); - else - ts->next_tick =3D 0; - - /* - * In dynticks mode, tick reprogram is deferred: - * - to the idle task if in dynticks-idle - * - to IRQ exit if in full-dynticks. - */ - if (unlikely(ts->tick_stopped)) - return HRTIMER_NORESTART; - - hrtimer_forward(timer, now, TICK_NSEC); - - return HRTIMER_RESTART; -} -#else -#define tick_nohz_highres_handler NULL -#endif /* CONFIG_HIGH_RES_TIMERS */ - #if defined CONFIG_NO_HZ_COMMON || defined CONFIG_HIGH_RES_TIMERS static int sched_skew_tick; =20 @@ -1587,7 +1563,7 @@ void tick_setup_sched_timer(int mode) hrtimer_init(&ts->sched_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD); =20 if (IS_ENABLED(CONFIG_HIGH_RES_TIMERS) && mode =3D=3D NOHZ_MODE_HIGHRES) - ts->sched_timer.function =3D tick_nohz_highres_handler; + ts->sched_timer.function =3D tick_nohz_handler; =20 /* Get the next period (per-CPU) */ hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update());