Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2047944ybg; Sun, 27 Oct 2019 10:00:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwavRBzQEZwD90BxdxKYlZD9gC/Kdyu32vKRfoE9yB/mczVk1sjIJtSbCm6T4nq1Sz9qI0v X-Received: by 2002:a50:eb4d:: with SMTP id z13mr14950115edp.175.1572195625935; Sun, 27 Oct 2019 10:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572195625; cv=none; d=google.com; s=arc-20160816; b=ieIOrHIKuOBeTYtVyGybcdhqf6ef4iuAMH9N0QCRiGdd46AsEbzQT5GC9XVSzgQ/Vh uPjWIZufCB7XlPTumR1sAUrBN+RaGtXE+5ILGixx0bSPsmXbm3TxSXRAqY4vDa4WRfWp sN81HRqUeSc4g/hjt7aewSBKdZ4yKt9yF4t00tloDblw0si/oGyzphdssU7gQLlbEmLn 1AbS2at/h0G2eCI2f0PoxFlphoN4bbH043p5FMpS59mP3WOn1EvBjMY549wbC7Kn1B/n KX4KojVRUikwmLVXuaUKKa84EGY5uRBRWc5c4V37zJNcd9sjhLmt7BpxXywot6K3xyki FT3A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Rslfl7ijgIi+FGL5+iRdcB0DOAl315/Jt883QYZO0SY=; b=GPnKYPOU2hiXKJ2nK26D2uPv9MIb9TgwwAlPYJl9uWtd7WnpxGPW/5WywzBsAl2ATs xoVcpOWImcBrbpgp3X2mYrkQCqokJwzqUM/tP4fLxQ/ZUKGkaFf1xC70wUIRydtiGd2N vSO9t+QUS8Gn8KvJFMwMVD3I7zD394xLbnJQ/Q/yfWo7wSCuQB9EnmEO6tX2inEuUCfC aB3FqJJ3CLsdYgYfoupWhlI+YHYTfpgWyIy/bYnC/wWGVrjWOUqHwhiDq4rSfHUec+B6 eTCJBqO53MQPSBV3XZH0RSzp+DRMJ2JAw2oNvVdcMaEyuYTP6R8Xzar/RL4F6xrZx7Lv 8rTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=DYiuVW5e; 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=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si5509858edb.234.2019.10.27.10.00.01; Sun, 27 Oct 2019 10:00:25 -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=@yandex-team.ru header.s=default header.b=DYiuVW5e; 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=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727634AbfJ0P5p (ORCPT + 99 others); Sun, 27 Oct 2019 11:57:45 -0400 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:35088 "EHLO forwardcorp1o.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbfJ0P5p (ORCPT ); Sun, 27 Oct 2019 11:57:45 -0400 Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id A05BE2E14B0; Sun, 27 Oct 2019 18:57:37 +0300 (MSK) Received: from vla5-2bf13a090f43.qloud-c.yandex.net (vla5-2bf13a090f43.qloud-c.yandex.net [2a02:6b8:c18:3411:0:640:2bf1:3a09]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id jFZ2U9DQrz-valO9vDm; Sun, 27 Oct 2019 18:57:37 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1572191857; bh=Rslfl7ijgIi+FGL5+iRdcB0DOAl315/Jt883QYZO0SY=; h=In-Reply-To:Message-ID:From:Date:References:To:Subject:Cc; b=DYiuVW5ebbAfRNtlxJ2oHjbE5seAbUn105pej0Rq7+mthX/FkxsnMX/mSUR5Adjvc ji5Dfa/VV0Rtoo8n2z9MFxcqXGVV4q1Vqo6C8sXqDD19poeLJbfpqZcQDHmGN/K5rh 1TL61Q53FkqWYgaLVcYHVGNk1jNdZo4x0l6ZEjmc= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from unknown (unknown [2a02:6b8:b080:7710::1:0]) by vla5-2bf13a090f43.qloud-c.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2orbSKLdUT-vaV0HXU7; Sun, 27 Oct 2019 18:57:36 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: Re: [RFC PATCH 07/10] pipe: Conditionalise wakeup in pipe_read() [ver #2] To: David Howells , torvalds@linux-foundation.org Cc: Rasmus Villemoes , Greg Kroah-Hartman , Peter Zijlstra , nicolas.dichtel@6wind.com, raven@themaw.net, Christian Brauner , 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-kernel@vger.kernel.org References: <157186182463.3995.13922458878706311997.stgit@warthog.procyon.org.uk> <157186189069.3995.10292601951655075484.stgit@warthog.procyon.org.uk> From: Konstantin Khlebnikov Message-ID: Date: Sun, 27 Oct 2019 18:57:35 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <157186189069.3995.10292601951655075484.stgit@warthog.procyon.org.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-CA Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/10/2019 23.18, David Howells wrote: > Only do a wakeup in pipe_read() if we made space in a completely full > buffer. The producer shouldn't be waiting on pipe->wait otherwise. We could go further and wakeup writer only when at least half of buffer is empty. This gives better batching and reduces rate of context switches. https://lore.kernel.org/lkml/157219118016.7078.16223055699799396042.stgit@buzz/T/#u > > Signed-off-by: David Howells > --- > > fs/pipe.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) > > diff --git a/fs/pipe.c b/fs/pipe.c > index 1274305772fb..e3a8f10750c9 100644 > --- a/fs/pipe.c > +++ b/fs/pipe.c > @@ -327,11 +327,13 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) > spin_lock_irq(&pipe->wait.lock); > tail++; > pipe_commit_read(pipe, tail); > - do_wakeup = 0; > - wake_up_interruptible_sync_poll_locked( > - &pipe->wait, EPOLLOUT | EPOLLWRNORM); > + do_wakeup = 1; > + if (head - (tail - 1) == pipe->max_usage) > + wake_up_interruptible_sync_poll_locked( > + &pipe->wait, EPOLLOUT | EPOLLWRNORM); > spin_unlock_irq(&pipe->wait.lock); > - kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); > + if (head - (tail - 1) == pipe->max_usage) > + kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); > } > total_len -= chars; > if (!total_len) > @@ -360,11 +362,6 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) > ret = -ERESTARTSYS; > break; > } > - 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); > } > __pipe_unlock(pipe); > >