public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Subhra Mazumdar <subhra.mazumdar@oracle.com>
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
Date: Tue, 18 Sep 2018 00:43:44 +0200	[thread overview]
Message-ID: <20180917224344.GB3284@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <304ffc06-1ab9-19d5-d5ca-e63e2abe2900@oracle.com>

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.

  reply	other threads:[~2018-09-17 22:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 20:24 [RFC PATCH 0/2] Pipe busy wait subhra mazumdar
2018-08-30 20:24 ` [RFC PATCH 1/2] pipe: introduce busy wait for pipe subhra mazumdar
2018-08-31 16:09   ` Steven Sistare
2018-09-05  0:50     ` Subhra Mazumdar
2018-09-05 13:45       ` Steven Sistare
2018-08-30 20:24 ` [RFC PATCH 2/2] pipe: use pipe busy wait subhra mazumdar
2018-09-04 21:54   ` Thomas Gleixner
2018-09-05  0:20     ` Subhra Mazumdar
2018-09-07 12:25   ` Peter Zijlstra
2018-09-17 21:05     ` Subhra Mazumdar
2018-09-17 22:43       ` Peter Zijlstra [this message]
2018-09-18  1:07         ` Subhra Mazumdar
2018-08-30 20:48 ` [RFC PATCH 0/2] Pipe " Subhra Mazumdar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180917224344.GB3284@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dhaval.giani@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=steven.sistare@oracle.com \
    --cc=subhra.mazumdar@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox