public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Dimitri Sivanich <sivanich@sgi.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] small optimization to update_curr_rt
Date: Mon, 03 Nov 2008 11:22:04 +0100	[thread overview]
Message-ID: <1225707724.7803.1612.camel@twins> (raw)
In-Reply-To: <20081031130341.GA12018@sgi.com>

On Fri, 2008-10-31 at 08:03 -0500, Dimitri Sivanich wrote:
> A very minor improvement, but might it be better to check sched_rt_runtime(rt_rq)
> before taking the rt_runtime_lock?

Yes, I think its ok to do so.

Like pointed out in the other thread, there are two races:

 - sched_rt_runtime() going to RUNTIME_INF, and that will be handled
   properly by sched_rt_runtime_exceeded()

 - sched_rt_runtime() going to !RUNTIME_INF, and here we can miss an
   accounting cycle, but I don't think that is something to worry too
   much about.

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

> Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
> 
> --
> 
>  kernel/sched_rt.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Index: linux/kernel/sched_rt.c
> ===================================================================
> --- linux.orig/kernel/sched_rt.c	2008-10-22 16:10:03.000000000 -0500
> +++ linux/kernel/sched_rt.c	2008-10-31 07:57:19.000000000 -0500
> @@ -537,13 +537,13 @@ static void update_curr_rt(struct rq *rq
>  	for_each_sched_rt_entity(rt_se) {
>  		rt_rq = rt_rq_of_se(rt_se);
>  
> -		spin_lock(&rt_rq->rt_runtime_lock);
>  		if (sched_rt_runtime(rt_rq) != RUNTIME_INF) {
> +			spin_lock(&rt_rq->rt_runtime_lock);
>  			rt_rq->rt_time += delta_exec;
>  			if (sched_rt_runtime_exceeded(rt_rq))
>  				resched_task(curr);
> +			spin_unlock(&rt_rq->rt_runtime_lock);
>  		}
> -		spin_unlock(&rt_rq->rt_runtime_lock);
>  	}
>  }
>  

  parent reply	other threads:[~2008-11-03 10:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-31 13:03 [PATCH] small optimization to update_curr_rt Dimitri Sivanich
2008-10-31 13:10 ` Steven Noonan
2008-10-31 13:46   ` Dimitri Sivanich
2008-11-03 10:22 ` Peter Zijlstra [this message]
2008-11-03 10:29   ` Ingo Molnar

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=1225707724.7803.1612.camel@twins \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sivanich@sgi.com \
    --cc=tglx@linutronix.de \
    /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