From: Linus Torvalds <torvalds@linux-foundation.org>
To: Al Viro <viro@zeniv.linux.org.uk>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [git pull] vfs.git pile 3 - dcache
Date: Wed, 3 Aug 2022 11:57:27 -0700 [thread overview]
Message-ID: <CAHk-=wizUgMbZKnOjvyeZT5E+WZM0sV+zS5Qxt84wp=BsRk3eQ@mail.gmail.com> (raw)
In-Reply-To: <YurA3aSb4GRr4wlW@ZenIV>
On Wed, Aug 3, 2022 at 11:39 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> Main part here is making parallel lookups safe for RT - making
> sure preemption is disabled in start_dir_add()/ end_dir_add() sections (on
> non-RT it's automatic, on RT it needs to to be done explicitly) and moving
> wakeups from __d_lookup_done() inside of such to the end of those sections.
Ugh.
I really dislike this pattern:
if (IS_ENABLED(CONFIG_PREEMPT_RT))
preempt_disable();
...
if (IS_ENABLED(CONFIG_PREEMPT_RT))
preempt_enable();
and while the new comment explains *why* it exists, it's still very ugly indeed.
We have it in a couple of other places, and we also end up having
another variation on the theme that is about "migrate_{dis,en}able()",
except it is written as
if (IS_ENABLED(CONFIG_PREEMPT_RT))
migrate_disable();
else
preempt_disable();
because on non-PREEMPT_RT obviously preempt_disable() is the better
and simpler thing.
Can we please just introduce helper functions?
At least that
if (IS_ENABLED(CONFIG_PREEMPT_RT))
preempt_disable();
...
pattern could be much more naturally expressed as
preempt_disable_under_spinlock();
...
which would make the code really explain what is going on. I would
still encourage that *comment* about it, but I think we really should
strive for code that makes sense even without a comment.
The fact that then without PREEMPT_RT, the whole
"preempt_disable_under_spinlock()" becomes a no-op is then an
implementation detail - and not so different from how a regular
preempt_disable() becomes a no-op when on UP (or with PREEMPT_NONE).
And that "preempt_disable_under_spinlock()" really documents what is
going on, and I feel would make that code easier to understand? The
fact that PREEMPT_RT has different rules about preemption is not
something that the dentry code should care about.
The dentry code could just say "I want to disable preemption, and I
already hold a spinlock, so do what is best".
So then "preempt_disable_under_spinlock()" precisely documents what
the dentry code really wants.
No?
Anyway, I have pulled this, but I really would like fewer of these
random PREEMPT_RT turds around, and more "this code makes sense" code.
Linus
next prev parent reply other threads:[~2022-08-03 18:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 18:39 [git pull] vfs.git pile 3 - dcache Al Viro
2022-08-03 18:57 ` Linus Torvalds [this message]
2022-08-03 19:49 ` Al Viro
2022-08-03 21:54 ` Steven Rostedt
2022-08-03 22:09 ` Linus Torvalds
2022-08-03 22:59 ` Steven Rostedt
2022-08-03 23:24 ` Matthew Wilcox
2022-08-03 23:42 ` Linus Torvalds
2022-08-04 0:42 ` Matthew Wilcox
2022-08-04 1:32 ` Steven Rostedt
2022-08-04 2:16 ` Linus Torvalds
2022-08-04 10:52 ` Steven Rostedt
2022-08-08 22:06 ` Thomas Gleixner
2022-08-08 22:43 ` Linus Torvalds
2022-08-09 16:00 ` Thomas Gleixner
2022-08-09 16:15 ` Matthew Wilcox
2022-08-09 17:58 ` Thomas Gleixner
2022-08-03 19:00 ` pr-tracker-bot
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='CAHk-=wizUgMbZKnOjvyeZT5E+WZM0sV+zS5Qxt84wp=BsRk3eQ@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
/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.