From: Peter Zijlstra <peterz@infradead.org>
To: Linus Torvalds <torvalds@linuxfoundation.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
peterz@infradead.org, Jonathan Cameron <jic23@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Oleg Nesterov <oleg@redhat.com>,
Eric Biederman <ebiederm@xmission.com>
Subject: [PATCH 0/2] cleanup: Conditional locking support
Date: Thu, 02 Nov 2023 11:44:29 +0100 [thread overview]
Message-ID: <20231102104429.025835330@infradead.org> (raw)
Hi,
Two patches, the first extending the cleanup/guard stuff to better handle
conditional locks, mutex_trylock(), mutex_lock_interruptible() etc.. And the
second a small ptrace conversion that I've been using as a test-case.
The normal scoped_guard() is changed to simply skip the body when a conditional
lock fails to acquire. A new scoped_cond_guard() is added that takes an extra
statement argument to provide an explicit 'fail' action.
The ptrace patch has:
scoped_cond_guard (mutex_intr, return -ERESTARTNOINTR,
&task->signal->cred_guard_mutex) {
...
}
...
return 0;
Where if the lock acquire fails, it does 'return -ERESTARTNOINTR'.
The crazy perf thing then becomes:
scoped_cond_guard (rwsem_read_intr, goto no_lock,
task ? &task->signal->exec_update_lock : NULL) {
if (0) {
no_lock:
if (task)
return -EINTR;
}
... body with or without lock ...
}
Specifically, that thing needs the lock when there is a task, but otherwise
needs to still do the body without the lock.
IIO also wanted something along these lines, although they have a custom
'trylock' thing.
Barring objections, I'm planning to merge this into tip/locking/cleanup which
I'll merge into tip/locking/core (and tip/perf/core when times comes).
My plan is to post the perf patches in 3 batches of roughly 10 patches each,
the simpler first and the more crazy ones (including the above) last.
next reply other threads:[~2023-11-02 11:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 10:44 Peter Zijlstra [this message]
2023-11-02 10:44 ` [PATCH 1/2] cleanup: Add conditional guard support Peter Zijlstra
2023-11-02 14:40 ` Oleg Nesterov
2023-11-02 15:55 ` Oleg Nesterov
2023-11-03 9:30 ` Peter Zijlstra
2023-11-03 18:17 ` Linus Torvalds
2023-11-03 18:51 ` Oleg Nesterov
2023-11-02 10:44 ` [PATCH 2/2] ptrace: Convert ptrace_attach() to use lock guards Peter Zijlstra
2023-11-02 15:17 ` Oleg Nesterov
2023-11-02 15:34 ` [PATCH 0/2] cleanup: Conditional locking support Peter Zijlstra
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=20231102104429.025835330@infradead.org \
--to=peterz@infradead.org \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=torvalds@linuxfoundation.org \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox