From nobody Fri Dec 19 19:55:18 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6236C433FE for ; Sat, 22 Oct 2022 08:47:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234755AbiJVIrk (ORCPT ); Sat, 22 Oct 2022 04:47:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235219AbiJVIo4 (ORCPT ); Sat, 22 Oct 2022 04:44:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 439752C6372; Sat, 22 Oct 2022 01:08:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EFEC0B82E01; Sat, 22 Oct 2022 07:40:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F411C433D6; Sat, 22 Oct 2022 07:40:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424442; bh=4wnaODor8D624RR9nMhH13dQqwy3N+A65TEwwd7SL/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CH5b3lYW0om3R6s1de7VIsJjWvjmtdjrSpDBHnCfsFgMi7Y12ALW5yWFWDjbVD1SH yQWypXnWUzgHxJ0yfBTPSbQS9RjAU6NX2xNeUJTlrq9cQKARzc6giG931RGylWgJ6D cZLWwoyx6k4WRf4aFYOFJ91e/jzWwzsPF/IJU2Wo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Andrew Morton , "Steven Rostedt (Google)" Subject: [PATCH 5.19 148/717] tracing: Add ioctl() to force ring buffer waiters to wake up Date: Sat, 22 Oct 2022 09:20:27 +0200 Message-Id: <20221022072441.711031138@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Steven Rostedt (Google) commit 01b2a52171735c6eea80ee2f355f32bea6c41418 upstream. If a process is waiting on the ring buffer for data, there currently isn't a clean way to force it to wake up. Add an ioctl call that will force any tasks that are waiting on the trace_pipe_raw file to wake up. Link: https://lkml.kernel.org/r/20220929095029.117f913f@gandalf.local.home Cc: stable@vger.kernel.org Cc: Ingo Molnar Cc: Andrew Morton Fixes: e30f53aad2202 ("tracing: Do not busy wait in buffer splice") Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -8353,12 +8353,34 @@ out: return ret; } =20 +/* An ioctl call with cmd 0 to the ring buffer file will wake up all waite= rs */ +static long tracing_buffers_ioctl(struct file *file, unsigned int cmd, uns= igned long arg) +{ + struct ftrace_buffer_info *info =3D file->private_data; + struct trace_iterator *iter =3D &info->iter; + + if (cmd) + return -ENOIOCTLCMD; + + mutex_lock(&trace_types_lock); + + iter->wait_index++; + /* Make sure the waiters see the new wait_index */ + smp_wmb(); + + ring_buffer_wake_waiters(iter->array_buffer->buffer, iter->cpu_file); + + mutex_unlock(&trace_types_lock); + return 0; +} + static const struct file_operations tracing_buffers_fops =3D { .open =3D tracing_buffers_open, .read =3D tracing_buffers_read, .poll =3D tracing_buffers_poll, .release =3D tracing_buffers_release, .splice_read =3D tracing_buffers_splice_read, + .unlocked_ioctl =3D tracing_buffers_ioctl, .llseek =3D no_llseek, };