Re: [PATCH 01/45] Create a dynamically sized pool of threads for doing very slow work items [ver #41]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Howells <dhowells@xxxxxxxxxx> wrote:

> I guess I need to stick a comment in slow_work_enqueue() to detail this,
> though the comments in slow_work_execute() do talk about it.

How about this:

diff --git a/kernel/slow-work.c b/kernel/slow-work.c
index f638f36..adf9b78 100644
--- a/kernel/slow-work.c
+++ b/kernel/slow-work.c
@@ -195,12 +195,32 @@ int slow_work_enqueue(struct slow_work *work)
 	BUG_ON(!work->ops);
 	BUG_ON(!work->ops->get_ref);
 
+	/* when honouring an enqueue request, we only promise that we will run
+	 * the work function in the future; we do not promise to run it once
+	 * per enqueue request
+	 *
+	 * we use the PENDING bit to merge together repeat requests without
+	 * having to disable IRQs and take the spinlock, whilst still
+	 * maintaining our promise
+	 */
 	if (!test_and_set_bit_lock(SLOW_WORK_PENDING, &work->flags)) {
 		spin_lock_irqsave(&slow_work_queue_lock, flags);
 
+		/* we promise that we will not attempt to execute the work
+		 * function in more than one thread simultaneously
+		 *
+		 * this, however, leaves us with a problem if we're asked to
+		 * enqueue the work whilst someone is executing the work
+		 * function as simply queueing the work immediately means that
+		 * another thread may try executing it whilst it is already
+		 * under execution
+		 *
+		 * to deal with this, we set the ENQ_DEFERRED bit instead of
+		 * enqueueing, and the thread currently executing the work
+		 * function will enqueue the work item when the work function
+		 * returns and it has cleared the EXECUTING bit
+		 */
 		if (test_bit(SLOW_WORK_EXECUTING, &work->flags)) {
-			/* can't queue lest we cause multiple threads to try
-			 * executing this item, so defer for later */
 			set_bit(SLOW_WORK_ENQ_DEFERRED, &work->flags);
 		} else {
 			if (work->ops->get_ref(work) < 0)

David
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux