Skip to contentSkip to conversation

increment nr_tasks in io_context when CLONE_IO is set

PATCH In review Nikanth Karthikesan 2 participants 3 messages Apr 15, 2008 – Apr 16, 2008 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 increment nr_tasks in io_context when CLONE_IO is set

Increment the nr_tasks associated with the io_context when CLONE_IO flag is set.

--

kernel/fork.c +1 -0
index dd249c3..01e843b 100644
@@ -812,6 +812,7 @@ static int copy_io(unsigned long clone_f
 		tsk->io_context = ioc_task_link(ioc);
 		if (unlikely(!tsk->io_context))
 			return -ENOMEM;
+		atomic_inc(&tsk->io_context->nr_tasks);
 	} else if (ioprio_valid(ioc->ioprio)) {
 		tsk->io_context = alloc_io_context(GFP_KERNEL, -1);
 		if (unlikely(!tsk->io_context))
#1 lore raw
Quoted 11 lines · Nikanth Karthikesan

Increment the nr_tasks associated with the io_context when CLONE_IO flag is set.

--

kernel/fork.c +0 -0
index dd249c3..01e843b 100644

kernel/fork.c static int copy_io(unsigned long clone_f · line 818

Quoted 7 lines
kernel/fork.c +1 -0
@@ -812,6 +812,7 @@ static int copy_io(unsigned long clone_f
 		tsk->io_context = ioc_task_link(ioc);
 		if (unlikely(!tsk->io_context))
 			return -ENOMEM;
+		atomic_inc(&tsk->io_context->nr_tasks);
 	} else if (ioprio_valid(ioc->ioprio)) {
 		tsk->io_context = alloc_io_context(GFP_KERNEL, -1);
 		if (unlikely(!tsk->io_context))

Fix is correct, however it would be more appropriate in ioc_task_link() instead.

include/linux/iocontext.h +3 -1
index cac4b36..2b7a118 100644
@@ -91,8 +91,10 @@ static inline struct io_context *ioc_task_link(struct io_context *ioc)
 	 * if ref count is zero, don't allow sharing (ioc is going away, it's
 	 * a race).
 	 */
-	if (ioc && atomic_inc_not_zero(&ioc->refcount))
+	if (ioc && atomic_inc_not_zero(&ioc->refcount)) {
+		atomic_inc(&ioc->nr_tasks);
 		return ioc;
+	}
 
 	return NULL;
 }
Signature · 1 line
Jens Axboe

A message that is not in the archive (sent off-list or not yet received): 4804A6CF.BANGALORE.BLR.100.174746A.1.15A79.1@1:7.BANGALORE.BLR.100.0.1.0.1@16

#3 lore raw
Quoted 6 lines · Jens Axboe
Quoted 5 lines · Nikanth Karthikesan

Increment the nr_tasks associated with the io_context when CLONE_IO flag is set.

Quoted 16 lines

kernel/fork.c static int copy_io(unsigned long clone_f · line 818

Quoted 13 lines

--

kernel/fork.c +1 -0
index dd249c3..01e843b 100644
@@ -812,6 +812,7 @@ static int copy_io(unsigned long clone_f
 		tsk->io_context = ioc_task_link(ioc);
 		if (unlikely(!tsk->io_context))
 			return -ENOMEM;
+		atomic_inc(&tsk->io_context->nr_tasks);
 	} else if (ioprio_valid(ioc->ioprio)) {
 		tsk->io_context = alloc_io_context(GFP_KERNEL, -1);
 		if (unlikely(!tsk->io_context))

Fix is correct, however it would be more appropriate in ioc_task_link() instead.

Yes. Thanks.

Quoted 18 lines
include/linux/iocontext.h +3 -1
index cac4b36..2b7a118 100644
@@ -91,8 +91,10 @@ static inline struct io_context *ioc_task_link(struct io_context *ioc)
 	 * if ref count is zero, don't allow sharing (ioc is going away, it's
 	 * a race).
 	 */
-	if (ioc && atomic_inc_not_zero(&ioc->refcount))
+	if (ioc && atomic_inc_not_zero(&ioc->refcount)) {
+		atomic_inc(&ioc->nr_tasks);
 		return ioc;
+	}
 
 	return NULL;
 }