From nobody Sat Feb 7 14:51:46 2026 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 1EF1C35CBCD for ; Tue, 27 Jan 2026 15:06:07 +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=1769526367; cv=none; b=rM/v9wRFSByT+WepBmi7lYwWbaladfLEQLpvaNvf2H9T8LWqY00/fxv/Rqr7Oo5fLpLqHLSuHv1XJTQ1mgnEEokcsi1OHRdIb31TZYArEVSSBZoUp27jXFODg+jckGlqMJ6ZGUlOkLAVN0Aho4KQxb36Z5HeDu53LZmtsDW9bxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769526367; c=relaxed/simple; bh=afAM7ZOA5SuRSLbL65crNSVL4m8qdt+XGZdZANRgrJw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=lzpx8GbTUN7EVLjaE5GD90rDMyC5wBl3ZxzMCxQs5+7951AczSR1J7n4YzPsmRXvtGF3gzcXLf/7ndleyTmu8o/sJHdVAuMFEB0YotI/k3s+470TV4shZRYs0Kk8h10beN0XS2tZkDnk43XotpgFMynjQiHJYmLpp4BxkdbwABY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VZYh7pYW; 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="VZYh7pYW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D610EC16AAE; Tue, 27 Jan 2026 15:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769526366; bh=afAM7ZOA5SuRSLbL65crNSVL4m8qdt+XGZdZANRgrJw=; h=Date:From:To:Cc:Subject:References:From; b=VZYh7pYWP4n0vNhxVKffcKkIUuU2DlumWn8pcajKg7Ljh3JQYCQzyZaFoVexWYLlK 1T/504ZeTXtkV2YIeet8RHFUkpEIcMw9KWs21czZxgOb3wX/8JTeJPqkLuF0weOgfj rQdp/mIUgX2B91mx7Ex5u++ngGH15np9qfhr3/DCCWDM31DBsHNdnMMU1oEfqd8bDf cvWpdmCn2PTh4bh3Vzd2uXwruYjQZZiNBHIj08VTWQQBeTKoLgx4PqnTg5BTEz7s2N e0BczQ8L47HloKAVDTZwdQ/Z3la4ufHCeqTdL+VVGyq4d6i0rYtVkVs9DFWx5DzwVt vQv3Z02r4OsJQ== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1vkkdw-00000000Le1-3Eiy; Tue, 27 Jan 2026 10:06:12 -0500 Message-ID: <20260127150612.623913531@kernel.org> User-Agent: quilt/0.68 Date: Tue, 27 Jan 2026 10:06:03 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Sebastian Andrzej Siewior , Clark Williams , Frederic Weisbecker , Petr Tesarik Subject: [for-next][PATCH 08/15] ring-buffer: Use a housekeeping CPU to wake up waiters References: <20260127150555.840066272@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Petr Tesarik Avoid running the wakeup irq_work on an isolated CPU. Since the wakeup can run on any CPU, let's pick a housekeeping CPU to do the job. This change reduces additional noise when tracing isolated CPUs. For example, the following ipi_send_cpu stack trace was captured with nohz_full=3D2 on the isolated CPU: -0 [002] d.h4. 1255.379293: ipi_send_cpu: cpu=3D2 ca= llsite=3Dirq_work_queue+0x2d/0x50 callback=3Drb_wake_up_waiters+0x0/0x80 -0 [002] d.h4. 1255.379329: =3D> trace_event_raw_event_ipi_send_cpu =3D> __irq_work_queue_local =3D> irq_work_queue =3D> ring_buffer_unlock_commit =3D> trace_buffer_unlock_commit_regs =3D> trace_event_buffer_commit =3D> trace_event_raw_event_x86_irq_vector =3D> __sysvec_apic_timer_interrupt =3D> sysvec_apic_timer_interrupt =3D> asm_sysvec_apic_timer_interrupt =3D> pv_native_safe_halt =3D> default_idle =3D> default_idle_call =3D> do_idle =3D> cpu_startup_entry =3D> start_secondary =3D> common_startup_64 The IRQ work interrupt alone adds considerable noise, but the impact can get even worse with PREEMPT_RT, because the IRQ work interrupt is then handled by a separate kernel thread. This requires a task switch and makes tracing useless for analyzing latency on an isolated CPU. After applying the patch, the trace is similar, but ipi_send_cpu always targets a non-isolated CPU. Unfortunately, irq_work_queue_on() is not NMI-safe. When running in NMI context, fall back to queuing the irq work on the local CPU. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Cc: Sebastian Andrzej Siewior Cc: Clark Williams Cc: Frederic Weisbecker Link: https://patch.msgid.link/20260108132132.2473515-1-ptesarik@suse.com Signed-off-by: Petr Tesarik Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ring_buffer.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 630221b00838..d33103408955 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -4,6 +4,7 @@ * * Copyright (C) 2008 Steven Rostedt */ +#include #include #include #include @@ -4013,19 +4014,36 @@ static void rb_commit(struct ring_buffer_per_cpu *c= pu_buffer) rb_end_commit(cpu_buffer); } =20 +static bool +rb_irq_work_queue(struct rb_irq_work *irq_work) +{ + int cpu; + + /* irq_work_queue_on() is not NMI-safe */ + if (unlikely(in_nmi())) + return irq_work_queue(&irq_work->work); + + /* + * If CPU isolation is not active, cpu is always the current + * CPU, and the following is equivallent to irq_work_queue(). + */ + cpu =3D housekeeping_any_cpu(HK_TYPE_KERNEL_NOISE); + return irq_work_queue_on(&irq_work->work, cpu); +} + static __always_inline void rb_wakeups(struct trace_buffer *buffer, struct ring_buffer_per_cpu *cpu_bu= ffer) { if (buffer->irq_work.waiters_pending) { buffer->irq_work.waiters_pending =3D false; /* irq_work_queue() supplies it's own memory barriers */ - irq_work_queue(&buffer->irq_work.work); + rb_irq_work_queue(&buffer->irq_work); } =20 if (cpu_buffer->irq_work.waiters_pending) { cpu_buffer->irq_work.waiters_pending =3D false; /* irq_work_queue() supplies it's own memory barriers */ - irq_work_queue(&cpu_buffer->irq_work.work); + rb_irq_work_queue(&cpu_buffer->irq_work); } =20 if (cpu_buffer->last_pages_touch =3D=3D local_read(&cpu_buffer->pages_tou= ched)) @@ -4045,7 +4063,7 @@ rb_wakeups(struct trace_buffer *buffer, struct ring_b= uffer_per_cpu *cpu_buffer) cpu_buffer->irq_work.wakeup_full =3D true; cpu_buffer->irq_work.full_waiters_pending =3D false; /* irq_work_queue() supplies it's own memory barriers */ - irq_work_queue(&cpu_buffer->irq_work.work); + rb_irq_work_queue(&cpu_buffer->irq_work); } =20 #ifdef CONFIG_RING_BUFFER_RECORD_RECURSION --=20 2.51.0