Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6904031ybp; Wed, 16 Oct 2019 00:20:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbfsAv92O2MC7vA6or0gTy61AS4J88hER91wlBljwygJeHszCSh8F6H5BsbvYVJRVTxT3e X-Received: by 2002:a05:6402:2d2:: with SMTP id b18mr37430420edx.264.1571210456301; Wed, 16 Oct 2019 00:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571210456; cv=none; d=google.com; s=arc-20160816; b=T6XbEExqwZLDY3O9yStp42IG8XUDHsbWpLtDs5OWo3x2d6GoS826KzqOAAEEYcV3VD mP5SPxYy+VNnWEqTc0UY3nRW8EavB+OD6WNqnbcrZYpiULH4hEeFdMKDuiaDVe+Dd4bZ LyuBot7LRkz6u2bN4h4+KYu0+bmvL1nCGRVf/pHlFesBMoXkFWFfpMnCaD38e6jCUqI7 QIUVaVQJzbQq4+uZx/PcH+2FldQVblT4xMkpXp8jOznucSRvXwtwsw2KHLoPnKQ6BvUE zIlMgPAtlV4o1hJqeyQ/f5S265KvBR5n/Z9SHmP1PxJkZDJK9t/gothP6T/JV7Fzx4Gt TXSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization; bh=tJrWoGqsLoOgjYvkpGjl5AA4ROHhC5aEHx/V2qeHsrI=; b=j3SMvvl5Wk1Gf6ZSCTheZA8O+lEhyRX8njRsjo/iRJFeahdGPt57422Ilwk1UTOPmf m1dnRFd7eaNIv0WbuPYq0mOzCzKZRFJN7goNVYAJi34DhECiw8DoPh2MoabYlaA1pqey vv0P1MWZcF7BXmzUq3q/0VQaOEXT+0xVNNWZttiwHi3Ib3v7T2ptPgEf9tbQ0OGIY1GP oa1B4etN4DKYYhOt1WHJIuleu7wfqGKSGMryLn40BD1pf7ClKaXQwf5GEe/aXqz32qVb jafnjaS52eUUqrHYokckYM3bo4wnz5QVWb9gmeDTMjeRRav2SP9rBRgdJU9vr2sb2O6N qHxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u30si16052037edl.366.2019.10.16.00.20.33; Wed, 16 Oct 2019 00:20:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731475AbfJOVsb (ORCPT + 99 others); Tue, 15 Oct 2019 17:48:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55734 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729725AbfJOVsa (ORCPT ); Tue, 15 Oct 2019 17:48:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9874118C427E; Tue, 15 Oct 2019 21:48:29 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-121-84.rdu2.redhat.com [10.10.121.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 056AF5D9E2; Tue, 15 Oct 2019 21:48:26 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [RFC PATCH 04/21] pipe: Advance tail pointer inside of wait spinlock in pipe_read() From: David Howells To: torvalds@linux-foundation.org Cc: dhowells@redhat.com, Casey Schaufler , Stephen Smalley , Greg Kroah-Hartman , nicolas.dichtel@6wind.com, raven@themaw.net, Christian Brauner , dhowells@redhat.com, keyrings@vger.kernel.org, linux-usb@vger.kernel.org, linux-block@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 15 Oct 2019 22:48:26 +0100 Message-ID: <157117610623.15019.10121494102947608380.stgit@warthog.procyon.org.uk> In-Reply-To: <157117606853.15019.15459271147790470307.stgit@warthog.procyon.org.uk> References: <157117606853.15019.15459271147790470307.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 15 Oct 2019 21:48:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Advance the pipe ring tail pointer inside of wait spinlock in pipe_read() so that the pipe can be written into with kernel notifications from contexts where pipe->mutex cannot be taken. Signed-off-by: David Howells --- fs/pipe.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/pipe.c b/fs/pipe.c index 0574277bad18..08af7e7bbea2 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -324,9 +324,14 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) if (!buf->len) { pipe_buf_release(pipe, buf); + spin_lock_irq(&pipe->wait.lock); tail++; pipe_commit_read(pipe, tail); - do_wakeup = 1; + do_wakeup = 0; + prelocked_wake_up_interruptible_sync_poll( + &pipe->wait, EPOLLOUT | EPOLLWRNORM); + spin_unlock_irq(&pipe->wait.lock); + kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); } total_len -= chars; if (!total_len) @@ -358,6 +363,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) if (do_wakeup) { wake_up_interruptible_sync_poll(&pipe->wait, EPOLLOUT | EPOLLWRNORM); kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); + do_wakeup = 0; } pipe_wait(pipe); }