From patchwork Wed Oct 19 08:24:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp206305wrs; Wed, 19 Oct 2022 01:52:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4y5s+uFDQ3jnDKUod+cadhfN6Jgbou8vc1LGFfN/Qun8FwvRoWNUwdbjLscTg/utXEYmsN X-Received: by 2002:a63:354e:0:b0:439:837:692f with SMTP id c75-20020a63354e000000b004390837692fmr6441324pga.74.1666169524605; Wed, 19 Oct 2022 01:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169524; cv=none; d=google.com; s=arc-20160816; b=PHMRGWZBSndjYsbBYxrcLEajJULdycESB4DLHiixfEyMVlxkiCqJeC2eWz4nyb5Rel xhTSsbYdG1aF+9o1Zmkh7VKuT/1jhtg7OHh/atkD7AFpuG02Ho2PuvInYFcAICoq/LJw VBXxhOBstJ77c4VMhiXH8tMu3ghU4lKFY/QmSCXol1WrnlO6Vp3Uz52c+7QmsAHTyG/L kJGGu1+d8L1Ag9lyLMueKhHN7TRbdlKbXT4M7AMdRwcGQPUoc5Jl58p9WmZmKgvaD46Q 8KiC4+MoUAnehqYmNAepXH4a5BpTr6oTD74EZVeYldhMv/VRTvE+alUaqSbsDWusDTnH 6ELA== 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=TkvMYKz8eAy03odsiHNg7eo9Mr1rNUM7ObXaB+Himjqc0uOr4c09ow3SO+w2vXeYSZ Cnql2U3DjupH8Rzv3K0NBhTC8esvvocp6JguRoabfLXr/o7FGMtfp/qHa6bBUkKmPANz sFezUkSzb9gXCtARDeGtRjlOzeUrQnaGLhUC5JSI7FpK8w3zjwQ1kI8opgnRohN0/g+0 LUajqp5k+xyBtQXH18owNDZH7DCguvE6ZSu62UlZdESMptmWevPSO5P3FsMHZ3InAhU4 0jXuKp8GWkSR8p8yV/qbmyr8FdSNDRIiwVswIfn5AR1Jhyxx8pqyV8/bUzj8Yf1k/A0j /DsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OIk9Lb39; 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 r30-20020a63fc5e000000b004600f27528fsi18000508pgk.175.2022.10.19.01.51.52; Wed, 19 Oct 2022 01:52:04 -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=OIk9Lb39; 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 S231689AbiJSIv2 (ORCPT + 99 others); Wed, 19 Oct 2022 04:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231727AbiJSItJ (ORCPT ); Wed, 19 Oct 2022 04:49:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA37E900DA; Wed, 19 Oct 2022 01:47:01 -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 dfw.source.kernel.org (Postfix) with ESMTPS id AA276617E1; Wed, 19 Oct 2022 08:46:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0C3CC433C1; Wed, 19 Oct 2022 08:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169213; bh=mnc13TlevMeVJzlX+brpL19d8f7IuIS8B6nuN0+yHxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIk9Lb39UTrjBUCt5lmb4moWUQklM9x/QXWdOxpPdI2KOfFMg7IVi5VLBAYbQXx+v R1CWBWGEUyt8G9fe7FK025U0GDZgi9wXH3pXiYync+Sy4wOAOYMvJXyxnpuZAb3jJW LMMkRkTXBcOOv3h5x14ibz1Uw+omwUGqXUP/pKDc= 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 6.0 159/862] tracing: Wake up ring buffer waiters on closing of the file Date: Wed, 19 Oct 2022 10:24:06 +0200 Message-Id: <20221019083256.997469669@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747105375108334630?= X-GMAIL-MSGID: =?utf-8?q?1747105375108334630?= 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; }