mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	DanielWagnerwagi@monom.org, Boqun Feng <boqun.feng@gmail.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Ming Lei <ming.lei@redhat.com>,
	yi1.li@linux.intel.com, takahiro.akashi@linaro.org
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>,
	"Luis R. Rodriguez" <mcgrof@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	ebiederm@xmission.com, pmladek@suse.com, luto@kernel.org,
	keescook@chromium.org, dhowells@redhat.com, alan@linux.intel.com,
	tytso@mit.edu, oss-drivers@netronome.com
Subject: Re: [PATCH] firmware: wake all waiters
Date: Tue, 27 Jun 2017 01:30:30 +0200	[thread overview]
Message-ID: <20170626233030.GI21846@wotan.suse.de> (raw)
In-Reply-To: <CA+55aFxivLtaFEur99eZpoafcweK1WNvSu2vEvxXvj5gKB8CdA@mail.gmail.com>

On Mon, Jun 26, 2017 at 02:44:17PM -0700, Linus Torvalds wrote:
> On Fri, Jun 23, 2017 at 4:37 PM, Jakub Kicinski
> <jakub.kicinski@netronome.com> wrote:
> > -               swake_up(&fw_st->wq);
> > +               swake_up_all(&fw_st->wq);
> 
> Why is that code using the braindamaed "swait" model in the first place?

The conversion was done via commit 5b029624948d ("firmware: do not use fw_lock
for fw_state protection").  This commit overlooked this "batched request"
feature.

> That's the real problem here - swait() is a very specialized
> interface, and it does not make sense to use it here.
> 
> Among all the simplifications it has is exactly the fact that it wakes
> up only one thing, because it is *so* specialized.

Not sure I follow, it can wake up all items in queue with swake_up_all(), no?

At first I *thought* we don't add further items with __prepare_to_swait() but
actually that if (list_empty(&wait->task_list)) check just checks if the
item was already added to a wait list. So swait can queue more waiters, no?

> But the *only* reason for swait is extreme memory issues and some very
> special realtime issues, where it saves a couple of bytes in
> structures that need close packing, and doesn't even use normal
> spinlocks, so it saves a couple of cycles at wakeup/sleep because it
> doesn't do a good job in general.

I see.

> The "avoid normal spinlocks" is because it is meant for code that is
> *so* special that it needs the magical low-level raw spinlocks.
> 
> I really have *no* idea why the firmware code uses that idiotic
> special wait-queue. It has no reason to do so, except this comment
> from the commit that added it:
> 
>   "We use also swait instead of wait because don't need all the additional
>     features wait provides."
> 
> which is bogus, since it clearly just got the waiting wrong exactly
> *because* swait is pretty damn bad and specialized.

If indeed it cannot queue and wake all then surely this is buggered!

> I think the two valid users are RCU (which needed it for RT), and kvm
> (which also needed it for similar issues - it needs to be
> non-preemptible).

Got it.

> I don't see any similar reason for the firmware loading, and all it
> did was use an odd interface that resulted in this bug.

>From my review when this was suggested it seemed to cover all grounds
and an API that was more light weight seemed sensible. The swait documentation
seems to note "One would recommend using this wait queue where possible."
If its non suitable for multiple waits then indeed this needs fixing so
this doesn't happen again.

> Why is the firmware code being so damn odd on purpose?

I've been asking myself that since I started reviewing the firmware code :) But
in this case I believe the commit overlooked batched requests functionality and
to use swake_up_all().

  Luis

  reply	other threads:[~2017-06-26 23:30 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23 23:37 Jakub Kicinski
2017-06-26 21:20 ` Luis R. Rodriguez
2017-06-26 21:23   ` [PATCH v2] firmware: fix batched requests - " Luis R. Rodriguez
2017-06-29 15:16     ` Greg KH
2017-06-29 15:17       ` Greg KH
2017-06-29 17:36         ` Luis R. Rodriguez
2017-06-26 23:41   ` [PATCH] firmware: " Luis R. Rodriguez
2017-06-27  2:10   ` Jakub Kicinski
2017-06-27 16:39     ` Luis R. Rodriguez
2017-06-27 21:25       ` Jakub Kicinski
2017-06-27 22:24         ` Luis R. Rodriguez
2017-06-27 22:39           ` Jakub Kicinski
2017-06-27 23:50             ` Luis R. Rodriguez
2017-06-28  7:06           ` [systemd-devel] " Lennart Poettering
2017-06-28 16:06             ` Luis R. Rodriguez
2017-06-28 16:21               ` Lennart Poettering
2017-06-28 17:57                 ` Luis R. Rodriguez
2017-06-29 19:56               ` Daniel Wagner
2017-06-27 17:48     ` Bjorn Andersson
2017-06-27 18:03       ` Luis R. Rodriguez
2017-06-27 18:59         ` Bjorn Andersson
2017-06-27 19:08           ` Luis R. Rodriguez
2017-06-27 19:52             ` Bjorn Andersson
2017-06-27 20:24               ` Luis R. Rodriguez
2017-06-26 21:44 ` Linus Torvalds
2017-06-26 23:30   ` Luis R. Rodriguez [this message]
2017-06-26 23:43     ` Linus Torvalds
2017-06-27  0:15       ` Luis R. Rodriguez
2017-06-28 13:45         ` Davidlohr Bueso
2017-06-28 15:58           ` Luis R. Rodriguez
2017-06-28 19:03             ` Davidlohr Bueso
2017-06-29 19:08         ` Davidlohr Bueso
2017-06-29 19:48           ` Luis R. Rodriguez
2017-06-30 16:32             ` Davidlohr Bueso
2017-07-05 16:18     ` Peter Zijlstra
2017-07-05 16:33       ` Linus Torvalds
2017-07-12 18:45         ` Luis R. Rodriguez

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=20170626233030.GI21846@wotan.suse.de \
    --to=mcgrof@kernel.org \
    --cc=DanielWagnerwagi@monom.org \
    --cc=alan@linux.intel.com \
    --cc=boqun.feng@gmail.com \
    --cc=dave@stgolabs.net \
    --cc=dhowells@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jakub.kicinski@netronome.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=oss-drivers@netronome.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=takahiro.akashi@linaro.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=yi1.li@linux.intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome