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 D86333A8FE1 for ; Tue, 24 Feb 2026 16:36:57 +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=1771951017; cv=none; b=n/729k+8URhoGYj1s14vDw+kgW9OzYugqxe1flNUd3JiIluZmOsYNjiVoTcu6VUJemDeXeuViUVcMWe55eTRY5pjhTyd+BZi0vsvzapx57e3JbgblBO/iARslKgKHgbzX3t30YmNLj5IZ0i5zrgPbQ03J8rJdJ6Qjd/NHarKP8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771951017; c=relaxed/simple; bh=KkoadQnbGFDGtRcIeCRYsYWiK7tvE9ULkPF+Bqym150=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=rVSbhR/CowL77SPpwycrUQq/idE1MZtBV1EAtS/CTWlaph72hrRoi+nHjZCmuPE5E9Epc3Aqi1BdnSJKDmIvjvwcH9qcgUP/cdbTzNDPXKpJTMvsCrAUjMLNLbQsZwRhAxbDSmlY4eA53no0Q/RHNpPRtVAP3vpjZJr5tfu+LLs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GEDn4vKR; 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="GEDn4vKR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30947C116D0; Tue, 24 Feb 2026 16:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771951017; bh=KkoadQnbGFDGtRcIeCRYsYWiK7tvE9ULkPF+Bqym150=; h=Date:From:To:Cc:Subject:References:From; b=GEDn4vKRJHVFadPyzoSj+X9rvauD7czsQhJda3i8fXNZDqvgHjBBlYKnjlpLkDz+Y xe+5OqxGtMVKNK60tbgKQxNRA7uD/ky92e3iEZeUDDurp4cmUuaUDJTOnT4tU+nGJr 6b//PD/7TEXOBPHuZvwKGfj8ULLk8V/Bo1qNPK9KLxV2/qbARTa2cfHRLQCHj46S5Z 27PnPJDXjYTB0hiEvH7/wpb483zVf1jVcusXkpIFlU2MqsEGfUQvJdeWPHgtfYtiKI c5ZfOjYUnzhph7MNXc/nTvkk42enSTDul0tlmXLoFnbhzWZEqK5KX1TNMLXBOR0/Wh N2nTZYu4npn7g== Date: Tue, 24 Feb 2026 17:36:54 +0100 Message-ID: <20260224163430.143098153@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 21/48] hrtimer: Add debug object init assertion 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 The debug object coverage in hrtimer_start_range_ns() happens too late to do anything useful. Implement the init assert assertion part and invoke that early in hrtimer_start_range_ns(). Signed-off-by: Thomas Gleixner --- kernel/time/hrtimer.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -441,12 +441,37 @@ static bool hrtimer_fixup_free(void *add } } +/* Stub timer callback for improperly used timers. */ +static enum hrtimer_restart stub_timer(struct hrtimer *unused) +{ + WARN_ON_ONCE(1); + return HRTIMER_NORESTART; +} + +/* + * hrtimer_fixup_assert_init is called when: + * - an untracked/uninit-ed object is found + */ +static bool hrtimer_fixup_assert_init(void *addr, enum debug_obj_state state) +{ + struct hrtimer *timer = addr; + + switch (state) { + case ODEBUG_STATE_NOTAVAILABLE: + hrtimer_setup(timer, stub_timer, CLOCK_MONOTONIC, 0); + return true; + default: + return false; + } +} + static const struct debug_obj_descr hrtimer_debug_descr = { - .name = "hrtimer", - .debug_hint = hrtimer_debug_hint, - .fixup_init = hrtimer_fixup_init, - .fixup_activate = hrtimer_fixup_activate, - .fixup_free = hrtimer_fixup_free, + .name = "hrtimer", + .debug_hint = hrtimer_debug_hint, + .fixup_init = hrtimer_fixup_init, + .fixup_activate = hrtimer_fixup_activate, + .fixup_free = hrtimer_fixup_free, + .fixup_assert_init = hrtimer_fixup_assert_init, }; static inline void debug_hrtimer_init(struct hrtimer *timer) @@ -470,6 +495,11 @@ static inline void debug_hrtimer_deactiv debug_object_deactivate(timer, &hrtimer_debug_descr); } +static inline void debug_hrtimer_assert_init(struct hrtimer *timer) +{ + debug_object_assert_init(timer, &hrtimer_debug_descr); +} + void destroy_hrtimer_on_stack(struct hrtimer *timer) { debug_object_free(timer, &hrtimer_debug_descr); @@ -483,6 +513,7 @@ static inline void debug_hrtimer_init_on static inline void debug_hrtimer_activate(struct hrtimer *timer, enum hrtimer_mode mode) { } static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { } +static inline void debug_hrtimer_assert_init(struct hrtimer *timer) { } #endif static inline void debug_setup(struct hrtimer *timer, clockid_t clockid, enum hrtimer_mode mode) @@ -1359,6 +1390,8 @@ void hrtimer_start_range_ns(struct hrtim struct hrtimer_clock_base *base; unsigned long flags; + debug_hrtimer_assert_init(timer); + /* * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard