linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] sys_ioprio_set: don't disable irqs
@ 2006-08-26 20:59 Oleg Nesterov
  2006-08-29  7:16 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2006-08-26 20:59 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Andrew Morton, linux-kernel

It is not good to disable interrupts while traversing all tasks in the system.
As I see it, sys_ioprio_get() doesn't need to do it at all, sys_ioprio_set()
does it for cfq_ioc_set_ioprio(), the latter can disable irqs itself.

Also, add a comment to explain why do we need tasklist_lock.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.18-rc4/block/cfq-iosched.c~5_setpr	2006-08-27 00:37:03.000000000 +0400
+++ 2.6.18-rc4/block/cfq-iosched.c	2006-08-27 00:38:57.000000000 +0400
@@ -1421,14 +1421,14 @@ static inline void changed_ioprio(struct
 }
 
 /*
- * callback from sys_ioprio_set, irqs are disabled
+ * callback from sys_ioprio_set.
  */
 static int cfq_ioc_set_ioprio(struct io_context *ioc, unsigned int ioprio)
 {
 	struct cfq_io_context *cic;
 	struct rb_node *n;
 
-	spin_lock(&cfq_exit_lock);
+	spin_lock_irq(&cfq_exit_lock);
 
 	n = rb_first(&ioc->cic_root);
 	while (n != NULL) {
@@ -1438,7 +1438,7 @@ static int cfq_ioc_set_ioprio(struct io_
 		n = rb_next(n);
 	}
 
-	spin_unlock(&cfq_exit_lock);
+	spin_unlock_irq(&cfq_exit_lock);
 
 	return 0;
 }
--- 2.6.18-rc4/fs/ioprio.c~5_setpr	2006-08-27 00:37:03.000000000 +0400
+++ 2.6.18-rc4/fs/ioprio.c	2006-08-27 00:54:17.000000000 +0400
@@ -81,7 +81,12 @@ asmlinkage long sys_ioprio_set(int which
 	}
 
 	ret = -ESRCH;
-	read_lock_irq(&tasklist_lock);
+	/*
+	 * We want IOPRIO_WHO_PGRP/IOPRIO_WHO_USER to be "atomic",
+	 * so we can't use rcu_read_lock(). See re-copy of ->ioprio
+	 * in copy_process().
+	 */
+	read_lock(&tasklist_lock);
 	switch (which) {
 		case IOPRIO_WHO_PROCESS:
 			if (!who)
@@ -124,7 +129,7 @@ free_uid:
 			ret = -EINVAL;
 	}
 
-	read_unlock_irq(&tasklist_lock);
+	read_unlock(&tasklist_lock);
 	return ret;
 }
 
@@ -170,7 +175,7 @@ asmlinkage long sys_ioprio_get(int which
 	int ret = -ESRCH;
 	int tmpio;
 
-	read_lock_irq(&tasklist_lock);
+	read_lock(&tasklist_lock);
 	switch (which) {
 		case IOPRIO_WHO_PROCESS:
 			if (!who)
@@ -221,7 +226,7 @@ asmlinkage long sys_ioprio_get(int which
 			ret = -EINVAL;
 	}
 
-	read_unlock_irq(&tasklist_lock);
+	read_unlock(&tasklist_lock);
 	return ret;
 }
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH RESEND] sys_ioprio_set: don't disable irqs
  2006-08-26 20:59 [PATCH RESEND] sys_ioprio_set: don't disable irqs Oleg Nesterov
@ 2006-08-29  7:16 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2006-08-29  7:16 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, linux-kernel

On Sun, Aug 27 2006, Oleg Nesterov wrote:
> It is not good to disable interrupts while traversing all tasks in the system.
> As I see it, sys_ioprio_get() doesn't need to do it at all, sys_ioprio_set()
> does it for cfq_ioc_set_ioprio(), the latter can disable irqs itself.
> 
> Also, add a comment to explain why do we need tasklist_lock.
> 
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

You should work against the 'block' branch in the block git repo, things
tend to change... I've applied your ioprio.c bit, the other one is not
needed anymore.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-08-29  7:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-26 20:59 [PATCH RESEND] sys_ioprio_set: don't disable irqs Oleg Nesterov
2006-08-29  7:16 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).