From patchwork Sat Oct 22 07:20:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1109437wrr; Sat, 22 Oct 2022 01:48:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM53p59i2Myqsh2LFEbhR1xDKLXrbzrPlwnSvHtHZUj10tXI2ONliGSWLhFauggb1Ks0pH5B X-Received: by 2002:a17:907:9625:b0:78d:bb06:9072 with SMTP id gb37-20020a170907962500b0078dbb069072mr19177363ejc.472.1666428512031; Sat, 22 Oct 2022 01:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428512; cv=none; d=google.com; s=arc-20160816; b=q/GzOngXn8sWCSPXwDxgacDbCgzKMqdLcWrR5sMXsQigbV6BnEMvg0qZ06MnGbD/Cx YLyGtxEBqyuL+HAiUuo5C28ujsVr332IzhS1C1XzEmKutZAZNtREulpTnr6OyUOr6Wht +CerWGjVyaaXuOHkZWpfbXrHjNzNSJrFy/zJ2J4/EcNR3DPlIp7dY7bTSfIvUejxMThr Zs7wne3e4e6ty8akmQjsssSfaYkjWtfPDv4K4/aj9uTdfExCoDl5wDRRU7u2AfzO2EXW dKR5KmoZ0uQM7SI8DlSS3g5trTUe+uw3bXkHjIHxy2u94hvSzjDxu/CoxHPrvLAIeOS8 3Lbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3LNgrQpDWQc9P23FLs/W3M4C7K+AnTH8yKu7xsG1MDA=; b=Q+bBlnuQArDC5WEw2aOfxEgoNBwxm0CkxwQYBy9IspqHm8i37V4XDKkzKPLdgqnIKK el5ExPXSzFD3PtdpkNX5NjvtHkv0Cby4++xTEsd6tvJq55DllSpSjWCeJLpZbd8DBw8r gXXMoyrjlIZrBtOEeZCaZUTgRcbg8zqGUgnCZPD8/X0FY8IFHn1QVbC1PWxltyleI1wB EDsRqL1FuysgwPL3ql7mWevxsSV0xzpwWd0mvjjR1pqSg1uNYm51cRpPxCQyGRO9GZz5 ssBMdWooTwxlwEeU1oQKBFpS5pcqw5NcEKC6sBm7LT4cYCR2ptOc7B9Gfr26Vt6Lf2Tk 38hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CH5b3lYW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b26-20020a05640202da00b004608c0b9a8asi6102879edx.201.2022.10.22.01.48.08; Sat, 22 Oct 2022 01:48:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CH5b3lYW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234406AbiJVIrk (ORCPT + 99 others); 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 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747376943337295726?= X-GMAIL-MSGID: =?utf-8?q?1747376943337295726?= 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; } +/* An ioctl call with cmd 0 to the ring buffer file will wake up all waiters */ +static long tracing_buffers_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct ftrace_buffer_info *info = file->private_data; + struct trace_iterator *iter = &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 = { .open = tracing_buffers_open, .read = tracing_buffers_read, .poll = tracing_buffers_poll, .release = tracing_buffers_release, .splice_read = tracing_buffers_splice_read, + .unlocked_ioctl = tracing_buffers_ioctl, .llseek = no_llseek, };