login
Header Space

 
 

Re: [PATCH] Replace completions with semaphores

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Matthew Wilcox <matthew@...>
Cc: Andi Kleen <andi@...>, Peter Zijlstra <peterz@...>, Bart Van Assche <bart.vanassche@...>, Roland Dreier <rdreier@...>, Ingo Molnar <mingo@...>, Ingo Oeser <ioe-lkml@...>, Daniel Walker <dwalker@...>, <linux-kernel@...>
Date: Tuesday, April 15, 2008 - 2:14 pm

On Tue, 15 Apr 2008, Matthew Wilcox wrote:

The origin of completions is literally the semaphore code - just 
simplified to use spinlocks and be usable as just a mutex. We used to use 
semaphores, and because of the subtle race with lockless semaphores I 
wrote that stupid completion code as a "generic semaphore with a very 
specific usage schenario" and called them "completions".

The completions _could_ have been extended/used as mutex semaphores, but 
the difference was really the mental model for them. That then limited the 
implementation of them: the functions working on completions are defined 
on purpose to be limited - it doesn't really have "up()" and "down()" 
functions: "complete()" is really a up(), but "wait_for_completion()" is 
more like a "wait_until_I_could_do_a_trydown()" function.

Would it make sense to use completions for countable events too? Yeah. In 
fact, we have some things that really would like to do counting, both in 
the sense of "wait for <n> events to all complete" _and_ in the sense of 
"allow up to <n> events to be outstanding". Both of which could be done as 
a counting function (just make "complete" increment the counter, and then 
make "wait for <n> events" initialize it to negative, while "allow <n>
outstanding events" would be a positive counter, and make 
"wait_for_completion()" basically be a "decrement and wait until it 
is zero".

IOW, completions() really follow the same patterns as semaphores, and it 
*does* make sense to just have one single code-base. But if we want to 
make semaphores go away, I think that it would be better to implement 
semaphores in terms of "extended completions" rather than the other way 
around. That way, we could one day really get rid of semaphores entirely.

		Linus
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Replace completions with semaphores, Matthew Wilcox, (Fri Apr 11, 5:00 pm)
Re: [PATCH] Replace completions with semaphores, Peter Zijlstra, (Sat Apr 12, 8:24 am)
Re: [PATCH] Replace completions with semaphores, Ingo Molnar, (Sun Apr 13, 3:05 am)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Sun Apr 13, 8:52 am)
Re: [PATCH] Replace completions with semaphores, Jens Axboe, (Mon Apr 14, 12:54 pm)
Re: [PATCH] Replace completions with semaphores, Ingo Molnar, (Mon Apr 14, 11:41 am)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Mon Apr 14, 1:46 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Sat Apr 12, 1:26 pm)
Re: [PATCH] Replace completions with semaphores, Roland Dreier, (Sat Apr 12, 3:53 pm)
Re: [PATCH] Replace completions with semaphores, Bart Van Assche, (Sun Apr 13, 9:55 am)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Sun Apr 13, 10:22 am)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Sat Apr 12, 4:47 pm)
Re: [PATCH] Replace completions with semaphores, Ingo Molnar, (Sun Apr 13, 3:08 am)
Re: [PATCH] Replace completions with semaphores, Bart Van Assche, (Sun Apr 13, 10:55 am)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Sun Apr 13, 8:57 am)
Re: [PATCH] Replace completions with semaphores, Ingo Molnar, (Mon Apr 14, 11:39 am)
Re: [PATCH] Replace completions with semaphores, Roland Dreier, (Mon Apr 14, 11:58 am)
Re: [PATCH] Replace completions with semaphores, Peter Zijlstra, (Mon Apr 14, 12:32 pm)
Re: [PATCH] Replace completions with semaphores, Andi Kleen, (Mon Apr 14, 1:46 pm)
Re: [PATCH] Replace completions with semaphores, Peter Zijlstra, (Mon Apr 14, 1:54 pm)
Re: [PATCH] Replace completions with semaphores, Alan Cox, (Mon Apr 14, 3:16 pm)
Re: [PATCH] Replace completions with semaphores, Andi Kleen, (Mon Apr 14, 3:16 pm)
Re: [PATCH] Replace completions with semaphores, Bart Van Assche, (Tue Apr 15, 2:18 am)
Re: [PATCH] Replace completions with semaphores, Peter Zijlstra, (Tue Apr 15, 2:46 am)
Re: [PATCH] Replace completions with semaphores, Bart Van Assche, (Tue Apr 15, 3:17 am)
Re: [PATCH] Replace completions with semaphores, Peter Zijlstra, (Tue Apr 15, 4:44 am)
Re: [PATCH] Replace completions with semaphores, Linus Torvalds, (Tue Apr 15, 12:09 pm)
Re: [PATCH] Replace completions with semaphores, Andi Kleen, (Tue Apr 15, 12:27 pm)
Re: [PATCH] Replace completions with semaphores, Linus Torvalds, (Tue Apr 15, 12:57 pm)
Re: [PATCH] Replace completions with semaphores, Andi Kleen, (Tue Apr 15, 1:15 pm)
Re: [PATCH] Replace completions with semaphores, Linus Torvalds, (Tue Apr 15, 1:26 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Tue Apr 15, 1:41 pm)
Re: [PATCH] Replace completions with semaphores, Linus Torvalds, (Tue Apr 15, 2:14 pm)
Re: [PATCH] Replace completions with semaphores, Ingo Oeser, (Wed Apr 16, 12:07 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Wed Apr 16, 12:16 pm)
Re: [PATCH] Replace completions with semaphores, Oliver Neukum, (Wed Apr 16, 12:31 pm)
Re: [PATCH] Replace completions with semaphores, Arjan van de Ven, (Wed Apr 16, 12:50 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Wed Apr 16, 12:58 pm)
Re: [PATCH] Replace completions with semaphores, Arjan van de Ven, (Wed Apr 16, 1:08 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Wed Apr 16, 2:10 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Wed Apr 16, 1:12 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Wed Apr 16, 12:34 pm)
Re: [PATCH] Replace completions with semaphores, Oliver Neukum, (Wed Apr 16, 12:42 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Wed Apr 16, 12:44 pm)
Re: [PATCH] Replace completions with semaphores, Roland Dreier, (Wed Apr 16, 12:47 pm)
Re: [PATCH] Replace completions with semaphores, Ingo Molnar, (Tue Apr 15, 1:05 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Tue Apr 15, 2:50 pm)
Re: [PATCH] Replace completions with semaphores, Ingo Molnar, (Wed Apr 16, 8:37 am)
Re: [PATCH] Replace completions with semaphores, Andi Kleen, (Wed Apr 16, 8:50 am)
Killable stat/readdir, Matthew Wilcox, (Wed Apr 16, 8:59 am)
Re: [PATCH] Replace completions with semaphores, Bart Van Assche, (Tue Apr 15, 9:15 am)
Re: [PATCH] Replace completions with semaphores, Daniel Walker, (Mon Apr 14, 2:09 pm)
Re: [PATCH] Replace completions with semaphores, Arjan van de Ven, (Mon Apr 14, 12:56 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Mon Apr 14, 1:50 pm)
Re: [PATCH] Replace completions with semaphores, Peter Zijlstra, (Sat Apr 12, 2:05 pm)
Re: [PATCH] Replace completions with semaphores, Matthew Wilcox, (Sat Apr 12, 3:04 pm)
Re: [PATCH] Replace completions with semaphores, Peter Zijlstra, (Sat Apr 12, 3:16 pm)
Re: [PATCH] Replace completions with semaphores, Daniel Walker, (Sat Apr 12, 2:01 pm)
Re: [PATCH] Replace completions with semaphores, Daniel Walker, (Sat Apr 12, 2:43 am)
Re: [PATCH] Replace completions with semaphores, Ingo Oeser, (Sat Apr 12, 6:31 am)
speck-geostationary