On Fri, Mar 28, 2008 at 11:01:24AM +1100, Nick Piggin wrote:Ah, I see what you're saying. The deadlock would be (on a single CPU machine), task A holding the semaphore, being preempted, task B taking a spinlock (thus non-preemptable), then calling down_spin() which will never succeed. That hadn't occurred to me -- I'm not used to thinking about preemption. I considered interrupt context and saw how that would deadlock, so just put a note in the documentation that it wasn't usable from interrupts. So it makes little sense to add this to semaphores. Better to introduce a spinaphore, as you say. I think we can do better here with: atomic_set(max); and while (unlikely(!atomic_add_unless(&ss->cur, -1, 0))) while (atomic_read(&ss->cur) == 0) cpu_relax(); It still spins on the spinaphore itself rather than on a local cacheline, so there's room for improvement. But it's not clear whether it'd be worth it. LOC wasn't really my argument -- I didn't want to introduce a new data structure unnecessarily. But the pitfalls (that I hadn't seen) of mixing down_spin() into semaphores are just too awful. I'll pop this patch off the stack of semaphore patches. Thanks. -- Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." --
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Greg KH | Re: [malware-list] [RFC 0/5] [TALPA] Intro to a linux interface for on access scan... |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Parag Warudkar | BUG: soft lockup - CPU#1 stuck for 15s! [swapper:0] |
git: | |
| Jakub Narebski | Re: VCS comparison table |
| Jakub Narebski | Git User's Survey 2007 unfinished summary continued |
| Linus Torvalds | I'm a total push-over.. |
| Marco Costalba | Decompression speed: zip vs lzo |
| Richard Stallman | Real men don't attack straw men |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Marcos Laufer | dmesg IBM x3650 OpenBSD 4.3 |
| Bill Chmura | SSL Certs on Carp'd web servers |
| Denys Fedoryshchenko | thousands of classes, e1000 TX unit hang |
| Steve French | Fwd: [PATCH] Fix CIFS compilation with CONFIG_KEYS unset |
| Jens Axboe | Re: [BUG] New Kernel Bugs |
| KOSAKI Motohiro | [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
| Treason Uncloaked | 3 hours ago | Linux kernel |
| Shared swap partition | 14 hours ago | Linux general |
| high memory | 2 days ago | Linux kernel |
| semaphore access speed | 2 days ago | Applications and Utilities |
| the kernel how to power off the machine | 2 days ago | Linux kernel |
| Easter Eggs in windows XP | 2 days ago | Windows |
| Root password | 2 days ago | Linux general |
| Where/when DNOTIFY is used? | 2 days ago | Linux kernel |
| How to convert Linux Kernel built-in module into a loadable module | 2 days ago | Linux kernel |
| Linux 2.6.24 and I/O schedulers | 2 days ago | Linux kernel |
