All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: psodagud@codeaurora.org
Cc: Kees Cook <keescook@chromium.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Rik van Riel <riel@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Eric Biggers <ebiggers@google.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	sherryy@android.com, Vegard Nossum <vegard.nossum@oracle.com>,
	Christoph Lameter <cl@linux.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Sasha Levin <alexander.levin@verizon.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: write_lock_irq(&tasklist_lock)
Date: Tue, 22 May 2018 13:27:17 -0700	[thread overview]
Message-ID: <CA+55aFyGHhPvbqGaA0+tx7fbH+Uc6sbGKk2PLoFYCt-agCOgOw@mail.gmail.com> (raw)
In-Reply-To: <0879f797135033e05e8e9166a3c85628@codeaurora.org>

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

  reply	other threads:[~2018-05-22 20:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 19:40 write_lock_irq(&tasklist_lock) Sodagudi Prasad
2018-05-22 20:27 ` Linus Torvalds [this message]
2018-05-22 21:17   ` write_lock_irq(&tasklist_lock) Peter Zijlstra
2018-05-22 21:31     ` write_lock_irq(&tasklist_lock) Linus Torvalds
2018-05-23  8:19       ` write_lock_irq(&tasklist_lock) Peter Zijlstra
2018-05-23 13:05 ` write_lock_irq(&tasklist_lock) Will Deacon
2018-05-23 15:25   ` write_lock_irq(&tasklist_lock) Linus Torvalds
2018-05-23 15:36     ` write_lock_irq(&tasklist_lock) Will Deacon
2018-05-23 16:26       ` write_lock_irq(&tasklist_lock) Linus Torvalds
2018-05-24 12:49         ` write_lock_irq(&tasklist_lock) Will Deacon
2018-05-24 13:51           ` write_lock_irq(&tasklist_lock) Boqun Feng
2018-05-24 17:37             ` write_lock_irq(&tasklist_lock) Sodagudi Prasad
2018-05-24 18:28               ` write_lock_irq(&tasklist_lock) Peter Zijlstra
2018-05-24 21:14             ` write_lock_irq(&tasklist_lock) Andrea Parri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+55aFyGHhPvbqGaA0+tx7fbH+Uc6sbGKk2PLoFYCt-agCOgOw@mail.gmail.com \
    --to=torvalds@linux-foundation.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.levin@verizon.com \
    --cc=cl@linux.com \
    --cc=ebiggers@google.com \
    --cc=fweisbec@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=psodagud@codeaurora.org \
    --cc=riel@redhat.com \
    --cc=sherryy@android.com \
    --cc=tglx@linutronix.de \
    --cc=vegard.nossum@oracle.com \
    --cc=wad@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.