From: Qais Yousef <qyousef@layalina.io>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
John Stultz <jstultz@google.com>,
LKML <linux-kernel@vger.kernel.org>, Wei Wang <wvw@google.com>,
Midas Chien <midaschieh@google.com>,
Kees Cook <keescook@chromium.org>,
Anton Vorontsov <anton@enomsg.org>,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
Tony Luck <tony.luck@intel.com>,
kernel-team@android.com, Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: [PATCH] pstore: Revert pmsg_lock back to a normal mutex
Date: Mon, 6 Mar 2023 19:19:26 +0000 [thread overview]
Message-ID: <20230306191926.n5526srkze5fnqag@airbuntu> (raw)
In-Reply-To: <20230304032135.GB2176990@google.com>
On 03/04/23 03:21, Joel Fernandes wrote:
> On Fri, Mar 03, 2023 at 08:36:45PM +0000, Qais Yousef wrote:
> > On 03/03/23 14:38, Steven Rostedt wrote:
> > > On Fri, 3 Mar 2023 14:25:23 -0500
> > > Joel Fernandes <joel@joelfernandes.org> wrote:
> > >
> > > > On Fri, Mar 3, 2023 at 1:37 PM Steven Rostedt <rostedt@goodmis.org> wrote:
> > > > >
> > > > > On Fri, 3 Mar 2023 18:11:34 +0000
> > > > > Joel Fernandes <joel@joelfernandes.org> wrote:
> > > > >
> > > > > > In the normal mutex's adaptive spinning, there is no check for if there is a
> > > > > > change in waiter AFAICS (ignoring ww mutex stuff for a second).
> > > > > >
> > > > > > I can see one may want to do that waiter-check, as spinning
> > > > > > indefinitely if the lock owner is on the CPU for too long may result in
> > > > > > excessing power burn. But normal mutex does not seem to do that.
> > > > > >
> > > > > > What makes the rtmutex spin logic different from normal mutex in this
> > > > > > scenario, so that rtmutex wants to do that but normal ones dont?
> > > > >
> > > > > Well, the point of the patch is that I don't think they should be different
> > > > > ;-)
> > > >
> > > > But there's no "waiter change" thing for mutex_spin_on_owner right.
> > > >
> > > > Then, should mutex_spin_on_owner() also add a call to
> > > > __mutex_waiter_is_first() ?
> > >
> > > Ah interesting, I missed the __mutex_waiter_is_first() in the mutex code,
> > > where it looks to do basically the same thing as rt_mutex (but slightly
> > > different). From looking at this, it appears that mutex() has FIFO fair
> > > logic, where the second waiter will sleep.
> > >
> > > Would be interesting to see why John sees such a huge difference between
> > > normal mutex and rtmutex if they are doing the same thing. One thing is
> > > perhaps the priority logic is causing the issue, where this will not
> > > improve anything.
> >
> > I think that can be a good suspect. If the waiters are RT tasks the root cause
> > might be starvation issue due to bad priority setup and moving to FIFO just
> > happens to hide it.
>
> I wonder if mutex should actually prioritize giving the lock to RT tasks
> instead of FIFO, since that's higher priority work. It sounds that's more
> 'fair'. But that's likely to make John's issue worse.
It is the right thing to do IMHO, but I guess the implications are just too
hard to tell to enforce it by default yet. Which is I guess why it's all
protected by PREEMPT_RT still.
(I'm not sure but I assumed that logically PREEMPT_RT would convert all mutex
to rt_mutexes by default)
>
> > For same priority RT tasks, we should behave as FIFO too AFAICS.
> >
> > If there are a mix of RT vs CFS; RT will always win of course.
> >
> > >
> > > I wonder if we add spinning to normal mutex for the other waiters if that
> > > would improve things or make them worse?
> >
> > I see a potential risk depending on how long the worst case scenario for this
> > optimistic spinning.
> >
> > RT tasks can prevent all lower priority RT and CFS from running.
>
> Agree, I was kind of hoping need_resched() in mutex_spin_on_owner() would
> come to the rescue in such a scenario, but obviously not. Modifications to
> check_preempt_curr_rt() could obviously aid there but...
>
> > CFS tasks will lose some precious bandwidth from their sched_slice() as this
> > will be accounted for them as RUNNING time even if they were effectively
> > waiting.
>
> True, but maybe the CFS task is happy to lose some bandwidth and get back to
> CPU quickly, than blocking and not getting any work done. ;-)
It depends on the worst case scenario of spinning. If we can ensure it's
bounded to something small, then yeah I don't see an issue :-)
Cheers
--
Qais Yousef
next prev parent reply other threads:[~2023-03-06 19:19 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-02 6:27 John Stultz
2023-03-02 13:24 ` Steven Rostedt
2023-03-02 19:39 ` John Stultz
2023-03-02 20:21 ` Steven Rostedt
2023-03-02 21:32 ` Steven Rostedt
2023-03-02 21:36 ` Steven Rostedt
2023-03-02 21:56 ` Steven Rostedt
2023-03-03 1:01 ` Steven Rostedt
2023-03-03 18:11 ` Joel Fernandes
2023-03-03 18:37 ` Steven Rostedt
2023-03-03 19:25 ` Joel Fernandes
2023-03-03 19:38 ` Steven Rostedt
2023-03-03 20:36 ` Qais Yousef
2023-03-04 3:21 ` Joel Fernandes
2023-03-06 19:19 ` Qais Yousef [this message]
2023-03-04 3:01 ` Joel Fernandes
2023-03-04 3:23 ` Joel Fernandes
2023-03-07 14:08 ` Peter Zijlstra
2023-03-07 20:19 ` Joel Fernandes
2023-03-06 18:30 ` John Stultz
2023-03-08 1:31 ` Steven Rostedt
2023-03-08 20:04 ` John Stultz
2023-03-08 20:41 ` Steven Rostedt
2023-03-02 22:41 ` David Laight
2023-03-02 22:53 ` Steven Rostedt
2023-03-04 3:10 ` [PATCH v2] " John Stultz
2023-03-05 16:36 ` Steven Rostedt
2023-03-06 18:27 ` John Stultz
[not found] ` <20230306010323.2909-1-hdanton@sina.com>
2023-03-06 15:28 ` Steven Rostedt
[not found] ` <20230307003106.1768-1-hdanton@sina.com>
2023-03-07 1:58 ` Steven Rostedt
2023-03-03 7:06 [PATCH] " Chunhui Li (李春辉)
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=20230306191926.n5526srkze5fnqag@airbuntu \
--to=qyousef@layalina.io \
--cc=anton@enomsg.org \
--cc=bigeasy@linutronix.de \
--cc=gpiccoli@igalia.com \
--cc=joel@joelfernandes.org \
--cc=jstultz@google.com \
--cc=keescook@chromium.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=midaschieh@google.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=wvw@google.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
all inboxes | Powered by JetHome®