<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/kernel/smp.c, branch linux-6.5.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.5.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.5.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2023-11-28T17:14:41Z</updated>
<entry>
<title>smp,csd: Throw an error if a CSD lock is stuck for too long</title>
<updated>2023-11-28T17:14:41Z</updated>
<author>
<name>Rik van Riel</name>
</author>
<published>2023-08-21T20:04:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2ca04946b4eafec8d44f7d1679e3ed5b0827295d'/>
<id>urn:sha1:2ca04946b4eafec8d44f7d1679e3ed5b0827295d</id>
<content type='text'>
[ Upstream commit 94b3f0b5af2c7af69e3d6e0cdd9b0ea535f22186 ]

The CSD lock seems to get stuck in 2 "modes". When it gets stuck
temporarily, it usually gets released in a few seconds, and sometimes
up to one or two minutes.

If the CSD lock stays stuck for more than several minutes, it never
seems to get unstuck, and gradually more and more things in the system
end up also getting stuck.

In the latter case, we should just give up, so the system can dump out
a little more information about what went wrong, and, with panic_on_oops
and a kdump kernel loaded, dump a whole bunch more information about what
might have gone wrong.  In addition, there is an smp.panic_on_ipistall
kernel boot parameter that by default retains the old behavior, but when
set enables the panic after the CSD lock has been stuck for more than
the specified number of milliseconds, as in 300,000 for five minutes.

[ paulmck: Apply Imran Khan feedback. ]
[ paulmck: Apply Leonardo Bras feedback. ]

Link: https://lore.kernel.org/lkml/bc7cc8b0-f587-4451-8bcd-0daae627bcc7@paulmck-laptop/
Signed-off-by: Rik van Riel &lt;riel@surriel.com&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
Reviewed-by: Imran Khan &lt;imran.f.khan@oracle.com&gt;
Reviewed-by: Leonardo Bras &lt;leobras@redhat.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Valentin Schneider &lt;vschneid@redhat.com&gt;
Cc: Juergen Gross &lt;jgross@suse.com&gt;
Cc: Jonathan Corbet &lt;corbet@lwn.net&gt;
Cc: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>trace,smp: Add tracepoints for scheduling remotelly called functions</title>
<updated>2023-06-16T20:08:09Z</updated>
<author>
<name>Leonardo Bras</name>
</author>
<published>2023-06-15T06:59:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bf5a8c26ad7caf0772a1cd48c8a0924e48bdbaf0'/>
<id>urn:sha1:bf5a8c26ad7caf0772a1cd48c8a0924e48bdbaf0</id>
<content type='text'>
Add a tracepoint for when a CSD is queued to a remote CPU's
call_single_queue. This allows finding exactly which CPU queued a given CSD
when looking at a csd_function_{entry,exit} event, and also enables us to
accurately measure IPI delivery time with e.g. a synthetic event:

  $ echo 'hist:keys=cpu,csd.hex:ts=common_timestamp.usecs' &gt;\
      /sys/kernel/tracing/events/smp/csd_queue_cpu/trigger
  $ echo 'csd_latency unsigned int dst_cpu; unsigned long csd; u64 time' &gt;\
      /sys/kernel/tracing/synthetic_events
  $ echo \
  'hist:keys=common_cpu,csd.hex:'\
  'time=common_timestamp.usecs-$ts:'\
  'onmatch(smp.csd_queue_cpu).trace(csd_latency,common_cpu,csd,$time)' &gt;\
      /sys/kernel/tracing/events/smp/csd_function_entry/trigger

  $ trace-cmd record -e 'synthetic:csd_latency' hackbench
  $ trace-cmd report
  &lt;...&gt;-467   [001]    21.824263: csd_queue_cpu:        cpu=0 callsite=try_to_wake_up+0x2ea func=sched_ttwu_pending csd=0xffff8880076148b8
  &lt;...&gt;-467   [001]    21.824280: ipi_send_cpu:         cpu=0 callsite=try_to_wake_up+0x2ea callback=generic_smp_call_function_single_interrupt+0x0
  &lt;...&gt;-489   [000]    21.824299: csd_function_entry:   func=sched_ttwu_pending csd=0xffff8880076148b8
  &lt;...&gt;-489   [000]    21.824320: csd_latency:          dst_cpu=0, csd=18446612682193848504, time=36

