Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4519886imm; Mon, 17 Sep 2018 15:44:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbWtVPazYKGAQ9l+uQHh4RZpK6Ohl+3SK8hHL+y4akPk3KgGyuOWhGsQChxEuV/Trg9tSnL X-Received: by 2002:a62:938e:: with SMTP id r14-v6mr28396758pfk.55.1537224261576; Mon, 17 Sep 2018 15:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537224261; cv=none; d=google.com; s=arc-20160816; b=aLfh0S9aClugC55KVeU+Yks6wPiFeDJ/M/GdZS+WBSdnkRf/36f0FY/2+5mXgCI/x6 2yZ+P0fm/cnuFaekttvKgfwSPVIx7Lq4/6RyMp56vkzc8nIvYJLem+9MWulWiT8yBpky HVYbpAa46NJL62A2rIqTzHiDAsPtk9l4HPiZSo6NAq0LwN3c4A6DGYlunF5qN60Svdzi cWYO4PUJYoTRs/mPK7x+IhSpNu/Q8t/qJmfHJhZlttxIxWJR6UaYR30bngM3wRVJLGaB JVHg0j2g9MXGQazClWn7dGuvL6G2zAE+bCcGf7RIomPC/+iSUNHNXISKNMPhrZi16upT XjNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Kj+du2oOrmctzDfUxB2Dz8cDyOdqlIK2iSNcj1sQfaY=; b=kahNd+oU1toazf0CdcsEEBxDvjbDx3cE0S3rSPDvQfbv4zBKcTXaN+0nSpnmI9D6Lj KpwZpo9IJQzIcqt7ktXIxgJL3t3mA7aDilQakJm6jbMitzfv1rlysr1ZMNm6aJPdyZOz DxQCPrCUgsPNV65wbYoexj7tB00WXTnczgs7QW+ov8Y+skQjVGcUjjLgzv/8ZUgtmr9D Z+uVvbkgvUFr6xtpzzsVJTMZeTOr+tyuEXY87IIO9h6dTaa1R4Uv+G0zEjsFsofWInis lwPXZYMjZBp/LxNnpkpFfxAWEZAwqgShJfP5BxLWK1L8AowoGCw4bet9jeJATpb0uqkY l08g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZZXOqQlB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k20-v6si16432181pgb.115.2018.09.17.15.44.06; Mon, 17 Sep 2018 15:44:21 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZZXOqQlB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728671AbeIRENL (ORCPT + 99 others); Tue, 18 Sep 2018 00:13:11 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45384 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725772AbeIRENL (ORCPT ); Tue, 18 Sep 2018 00:13:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Kj+du2oOrmctzDfUxB2Dz8cDyOdqlIK2iSNcj1sQfaY=; b=ZZXOqQlByk9Kd66+aigX4S/7E 5FNOXcfPUPaa4YlR6zn+WOSt/pz6M2kiNEdfkHUBzsgztAGSC8nwfDhleOg73aPMQffDrebb66j/U PwRD0OCjT+zFvukxfLqLmT/OQoLrYpyB1ZMfFSdM1ojvt8D/qp480CNm9znY1LNU405Skn8qlMSfQ +v4wiTKGpBjopGkLCTPHZTa5wksUYOx5BLc5Y5G0JAJY1h4Vm9as/zhs51GMFgLptT5JcqRzRck3i rA3yqAuMUMf6JXIf2lnmY7dbHMYtOgVtnRFN4aaG2lPHVEd9Xbf2WH0SAtpSh69HkXJ4OU1kFU7gy 3tbCC86kQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g22F9-0005go-RY; Mon, 17 Sep 2018 22:43:48 +0000 Received: by worktop (Postfix, from userid 1000) id 8E2A86E0A92; Tue, 18 Sep 2018 00:43:44 +0200 (CEST) Date: Tue, 18 Sep 2018 00:43:44 +0200 From: Peter Zijlstra To: Subhra Mazumdar Cc: linux-kernel@vger.kernel.org, dhaval.giani@oracle.com, steven.sistare@oracle.com Subject: Re: [RFC PATCH 2/2] pipe: use pipe busy wait Message-ID: <20180917224344.GB3284@worktop.programming.kicks-ass.net> References: <20180830202458.32579-1-subhra.mazumdar@oracle.com> <20180830202458.32579-3-subhra.mazumdar@oracle.com> <20180907122557.GY24106@hirez.programming.kicks-ass.net> <304ffc06-1ab9-19d5-d5ca-e63e2abe2900@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <304ffc06-1ab9-19d5-d5ca-e63e2abe2900@oracle.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 17, 2018 at 02:05:40PM -0700, Subhra Mazumdar wrote: > On 09/07/2018 05:25 AM, Peter Zijlstra wrote: > >Why not just busy wait on current->state ? A little something like: > > > >diff --git a/fs/pipe.c b/fs/pipe.c > >index bdc5d3c0977d..8d9f1c95ff99 100644 > >--- a/fs/pipe.c > >+++ b/fs/pipe.c > >@@ -106,6 +106,7 @@ void pipe_double_lock(struct pipe_inode_info *pipe1, > > void pipe_wait(struct pipe_inode_info *pipe) > > { > > DEFINE_WAIT(wait); > >+ u64 start; > > /* > > * Pipes are system-local resources, so sleeping on them > >@@ -113,7 +114,15 @@ void pipe_wait(struct pipe_inode_info *pipe) > > */ > > prepare_to_wait(&pipe->wait, &wait, TASK_INTERRUPTIBLE); > > pipe_unlock(pipe); > >- schedule(); > >+ > >+ preempt_disable(); > >+ start = local_clock(); > >+ while (!need_resched() && current->state != TASK_RUNNING && > >+ (local_clock() - start) < pipe->poll_usec) > >+ cpu_relax(); > >+ schedule_preempt_disabled(); > >+ preempt_enable(); > >+ > > finish_wait(&pipe->wait, &wait); > > pipe_lock(pipe); > > } > This will make the current thread always spin and block as it itself does > the state change to TASK_RUNNING in finish_wait. Nah, the actual wakeup will also do that state change. The one in finish_wait() is for the case where the wait condition became true without wakeup, such that we don't 'leak' the INTERRUPTIBLE state.