Re: [PATCH] Replace completions with semaphores

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Roland Dreier
Date: Monday, April 14, 2008 - 8:58 am

> which ones exactly are these places that demand the use of a counting 
 > semaphore? I cannot think of a single place where it's the best choice, 
 > let alone one where it's the only choice.

Two of the places that use semaphores are drivers/infiniband/hw/mthca
and drivers/net/mlx4 -- in both cases, the device firmware allows up to
"N" outstanding firmware commands to be in flight, and the driver uses a
semaphore to handle issuing firmware commands.  That is, down() when we
want to issue a command, and up() when the firmware responds that the
command is complete.

What would you suggest as a better way to code this?  This is an honest
question -- there probably is a more elegant way to handle this
situation and I really would like to learn about it.

Also, the argument that removing semaphores makes the kernel as a whole
better does make sense to me; I wouldn't be opposed to basically
open-coding semaphores in terms of wait_event() in the driver or
something like that, but I wouldn't say that such an implementation is
locally more readable or maintainable if we look only at the driver
code.

 - R.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

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