Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2263283ybg; Thu, 24 Oct 2019 07:17:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8a6ElK3hIdiJatL8C1fmKgFy0cmpPkp/hZKVCpS79IRzRcPcfVoUHvvWQIfpfNAQcT/T8 X-Received: by 2002:a05:6402:1686:: with SMTP id a6mr43913243edv.174.1571926623225; Thu, 24 Oct 2019 07:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571926623; cv=none; d=google.com; s=arc-20160816; b=um02qEOVavBpelcJqbDtZwg9C9QBMZLh05G+8K1OACd7xlhXL3pNvhO0MKcTHseXFE lKrYrzMS/v70FA/KHqy75njTmKNfJA40yYRChYH6fxynkL6FPJb2Cflb7qzy+J/1YIl6 BqTm6u4THawYkBVG63SqPUaxsA50vlVfEryiJjMZGQXYCUsZYqVeOXRx0eKD61DkazsY 5udpJ0OQZjxDsZK+FPXxL4/E66HLrVdPnPidSSTcODkmSzVGxFhttE/9HTuN/+zkA+Mg R8KsWnFSkx1lsTX9tWz+STKU0Xkx1RBw+ZWr709xz+hsGzRhP3SieqBNMLLnCDxT7XC2 Hldg== 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:dkim-signature; bh=PTa8/R0oI/33uh7QoOdTHDItHL1AUlg5WLx25CuXu0w=; b=yNkwSlgGr1iLldQoKnUi8+gZhy/U58IGXXqcP/RMx6Q6yv1/RkcAycptqaNgBcz2CQ xTDE/bJlPb44RkTANIx/G9klbXYcSEd+TH+jfIGykLskWoAjpf+mn25CKlrCt6CbN8Lm 6aG7wO1FIRhVyicI9pl/EZIUVA1ADWi+vdrBtB/SmjhDeZir2CwhHACjX246CgSVe0TW Smk+OSK3tymtWlCu4qNmsa69U8M3CqumB5sPNsgW8HU2R/0wBNT9cn27CI8WdVPQbVYi BWWdAfu6YRSwPn/KNzwAq9E+HTOogXiqkUQGhKMMMi6arAcKqTh1sXrMk5kjmlQtqNjC triA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M4erFpeG; 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=pass (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 va9si15314931ejb.126.2019.10.24.07.16.37; Thu, 24 Oct 2019 07:17:03 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M4erFpeG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407421AbfJWUSN (ORCPT + 99 others); Wed, 23 Oct 2019 16:18:13 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54166 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2406052AbfJWUSM (ORCPT ); Wed, 23 Oct 2019 16:18:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571861890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PTa8/R0oI/33uh7QoOdTHDItHL1AUlg5WLx25CuXu0w=; b=M4erFpeGVQh97cMmgKy7wsyesEd+/qi+0bmhQyscWr2rzz6QA1/YmZeC2QDoBTB1ON2I5F 7SNEBDFHLFt65Ry/4ew8YGuZ+T3XaUlPHq1HCYvvuk9twGcG29KALwnl3Kot1y4HUv9wgd c3uenV0OMbxjLL1vZcnZR2CUVUhFEKI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-342-Z1qnm_rTOfe_DMgLiIc_Rg-1; Wed, 23 Oct 2019 16:18:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 739BE80183D; Wed, 23 Oct 2019 20:18:05 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-121-40.rdu2.redhat.com [10.10.121.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0BC760BF1; Wed, 23 Oct 2019 20:18:02 +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 06/10] pipe: Advance tail pointer inside of wait spinlock in pipe_read() [ver #2] From: David Howells To: torvalds@linux-foundation.org Cc: dhowells@redhat.com, Rasmus Villemoes , Greg Kroah-Hartman , Peter Zijlstra , 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: Wed, 23 Oct 2019 21:18:02 +0100 Message-ID: <157186188205.3995.4257625973468561091.stgit@warthog.procyon.org.uk> In-Reply-To: <157186182463.3995.13922458878706311997.stgit@warthog.procyon.org.uk> References: <157186182463.3995.13922458878706311997.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: Z1qnm_rTOfe_DMgLiIc_Rg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 12e47cae9425..1274305772fb 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -324,9 +324,14 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) =20 =09=09=09if (!buf->len) { =09=09=09=09pipe_buf_release(pipe, buf); +=09=09=09=09spin_lock_irq(&pipe->wait.lock); =09=09=09=09tail++; =09=09=09=09pipe_commit_read(pipe, tail); -=09=09=09=09do_wakeup =3D 1; +=09=09=09=09do_wakeup =3D 0; +=09=09=09=09wake_up_interruptible_sync_poll_locked( +=09=09=09=09=09&pipe->wait, EPOLLOUT | EPOLLWRNORM); +=09=09=09=09spin_unlock_irq(&pipe->wait.lock); +=09=09=09=09kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); =09=09=09} =09=09=09total_len -=3D chars; =09=09=09if (!total_len) @@ -358,6 +363,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) =09=09if (do_wakeup) { =09=09=09wake_up_interruptible_sync_poll(&pipe->wait, EPOLLOUT | EPOLLWRNO= RM); =09=09=09kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); +=09=09=09do_wakeup =3D 0; =09=09} =09=09pipe_wait(pipe); =09}