Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6200568rdb; Thu, 14 Dec 2023 10:55:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNLbwxC6/oyOf1kT08oKd02Wp7GkoCTNnMTwicECry3k/J/UScC4N20Vt2Y+If8XsYdlEA X-Received: by 2002:a17:903:185:b0:1d3:535e:c51 with SMTP id z5-20020a170903018500b001d3535e0c51mr1972153plg.99.1702580120004; Thu, 14 Dec 2023 10:55:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702580119; cv=none; d=google.com; s=arc-20160816; b=Xms/hiq2qwfYvddlj3DtVIUqxb+psJXsizFywOEcTE4R7czczoJfnBcnVwMXW1VC43 oeztwH2+R36de35dvkvVRIIuiurOe20l/kwtRnWW/OtpcOaUSl3KvJMueKwdmoxc0CLS FlDgbqwOaEORhzuMS5IQOtx72RBndd3c2aSj8KbWVi29CuD18abIMugzbosV2EC2PJGE AS43Jew2vuq7Pwk1jVbh0AUiKfq//nAHxC7g4TK+Q8fvP0hxFx+Vz/bsopOJ7VCfpfc5 iWYQJqSkpxneEIJyAL6jyPEwnJq5r9BiBuCRqSaZdd365pZTMf5ufE0yRkXSQiORU08h xBhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:content-disposition:mime-version :references:user-agent:message-id:subject:cc:from:date :dkim-signature; bh=FR9jV8jtjjMbaLdWDfdcNqy5/rmLgKsRGvcsO5TSkbc=; fh=XDFFka9cucso3iet729PgLkonFHnaQhQVE3vmOioU6Y=; b=O2GdaTHB9cYnuDY8eto+YwUEWgyORDKI9vOAmBCvhjccL9jV7Wz3z3nob45mxPVPo1 4bNnGa4TdcAZnaH+ATA+LwbpPVmlozd0yGCY5EG7Oqp9M9JB9xetZI48Oa/ea1qjWbFh W/LOBH4CVGgVl3kMtpBCpdQR0WWQTNUe2EHzrE54LqRWeeGrB6nlvZjPwHLrnY4Jnc87 MYQQTbFTtIhHAk5i3kglG8oLbNu6T5rHVW3NeqhQXCSTH4IwVDCI6zW2k8vI7g6COGV4 0r/NB+qeT1HwFoY3bRDx2g318r45RCa3CNf+ZiS/g1SmYaWvNGSdoir6kkAkhvhlWhav zZNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=BTeEgmOL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u10-20020a170902e80a00b001d05814624esi11756718plg.385.2023.12.14.10.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 10:55:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=BTeEgmOL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 8B92880ABFF0; Thu, 14 Dec 2023 10:45:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573318AbjLNSpE (ORCPT + 99 others); Thu, 14 Dec 2023 13:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573215AbjLNSo6 (ORCPT ); Thu, 14 Dec 2023 13:44:58 -0500 Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FB24181; Thu, 14 Dec 2023 10:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1702579502; bh=SQnZ6NeLN5oEGpHe+yCkGHc7k0RaveLdBbAl+Im5Zug=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=BTeEgmOLsL91Kw433qClTnDJFQz8R8M6u4NFFrKujJIk1CUqMqVi5/IjHOi7L7cN5 qIaQmBZtSgm54+iBkAC8FLSNuCrgRIxP/tISAapoptKj56OSsDWvAoP04NfcAk6qih ZWWNzOD6zF8wVMIoYq7pwrFQNvQiBNfLYaOaH4Z4ugpnU4GHp1GkiapRIckJ+he1vZ GN494qBV24nnxOWzJtnK/gAAF08dvGrfYOUrOn49j506w90SgcJv7h6kGgKMWsHOkh DbnrSk/YuQxaptyc2iZJ6x8efy8aDFTLr/rtJLIyHYFMra6Vd5/t8c9MvFLUdbwqDd 9ORzWWuoBw81w== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 3A9B813274; Thu, 14 Dec 2023 19:45:02 +0100 (CET) Date: Thu, 14 Dec 2023 19:45:02 +0100 From: Ahelenia =?utf-8?Q?Ziemia=C5=84ska?= Cc: Jens Axboe , Christian Brauner , Alexander Viro , linux-fsdevel@vger.kernel.org, Steven Rostedt , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH RERESEND 04/11] tracing: tracing_buffers_splice_read: behave as-if non-blocking I/O Message-ID: <21b84f2e4e5eaad501ff7b2bb03e2ad2f25ecdf14.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20231103 References: <2cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="g54druvikqn24p6f" Content-Disposition: inline In-Reply-To: <2cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Dec 2023 10:45:49 -0800 (PST) --g54druvikqn24p6f Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Otherwise we risk sleeping with the pipe locked for indeterminate lengths of time. Link: https://lore.kernel.org/linux-fsdevel/qk6hjuam54khlaikf2ssom6custxf5i= s2ekkaequf4hvode3ls@zgf7j5j4ubvw/t/#u Signed-off-by: Ahelenia Ziemia=C5=84ska --- kernel/trace/trace.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index abaaf516fcae..9be7a4c0a3ca 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -8477,7 +8477,6 @@ tracing_buffers_splice_read(struct file *file, loff_t= *ppos, if (splice_grow_spd(pipe, &spd)) return -ENOMEM; =20 - again: trace_access_lock(iter->cpu_file); entries =3D ring_buffer_entries_cpu(iter->array_buffer->buffer, iter->cpu= _file); =20 @@ -8528,35 +8527,12 @@ tracing_buffers_splice_read(struct file *file, loff= _t *ppos, =20 /* did we read anything? */ if (!spd.nr_pages) { - long wait_index; - - if (ret) - goto out; - - ret =3D -EAGAIN; - if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) - goto out; - - wait_index =3D READ_ONCE(iter->wait_index); - - ret =3D wait_on_pipe(iter, iter->tr->buffer_percent); - if (ret) - goto out; - - /* No need to wait after waking up when tracing is off */ - if (!tracer_tracing_is_on(iter->tr)) - goto out; - - /* Make sure we see the new wait_index */ - smp_rmb(); - if (wait_index !=3D iter->wait_index) - goto out; - - goto again; + if (!ret) + ret =3D -EAGAIN; + } else { + ret =3D splice_to_pipe(pipe, &spd); } =20 - ret =3D splice_to_pipe(pipe, &spd); -out: splice_shrink_spd(&spd); =20 return ret; --=20 2.39.2 --g54druvikqn24p6f Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmV7TS0ACgkQvP0LAY0m WPF63Q/+OAYOkFT+fQwGUZ1l3xQn7uXI1BvgJCTJYsy/ovPkqp60dJ2oSkrT4ZoR ngXaput2QYh+kRINn4r6NE4l3VTnIDbbDViXBdHjXvywCx7014GavLfUbVvSz5wZ GzwNIrUVszdIDv2na7L5Be+8C7R+5AlKDvtRiU9r6H5h2IIS0B3BBGkla/NNt5Z0 U/UPlFEytG0X/12K3eRt80AvXHYK27v0EWKuI0sDAN7D5qyLpKH1WBxFHG4QU+0p MTfamhiZFeT+6uqiqFhNR08WbMtvyqtQEoAvkuGO0zY8rGmX0HIuNqfOjtRVHKGx NJ98YLV4Ty+YEWnx14mcVy+dVWi651Jr45RbriaJq4/Ze+cikJsX5HaJt7vyUW1m R/apJo40OLyiDs7oXVubnQuoGA7EhceDkpyRZNjO/mh6FGrFV6RXjdB3LrkEgi2Y QIDhePbLp4a3Nstf/cS7Ribbd4PX/sGKzGANuRWu7cTF5PWYSyAHbuMO9VWkSfP5 G9Xl+8jucDJUdVYWn0DjUx1yJ0dAjCZCGswhxrzcVx0nyS7bxJDr0pGgN8OJHmiw tk8AJw9M8YuxW8zQ1cuH7z+8g1sf5jxclKWU/8nTxjmNBBGpAwABN5k55PKINqAL rKdiqHcaPLKf4ErWZ2VLwLY+TifuiOk3oty9+Xl2MDS5INYwUlM= =uzCr -----END PGP SIGNATURE----- --g54druvikqn24p6f--