Skip to contentSkip to conversation

Reduce cpuset.c write_lock_irq() to read_lock()

PATCH In review Paul Menage 2 participants 2 messages May 24, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reduce cpuset.c write_lock_irq() to read_lock()

cpuset.c:update_nodemask() uses a write_lock_irq() on tasklist_lock to block concurrent forks; a read_lock() suffices and is less intrusive.

---
 kernel/cpuset.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/cpuset.c +3 -3
Index: scratch-2.6.22-rc1-mm1/kernel/cpuset.c
===================================================================
@@ -923,10 +923,10 @@ static int update_nodemask(struct cpuset
 		mmarray = kmalloc(ntasks * sizeof(*mmarray), GFP_KERNEL);
 		if (!mmarray)
 			goto done;
-		write_lock_irq(&tasklist_lock);		/* block fork */
+		read_lock(&tasklist_lock);		/* block fork */
 		if (atomic_read(&cs->count) <= ntasks)
 			break;				/* got enough */
-		write_unlock_irq(&tasklist_lock);	/* try again */
+		read_unlock(&tasklist_lock);	/* try again */
 		kfree(mmarray);
 	}
 
@@ -948,7 +948,7 @@ static int update_nodemask(struct cpuset
 			continue;
 		mmarray[n++] = mm;
 	} while_each_thread(g, p);
-	write_unlock_irq(&tasklist_lock);
+	read_unlock(&tasklist_lock);
 
 	/*
 	 * Now that we've dropped the tasklist spinlock, we can
#1 lore raw
Quoted 2 lines · Paul M

cpuset.c:update_nodemask() uses a write_lock_irq() on tasklist_lock to block concurrent forks; a read_lock() suffices and is less intrusive.

Seems reasonable to me - thanks.

kernel/cpuset.c static int update_nodemask(struct cpuset · line 929

Quoted 6 lines
kernel/cpuset.c +2 -2
-		write_lock_irq(&tasklist_lock);		/* block fork */
+		read_lock(&tasklist_lock);		/* block fork */
 		if (atomic_read(&cs->count) <= ntasks)
 			break;				/* got enough */
-		write_unlock_irq(&tasklist_lock);	/* try again */
+		read_unlock(&tasklist_lock);	/* try again */

Too bad you didn't keep the nicely aligned comments aligned ;).

Signature · 3 lines
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <[email protected]> 1.925.600.0401