Messages in this thread | | | From | Linus Torvalds <> | Date | Tue, 22 May 2018 13:27:17 -0700 | Subject | Re: write_lock_irq(&tasklist_lock) |
| |
On Tue, May 22, 2018 at 12:40 PM Sodagudi Prasad <psodagud@codeaurora.org> wrote:
> Have you observed this type of issues with tasklist_lock ?
tasklist_lock remains pretty painful. It covers too much, but trying to split it up has never worked well.
It's usually not a huge problem because there are so few writers, but what you're seeing is the writer starvation issue because readers can be plentiful.
> Do we need write_lock_irq(&tasklist_lock) in below portion of code ? Can > I use write_unlock instead of write_lock_irq in portion of code?
You absolutely need write_lock_irq(), because taking the tasklist_lock without disabling interrupts will deadlock very quickly due to an interrupt taking the tasklist_lock for reading.
That said, the write_lock_irq(&tasklist_lock) could possibly be replaced with something like
static void tasklist_write_lock(void) { unsigned long flags; local_irq_save(flags); while (!write_trylock(&tasklist_lock)) { local_irq_restore(flags); do { cpu_relax(); } while (write_islocked(&tasklist_lock)); local_irq_disable(); } }
but we don't have that "write_islocked()" function.
So the above would need more work, and is entirely untested anyway, obviously.
Linus
| |