From patchwork Sat Oct 22 07:20:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1089731wrr; Sat, 22 Oct 2022 00:44:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Xd3xk5ozw/BFSioIeiSWqcqcDZP0mYybJGGL2VzPDIwWDfVJVFeT5TKQNA0v0Nv86Z9l+ X-Received: by 2002:a05:6a00:1a16:b0:56a:afb4:2b53 with SMTP id g22-20020a056a001a1600b0056aafb42b53mr6479602pfv.35.1666424656488; Sat, 22 Oct 2022 00:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424656; cv=none; d=google.com; s=arc-20160816; b=rv5cR4tomDgPz1/A29eu5a27ECMUbJ1E7lHxrMSgp5k9Xo/zhccHUAtxDY75AJO6kB 6hjVauQuQsrJxiuMFFvWj+bgCOO0Tw+PW3kp17qBkAm5tnMOu0yrl8ku3kgHtc5Pmnrh JtqNQbLCm8ZmSy7IwScCDyTOGQ1krJx48o3s6WCzcoIpgsX7qTZyz2vP7gsHFHehdCyK cTHFxzIDEs0vL8pjGVO1jfdWupeQG0QGVMjngx8E+IqQUTCQEl1sUNhLK88iFuVcl1q0 GkA84qAlZ6TzdYQqDIXhkvdKfwmlgfu10SYQiIIyGJUNdmOiuGHAE7WNDEzNOqKLH0kS 7Vlg== 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=EEjdHCiy3VT3zNZ9qREpPsxlzbLPsv/9VD9RXYm5H2w=; b=R7/uCupZUtIGdRfO/6gEgKRsGM2zVZeS0SZNLw4Ls1GgOQ33AyV8gPTXz9EbRI0VAo EycnWvjNtY96cHCHxSKo81vp+x4T95NgEzSF5pwzAH2PbXajNfSwcNXhhacexn4qSR+N o+oFEZzt/2XoHvi2LFg1U3xdLPO3K2wmu8yMU92EYqKwSsEsZxXIVNdE7HslHeHz0SlL e1NrptqIjHFNKS93X44MmmXf16nSTq0SMWzyuhEkvtafqk07Rtrh3Mupb4ZQk8i6t6rY G1IyxPPPsmb32N32+y5K9jhai50Nrqck4qpx7Y7S2jVcfcALeGHBgCiOPSTuNBqVdTNC s/VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cB1a8U7M; 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 pi16-20020a17090b1e5000b0020d47757829si2480036pjb.144.2022.10.22.00.44.04; Sat, 22 Oct 2022 00:44:16 -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=cB1a8U7M; 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 S231332AbiJVHnh (ORCPT + 99 others); Sat, 22 Oct 2022 03:43:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbiJVHm4 (ORCPT ); Sat, 22 Oct 2022 03:42:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22DC762A5A; Sat, 22 Oct 2022 00:41:50 -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 A79C7B82E05; Sat, 22 Oct 2022 07:40:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03D10C433D6; Sat, 22 Oct 2022 07:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424437; bh=mnc13TlevMeVJzlX+brpL19d8f7IuIS8B6nuN0+yHxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cB1a8U7M7XX6enPk8/IleCek8VX1HXiIVwe9OSj0O7iPi49PGpE/Cd3H68k1JyaEy 05kIV5PlsJth0tvSUaWZsFyxv51RSO9z5eXBEZUfYijHDTp4zKtjbCeXuASlITBuIS +U3F5dPBPLmYgCSc2Io8BRAXUfFt8Q4IseteRSE4= 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 146/717] tracing: Wake up ring buffer waiters on closing of the file Date: Sat, 22 Oct 2022 09:20:25 +0200 Message-Id: <20221022072441.334683004@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?1747372900917586433?= X-GMAIL-MSGID: =?utf-8?q?1747372900917586433?= From: Steven Rostedt (Google) commit f3ddb74ad0790030c9592229fb14d8c451f4e9a8 upstream. When the file that represents the ring buffer is closed, there may be waiters waiting on more input from the ring buffer. Call ring_buffer_wake_waiters() to wake up any waiters when the file is closed. Link: https://lkml.kernel.org/r/20220927231825.182416969@goodmis.org 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 --- include/linux/trace_events.h | 1 + kernel/trace/trace.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -92,6 +92,7 @@ struct trace_iterator { unsigned int temp_size; char *fmt; /* modified format holder */ unsigned int fmt_size; + long wait_index; /* trace_seq for __print_flags() and __print_symbolic() etc. */ struct trace_seq tmp_seq; --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -8160,6 +8160,12 @@ static int tracing_buffers_release(struc __trace_array_put(iter->tr); + 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); + if (info->spare) ring_buffer_free_read_page(iter->array_buffer->buffer, info->spare_cpu, info->spare); @@ -8313,6 +8319,8 @@ tracing_buffers_splice_read(struct file /* did we read anything? */ if (!spd.nr_pages) { + long wait_index; + if (ret) goto out; @@ -8320,10 +8328,17 @@ tracing_buffers_splice_read(struct file if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) goto out; + wait_index = READ_ONCE(iter->wait_index); + ret = wait_on_pipe(iter, iter->tr->buffer_percent); if (ret) goto out; + /* Make sure we see the new wait_index */ + smp_rmb(); + if (wait_index != iter->wait_index) + goto out; + goto again; }