From patchwork Thu Dec 21 03:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 181955 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp156147dyi; Wed, 20 Dec 2023 19:10:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcj/c5Lwnga6BCP8vzOPKTadunVYYuzeK+Sm+21kQmC7Y8ccRiMmVJJZc6RkWkLh3DZRfY X-Received: by 2002:a05:6870:4d14:b0:204:245e:7612 with SMTP id pn20-20020a0568704d1400b00204245e7612mr972522oab.90.1703128210617; Wed, 20 Dec 2023 19:10:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703128210; cv=none; d=google.com; s=arc-20160816; b=XDUeMTXZOd3YZMYwLXfGjF25OZL/ueacYyMVI3jyZgEqAc42HvVR4/rbybFIPvgGLd spOTVom2qcP5LnLQH0xprT3qz8K6S51Td96BqKTvQsPf9uYoOtnDEbmmXm6i86z88c7f GvOr3JpRvgb1tL1XKyzAd2giduoFRMV2I5Wf90CKaicZHjydl2m06XUqDdwCwOPNlnEe LNY8ZQU0YuXelo57ot3Zrad5JeRnCTTpLPknN7+pXq8tSpBSUnvepxgLWu23fBqobjqg f9aZ/T9lxLgT/BKAaBE5mxx8QHdXG3KDN9+JNaLYPHro93oj1aio5gjuwVQQLOKqUAwV IZSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:from:date:dkim-signature; bh=lHelMyInKf7WfX7wQTfqF9xHr0eVHIk2emrhPum5PFA=; fh=J9tRb8oSmNAMPWMkgjMppEaYnvjrMor/cu2k4WOZ8/A=; b=f978z8eqjc5TXL+0xox3ij3GR8Yljj1XoQOq4t1Q+UKX7hLq8N3ay+6tGiAOatzQo4 VjXVFPSzDRiE98B1gKJd/v5ohEoNj32nzKMUYS/8pRlHgKgZXzB0FYnR7ZToB34I2o9O FF6oGgVYahhc1+uLpY+ZVG7s//LWJ9XKCBUnseNOM6NT9az2gmz3A8rU1FOl5202FB68 VuxuzGCpbg0y2sU3RRS7+yGBBySXdIxgYoiX8ygBbS/cyjHS+5rhkeSoHkqLlKiBmp9B C7vGGV+Qg4DrFZqwTAw3k/F41OwrLm/0PYsl8Whwzrl73JweMN9onTkrIG/Di4lvkgMt Dosg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=dSrYc8hG; spf=pass (google.com: domain of linux-kernel+bounces-7775-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7775-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y22-20020a637d16000000b005bd42f6085fsi781749pgc.344.2023.12.20.19.10.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 19:10:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7775-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=dSrYc8hG; spf=pass (google.com: domain of linux-kernel+bounces-7775-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7775-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1FF65286E81 for ; Thu, 21 Dec 2023 03:09:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF232BA4B; Thu, 21 Dec 2023 03:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="dSrYc8hG" X-Original-To: linux-kernel@vger.kernel.org Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03422AD4B; Thu, 21 Dec 2023 03:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nabijaczleweli.xyz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nabijaczleweli.xyz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1703128132; bh=eAEZKuHticwVYxrh9ppCMct1OB8vV2MAUTSowqzWAZ8=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=dSrYc8hG+4fSy0WFWd9aZsqSwDNE4gGjB3V5Qw1jR5c2AUkMmUdNDUVzE1Fe9+45G y//sDt54gWQYIvIR/B5mXHUKki0Ca2X4hMpymSj+1073lc8INhpYVQpbAw6bISFAOA 92s6NHFQw/rg3Prjt9JAsN4UgZf6L8ELbsPCO53JVe4cbsssKs19jqzNYtrLmOI6Hc y42k5X73W9gUZNZOMYA5rCn2UwZvfJvAolnMdhdAyYLek71D24c5TqS5XjvYCbUY0L cDXTpFHzEvxJVo9G7A7vG3DrM5zAaez2GiIKUUPOvnxXjMPSvVzAuaIG6jQvb+q2Oa H/aURzGp3PWaA== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 15D4F13DB0; Thu, 21 Dec 2023 04:08:52 +0100 (CET) Date: Thu, 21 Dec 2023 04:08:51 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Jens Axboe , Christian Brauner , Alexander Viro , linux-fsdevel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kuniyuki Iwashima , David Howells , Alexander Mikhalitsyn , John Fastabend , Daan De Meyer , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 02/11] af_unix: unix_stream_splice_read: always request MSG_DONTWAIT Message-ID: <8309aff7e55f0c7fe973bb2d1e6b6b3a80ac5a99.1703126594.git.nabijaczleweli@nabijaczleweli.xyz> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20231103-116-3b855e-dirty X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785859366410044150 X-GMAIL-MSGID: 1785859366410044150 Otherwise we risk sleeping with the pipe locked for indeterminate lengths of time ‒ given: cat > unix.c <<^D #define _GNU_SOURCE #include #include #include int main() { int sp[2]; socketpair(AF_UNIX, SOCK_STREAM, 0, sp); for (;;) splice(sp[0], 0, 1, 0, 128 * 1024 * 1024, 0); } ^D cc unix.c -o unix mkfifo fifo ./unix > fifo & read -r _ < fifo & sleep 0.1 echo zupa > fifo unix used to sleep in splice and the shell used to enter an uninterruptible sleep in open("fifo"); now the splice returns -EAGAIN and the whole program completes. Signed-off-by: Ahelenia Ziemiańska --- net/unix/af_unix.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index ac1f2bc18fc9..bae84552bf58 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -2921,15 +2921,12 @@ static ssize_t unix_stream_splice_read(struct socket *sock, loff_t *ppos, .pipe = pipe, .size = size, .splice_flags = flags, + .flags = MSG_DONTWAIT, }; if (unlikely(*ppos)) return -ESPIPE; - if (sock->file->f_flags & O_NONBLOCK || - flags & SPLICE_F_NONBLOCK) - state.flags = MSG_DONTWAIT; - return unix_stream_read_generic(&state, false); }