All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Mike Galbraith <mgalbraith@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
	RT <linux-rt-users@vger.kernel.org>
Subject: [RFC][PATCH 2/3] cpupri: Remove vector locks and read entire loop
Date: Fri, 29 Jul 2011 11:13:42 -0400	[thread overview]
Message-ID: <20110729151954.908564429@goodmis.org> (raw)
In-Reply-To: 20110729151340.419467771@goodmis.org

[-- Attachment #1: sched-cpupri-nolock.patch --]
[-- Type: text/plain, Size: 2601 bytes --]

Index: linux-rt.git/kernel/sched_cpupri.c
===================================================================
--- linux-rt.git.orig/kernel/sched_cpupri.c
+++ linux-rt.git/kernel/sched_cpupri.c
@@ -122,8 +122,8 @@ static int convert_prio(int prio)
 	return cpupri;
 }
 
-#define for_each_cpupri_active(array, idx)                    \
-	for_each_set_bit(idx, array, CPUPRI_NR_PRIORITIES)
+#define for_each_cpupri_active(array, idx)		\
+	for(idx = 0; (idx) < MAX_RT_PRIO; (idx)++)
 
 /**
  * cpupri_find - find the best (lowest-pri) CPU in the system
@@ -153,6 +153,13 @@ int cpupri_find(struct cpupri *cp, struc
 		if (idx >= task_pri)
 			break;
 
+		/*
+		 * When a mask is updated, the new prio is set before
+		 * the old prio is cleared. This makes sure that we
+		 * don't miss this run queue.
+		 */
+		smp_rmb();
+
 		if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids)
 			continue;
 
@@ -193,7 +200,6 @@ void cpupri_set(struct cpupri *cp, int c
 {
 	int                 *currpri = &cp->cpu_to_pri[cpu];
 	int                  oldpri  = *currpri;
-	unsigned long        flags;
 
 	newpri = convert_prio(newpri);
 
@@ -213,26 +219,17 @@ void cpupri_set(struct cpupri *cp, int c
 	if (likely(newpri != CPUPRI_INVALID)) {
 		struct cpupri_vec *vec = &cp->pri_to_cpu[newpri];
 
-		raw_spin_lock_irqsave(&vec->lock, flags);
-
 		cpumask_set_cpu(cpu, vec->mask);
-		vec->count++;
-		if (vec->count == 1)
-			set_bit(newpri, cp->pri_active);
-
-		raw_spin_unlock_irqrestore(&vec->lock, flags);
 	}
+	/*
+	 * Set the new prio before clearing the old prio so we
+	 * don't miss this run queue during the loop.
+	 */
+	smp_wmb();
 	if (likely(oldpri != CPUPRI_INVALID)) {
 		struct cpupri_vec *vec  = &cp->pri_to_cpu[oldpri];
 
-		raw_spin_lock_irqsave(&vec->lock, flags);
-
-		vec->count--;
-		if (!vec->count)
-			clear_bit(oldpri, cp->pri_active);
 		cpumask_clear_cpu(cpu, vec->mask);
-
-		raw_spin_unlock_irqrestore(&vec->lock, flags);
 	}
 	cpupri_stop_vec();
 
@@ -255,7 +252,6 @@ int cpupri_init(struct cpupri *cp)
 	for (i = 0; i < CPUPRI_NR_PRIORITIES; i++) {
 		struct cpupri_vec *vec = &cp->pri_to_cpu[i];
 
-		raw_spin_lock_init(&vec->lock);
 		vec->count = 0;
 		if (!zalloc_cpumask_var(&vec->mask, GFP_KERNEL))
 			goto cleanup;
Index: linux-rt.git/kernel/sched_cpupri.h
===================================================================
--- linux-rt.git.orig/kernel/sched_cpupri.h
+++ linux-rt.git/kernel/sched_cpupri.h
@@ -12,7 +12,6 @@
 /* values 2-101 are RT priorities 0-99 */
 
 struct cpupri_vec {
-	raw_spinlock_t lock;
 	int        count;
 	cpumask_var_t mask;
 };


  parent reply	other threads:[~2011-07-29 15:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29 15:13 [RFC][PATCH 0/3] update to cpupri algorithm Steven Rostedt
2011-07-29 15:13 ` [RFC][PATCH 1/3] cpupri: Add profiling Steven Rostedt
2011-07-29 15:13 ` Steven Rostedt [this message]
2011-07-29 15:13 ` [RFC][PATCH 3/3] cpupri: Add atomic vector count to speed up loop Steven Rostedt
2011-07-29 15:38 ` [RFC][PATCH 0/3] update to cpupri algorithm Mike Galbraith
2011-07-29 18:24 ` Mike Galbraith
2011-07-30  7:12   ` Mike Galbraith
2011-07-30  8:16     ` Mike Galbraith
2011-07-30  9:19 ` Mike Galbraith
2011-08-01 14:18   ` Steven Rostedt
2011-08-01 18:41     ` Mike Galbraith
2011-08-01 18:54       ` Steven Rostedt
2011-08-01 19:06         ` Mike Galbraith
2011-08-02  8:59         ` Mike Galbraith
2011-08-02  8:46     ` Mike Galbraith

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=20110729151954.908564429@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mgalbraith@suse.de \
    --cc=peterz@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.