[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFyGHhPvbqGaA0+tx7fbH+Uc6sbGKk2PLoFYCt-agCOgOw@mail.gmail.com>
Date: Tue, 22 May 2018 13:27:17 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: psodagud@...eaurora.org
Cc: Kees Cook <keescook@...omium.org>,
Andy Lutomirski <luto@...capital.net>,
Will Drewry <wad@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Rik van Riel <riel@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Eric Biggers <ebiggers@...gle.com>,
Frederic Weisbecker <fweisbec@...il.com>, sherryy@...roid.com,
Vegard Nossum <vegard.nossum@...cle.com>,
Christoph Lameter <cl@...ux.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Sasha Levin <alexander.levin@...izon.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: write_lock_irq(&tasklist_lock)
On Tue, May 22, 2018 at 12:40 PM Sodagudi Prasad <psodagud@...eaurora.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
Powered by blists - more mailing lists