Suggested-by: Valentin Schneider &lt;vschneid@redhat.com&gt;
Signed-off-by: Leonardo Bras &lt;leobras@redhat.com&gt;
Tested-and-reviewed-by: Valentin Schneider &lt;vschneid@redhat.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/r/20230615065944.188876-7-leobras@redhat.com
</content>
</entry>
<entry>
<title>trace,smp: Add tracepoints around remotelly called functions</title>
<updated>2023-06-16T20:08:09Z</updated>
<author>
<name>Leonardo Bras</name>
</author>
<published>2023-06-15T06:59:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=949fa3f11ced2a5c8e3737e73b09676adf4b322b'/>
<id>urn:sha1:949fa3f11ced2a5c8e3737e73b09676adf4b322b</id>
<content type='text'>
The recently added ipi_send_{cpu,cpumask} tracepoints allow finding sources
of IPIs targeting CPUs running latency-sensitive applications.

For NOHZ_FULL CPUs, all IPIs are interference, and those tracepoints are
sufficient to find them and work on getting rid of them. In some setups
however, not *all* IPIs are to be suppressed, but long-running IPI
callbacks can still be problematic.

Add a pair of tracepoints to mark the start and end of processing a CSD IPI
callback, similar to what exists for softirq, workqueue or timer callbacks.

Signed-off-by: Leonardo Bras &lt;leobras@redhat.com&gt;
Tested-and-reviewed-by: Valentin Schneider &lt;vschneid@redhat.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/r/20230615065944.188876-5-leobras@redhat.com
</content>
</entry>
<entry>
<title>cpu/hotplug: Mark arch_disable_smp_support() and bringup_nonboot_cpus() __init</title>
<updated>2023-05-15T11:44:47Z</updated>
<author>
<name>Thomas Gleixner</name>
</author>
<published>2023-05-12T21:07:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ba831b7b1a517ba7f25d6fa9736a8092d07b0c74'/>
<id>urn:sha1:ba831b7b1a517ba7f25d6fa9736a8092d07b0c74</id>
<content type='text'>
No point in keeping them around.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Tested-by: Michael Kelley &lt;mikelley@microsoft.com&gt;
Tested-by: Oleksandr Natalenko &lt;oleksandr@natalenko.name&gt;
Tested-by: Helge Deller &lt;deller@gmx.de&gt; # parisc
Tested-by: Guilherme G. Piccoli &lt;gpiccoli@igalia.com&gt; # Steam Deck
Link: https://lore.kernel.org/r/20230512205255.551974164@linutronix.de
</content>
</entry>
<entry>
<title>trace,smp: Trace all smp_function_call*() invocations</title>
<updated>2023-03-24T10:01:30Z</updated>
<author>
<name>Peter Zijlstra</name>
</author>
<published>2023-03-22T13:58:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5c3124975e15c1fadd5af1c61e4d627cf6d97ba2'/>
<id>urn:sha1:5c3124975e15c1fadd5af1c61e4d627cf6d97ba2</id>
<content type='text'>
(Ab)use the trace_ipi_send_cpu*() family to trace all
smp_function_call*() invocations, not only those that result in an
actual IPI.

The queued entries log their callback function while the actual IPIs
are traced on generic_smp_call_function_single_interrupt().

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
</content>
</entry>
<entry>
<title>trace: Add trace_ipi_send_cpu()</title>
<updated>2023-03-24T10:01:29Z</updated>
<author>
<name>Peter Zijlstra</name>
</author>
<published>2023-03-22T10:28:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=68e2d17c9eb311ab59aeb6d0c38aad8985fa2596'/>
<id>urn:sha1:68e2d17c9eb311ab59aeb6d0c38aad8985fa2596</id>
<content type='text'>
Because copying cpumasks around when targeting a single CPU is a bit
daft...

Tested-and-reviewed-by: Valentin Schneider &lt;vschneid@redhat.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20230322103004.GA571242%40hirez.programming.kicks-ass.net
</content>
</entry>
<entry>
<title>sched, smp: Trace smp callback causing an IPI</title>
<updated>2023-03-24T10:01:29Z</updated>
<author>
<name>Valentin Schneider</name>
</author>
<published>2023-03-07T14:35:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=68f4ff04dbada18dad79659c266a8e5e29e458cd'/>
<id>urn:sha1:68f4ff04dbada18dad79659c266a8e5e29e458cd</id>
<content type='text'>
Context
=======

