<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/time/timer.c, branch v6.8</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.8</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.8'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2023-12-20T15:49:39Z</updated>
<entry>
<title>timers: Fix nextevt calculation when no timers are pending</title>
<updated>2023-12-20T15:49:39Z</updated>
<author>
<name>Anna-Maria Behnsen</name>
<email>anna-maria@linutronix.de</email>
</author>
<published>2023-12-01T09:26:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=da65f29dada7f7cbbf0d6375b88a0316f5f7d6f5'/>
<id>urn:sha1:da65f29dada7f7cbbf0d6375b88a0316f5f7d6f5</id>
<content type='text'>
When no timer is queued into an empty timer base, the next_expiry will not
be updated. It was originally calculated as

  base-&gt;clk + NEXT_TIMER_MAX_DELTA

When the timer base stays empty long enough (&gt; NEXT_TIMER_MAX_DELTA), the
next_expiry value of the empty base suggests that there is a timer pending
soon. This might be more a kind of a theoretical problem, but the fix
doesn't hurt.

Use only base-&gt;next_expiry value as nextevt when timers are
pending. Otherwise nextevt will be jiffies + NEXT_TIMER_MAX_DELTA. As all
information is in place, update base-&gt;next_expiry value of the empty timer
base as well.

Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-13-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>timers: Rework idle logic</title>
<updated>2023-12-20T15:49:39Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2023-12-01T09:26:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bb8caad5083f8fbba70faf41f1d3bab7cf09da6d'/>
<id>urn:sha1:bb8caad5083f8fbba70faf41f1d3bab7cf09da6d</id>
<content type='text'>
To improve readability of the code, split base-&gt;idle calculation and
expires calculation into separate parts. While at it, update the comment
about timer base idle marking.

Thereby the following subtle change happens if the next event is just one
jiffy ahead and the tick was already stopped: Originally base-&gt;is_idle
remains true in this situation. Now base-&gt;is_idle turns to false. This may
spare an IPI if a timer is enqueued remotely to an idle CPU that is going
to tick on the next jiffy.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-12-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>timers: Use already existing function for forwarding timer base</title>
<updated>2023-12-20T15:49:38Z</updated>
<author>
<name>Anna-Maria Behnsen</name>
<email>anna-maria@linutronix.de</email>
</author>
<published>2023-12-01T09:26:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7a39a5080ef0e3cf233d92165f6a778f08a08244'/>
<id>urn:sha1:7a39a5080ef0e3cf233d92165f6a778f08a08244</id>
<content type='text'>
There is an already existing function for forwarding the timer
base. Forwarding the timer base is implemented directly in
get_next_timer_interrupt() as well.

Remove the code duplication and invoke __forward_timer_base() instead.

Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-11-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>timers: Split out forward timer base functionality</title>
<updated>2023-12-20T15:49:38Z</updated>
<author>
<name>Anna-Maria Behnsen</name>
<email>anna-maria@linutronix.de</email>
</author>
<published>2023-12-01T09:26:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1e490484aa3af42d4eeffabf96d6a02be69d586b'/>
<id>urn:sha1:1e490484aa3af42d4eeffabf96d6a02be69d586b</id>
<content type='text'>
Forwarding timer base is done when the next expiry value is calculated and
when a new timer is enqueued. When the next expiry value is calculated the
jiffies value is already available and does not need to be reread a second
time.

Splitting out the forward timer base functionality to make it executable
via both contextes - those where jiffies are already known and those, where
jiffies need to be read.

