I need to solve a locking problem for this scenario:
- A multi CPU system.
- All of the CPU's use a common (software) resource.
- Read only access to the resource is very common. (Processing of incoming network packets)
- Write access is a lot less frequent. (Pretty much configuration changes only).
Currently I use the read_lock_bh
, write_lock_bh
(spinlocks) mechanism.
The problem is that the more CPU's, the more I get soft lockups in a writer context.
I read the concurrency chapter in this book, But couldn't quite understand whether the reader or the writer will get priority when using spin locks.
So the questions are:
- Does the Linux spinlock mechanism give priority the reader/writer/none of them?
- Is there a better mechanism I can use in order to avoid those soft lockups in my scenario, or maybe a way for me to give priority to the writer whenever it tries to obtain the lock, while using my current solution?
Thanks, Nir