The newly-introduced ipi_send_cpumask tracepoint has a "callback" parameter
which so far has only been fed with NULL.

While CSD_TYPE_SYNC/ASYNC and CSD_TYPE_IRQ_WORK share a similar backing
struct layout (meaning their callback func can be accessed without caring
about the actual CSD type), CSD_TYPE_TTWU doesn't even have a function
attached to its struct. This means we need to check the type of a CSD
before eventually dereferencing its associated callback.

This isn't as trivial as it sounds: the CSD type is stored in
__call_single_node.u_flags, which get cleared right before the callback is
executed via csd_unlock(). This implies checking the CSD type before it is
enqueued on the call_single_queue, as the target CPU's queue can be flushed
before we get to sending an IPI.

Furthermore, send_call_function_single_ipi() only has a CPU parameter, and
would need to have an additional argument to trickle down the invoked
function. This is somewhat silly, as the extra argument will always be
pushed down to the function even when nothing is being traced, which is
unnecessary overhead.

Changes
=======

send_call_function_single_ipi() is only used by smp.c, and is defined in
sched/core.c as it contains scheduler-specific ops (set_nr_if_polling() of
a CPU's idle task).

Split it into two parts: the scheduler bits remain in sched/core.c, and the
actual IPI emission is moved into smp.c. This lets us define an
__always_inline helper function that can take the related callback as
parameter without creating useless register pressure in the non-traced path
which only gains a (disabled) static branch.

Do the same thing for the multi IPI case.

Signed-off-by: Valentin Schneider &lt;vschneid@redhat.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/r/20230307143558.294354-8-vschneid@redhat.com
</content>
</entry>
<entry>
<title>smp: reword smp call IPI comment</title>
<updated>2023-03-24T10:01:28Z</updated>
<author>
<name>Valentin Schneider</name>
</author>
<published>2023-03-07T14:35:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=253a0fb4c62827cdcaf43afcea5d675507eaf7a3'/>
<id>urn:sha1:253a0fb4c62827cdcaf43afcea5d675507eaf7a3</id>
<content type='text'>
Accessing the call_single_queue hasn't involved a spinlock since 2014:

  6897fc22ea01 ("kernel: use lockless list for smp_call_function_single")

The llist operations (namely cmpxchg() and xchg()) provide similar ordering
guarantees, update the comment to lessen confusion.

Signed-off-by: Valentin Schneider &lt;vschneid@redhat.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/r/20230307143558.294354-7-vschneid@redhat.com
</content>
</entry>
<entry>
<title>smp: Trace IPIs sent via arch_send_call_function_ipi_mask()</title>
<updated>2023-03-24T10:01:27Z</updated>
<author>
<name>Valentin Schneider</name>
</author>
<published>2023-03-07T14:35:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=08407b5f61c1bbd4ebb26a76474df4354fd76fb7'/>
<id>urn:sha1:08407b5f61c1bbd4ebb26a76474df4354fd76fb7</id>
<content type='text'>
This simply wraps around the arch function and prepends it with a
tracepoint, similar to send_call_function_single_ipi().

Signed-off-by: Valentin Schneider &lt;vschneid@redhat.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
Link: https://lore.kernel.org/r/20230307143558.294354-4-vschneid@redhat.com
</content>
</entry>
<entry>
<title>sched, smp: Trace IPIs sent via send_call_function_single_ipi()</title>
<updated>2023-03-24T10:01:27Z</updated>
<author>
<name>Valentin Schneider</name>
</author>
<published>2023-03-07T14:35:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cc9cb0a71725aa8dd8d8f534a9b562bbf7981f75'/>
<id>urn:sha1:cc9cb0a71725aa8dd8d8f534a9b562bbf7981f75</id>
<content type='text'>
send_call_function_single_ipi() is the thing that sends IPIs at the bottom
of smp_call_function*() via either generic_exec_single() or
smp_call_function_many_cond(). Give it an IPI-related tracepoint.

Note that this ends up tracing any IPI sent via __smp_call_single_queue(),
which covers __ttwu_queue_wakelist() and irq_work_queue_on() "for free".

Signed-off-by: Valentin Schneider &lt;vschneid@redhat.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
Acked-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://lore.kernel.org/r/20230307143558.294354-3-vschneid@redhat.com
</content>
</entry>
</feed>