No functional change.

Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-10-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>timers: Clarify check in forward_timer_base()</title>
<updated>2023-12-20T15:49:38Z</updated>
<author>
<name>Anna-Maria Behnsen</name>
<email>anna-maria@linutronix.de</email>
</author>
<published>2023-12-01T09:26:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8a2c9c7e7848d7f63d38b698209148b5bb4ba7f3'/>
<id>urn:sha1:8a2c9c7e7848d7f63d38b698209148b5bb4ba7f3</id>
<content type='text'>
The current check whether a forward of the timer base is required can be
simplified by using an already existing comparison function which is easier
to read. The related comment is outdated and was not updated when the check
changed in commit 36cd28a4cdd0 ("timers: Lower base clock forwarding
threshold").

Use time_before_eq() for the check and replace the comment by copying the
comment from the same check inside get_next_timer_interrupt(). Move the
precious information of the outdated comment to the proper place in
__run_timers().

No functional change.

Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-9-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>timers: Move store of next event into __next_timer_interrupt()</title>
<updated>2023-12-20T15:49:38Z</updated>
<author>
<name>Anna-Maria Behnsen</name>
<email>anna-maria@linutronix.de</email>
</author>
<published>2023-12-01T09:26:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b5e6f59888c7bde3c05f61b3ce06b78a86713fc0'/>
<id>urn:sha1:b5e6f59888c7bde3c05f61b3ce06b78a86713fc0</id>
<content type='text'>
Both call sites of __next_timer_interrupt() store the return value directly
in base-&gt;next_expiry. Move the store into __next_timer_interrupt() and to
make its purpose more clear, rename the function to next_expiry_recalc().

No functional change.

Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-8-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>timers: Do not IPI for deferrable timers</title>
<updated>2023-12-20T15:49:38Z</updated>
<author>
<name>Anna-Maria Behnsen</name>
<email>anna-maria@linutronix.de</email>
</author>
<published>2023-12-01T09:26:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d124c3393e798b1fb142ee728d5c8976d11e722d'/>
<id>urn:sha1:d124c3393e798b1fb142ee728d5c8976d11e722d</id>
<content type='text'>
Deferrable timers do not prevent CPU from going idle and are not taken into
account on idle path. Sending an IPI to a remote CPU when a new first
deferrable timer was enqueued will wake up the remote CPU but nothing will
be done regarding the deferrable timers.

Drop IPI completely when a new first deferrable timer was enqueued.

Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-7-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>tracing/timers: Add tracepoint for tracking timer base is_idle flag</title>
<updated>2023-12-20T15:49:38Z</updated>
<author>
<name>Anna-Maria Behnsen</name>
<email>anna-maria@linutronix.de</email>
</author>
<published>2023-12-01T09:26:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b573c73101d8786446535b2ab28cbc8907bda9a9'/>
<id>urn:sha1:b573c73101d8786446535b2ab28cbc8907bda9a9</id>
<content type='text'>
When debugging timer code the timer tracepoints are very important. There
is no tracepoint when the is_idle flag of the timer base changes. Instead
of always adding manually trace_printk(), add tracepoints which can be
easily enabled whenever required.

Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-6-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>tracing/timers: Enhance timer_start tracepoint</title>
<updated>2023-12-20T15:49:38Z</updated>
<author>
<name>Anna-Maria Behnsen</name>
<email>anna-maria@linutronix.de</email>
</author>
<published>2023-12-01T09:26:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dbcdcb62b59db2cf6a24113873b90da15c6f0b19'/>
<id>urn:sha1:dbcdcb62b59db2cf6a24113873b90da15c6f0b19</id>
<content type='text'>
For starting a timer, the timer is enqueued into a bucket of the timer
wheel. The bucket expiry is the defacto expiry of the timer but it is not
equal the timer expiry because of increasing granularity when bucket is in
a higher level of the wheel. To be able to figure out in a trace whether a
timer expired in time or not, the bucket expiry time is required as well.

Add bucket expiry time to the timer_start tracepoint and thereby simplify
the arguments.

Signed-off-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Frederic Weisbecker &lt;frederic@kernel.org&gt;
Link: https://lore.kernel.org/r/20231201092654.34614-5-anna-maria@linutronix.de

</content>
</entry>
<entry>
<title>timers: Provide timer_shutdown[_sync]()</title>
<updated>2022-11-24T14:09:12Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2022-11-23T20:18:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f571faf6e443b6011ccb585d57866177af1f643c'/>
<id>urn:sha1:f571faf6e443b6011ccb585d57866177af1f643c</id>
<content type='text'>
Tearing down timers which have circular dependencies to other
functionality, e.g. workqueues, where the timer can schedule work and work
can arm timers, is not trivial.

In those cases it is desired to shutdown the timer in a way which prevents
rearming of the timer. The mechanism to do so is to set timer-&gt;function to
NULL and use this as an indicator for the timer arming functions to ignore
the (re)arm request.

Expose new interfaces for this: timer_shutdown_sync() and timer_shutdown().

timer_shutdown_sync() has the same functionality as timer_delete_sync()
plus the NULL-ification of the timer function.

timer_shutdown() has the same functionality as timer_delete() plus the
NULL-ification of the timer function.

In both cases the rearming of the timer is prevented by silently discarding
rearm attempts due to timer-&gt;function being NULL.

Co-developed-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Reviewed-by: Jacob Keller &lt;jacob.e.keller@intel.com&gt;
Reviewed-by: Anna-Maria Behnsen &lt;anna-maria@linutronix.de&gt;
Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home
Link: https://lore.kernel.org/all/20221110064101.429013735@goodmis.org
Link: https://lore.kernel.org/r/20221123201625.314230270@linutronix.de

</content>
</entry>
</feed>
