task_work: Decouple TIF_NOTIFY_SIGNAL and task_work
Bugzilla: https://bugzilla.redhat.com/2120352 commit 7c5d8fa6fbb12a3f0eefe8762bfede508e147cb3 Author: Eric W. Biederman <ebiederm@xmission.com> Date: Wed Feb 9 11:18:54 2022 -0600 task_work: Decouple TIF_NOTIFY_SIGNAL and task_work There are a small handful of reasons besides pending signals that the kernel might want to break out of interruptible sleeps. The flag TIF_NOTIFY_SIGNAL and the helpers that set and clear TIF_NOTIFY_SIGNAL provide that the infrastructure for breaking out of interruptible sleeps and entering the return to user space slow path for those cases. Expand tracehook_notify_signal inline in it's callers and remove it, which makes clear that TIF_NOTIFY_SIGNAL and task_work are separate concepts. Update the comment on set_notify_signal to more accurately describe it's purpose. Reviewed-by: Kees Cook <keescook@chromium.org> Link: https://lkml.kernel.org/r/20220309162454.123006-9-ebiederm@xmission.com Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
This commit is contained in:
parent
6fb7c30612
commit
5a3ee243fe
|
@ -461,7 +461,9 @@ static bool io_flush_signals(void)
|
||||||
{
|
{
|
||||||
if (unlikely(test_thread_flag(TIF_NOTIFY_SIGNAL))) {
|
if (unlikely(test_thread_flag(TIF_NOTIFY_SIGNAL))) {
|
||||||
__set_current_state(TASK_RUNNING);
|
__set_current_state(TASK_RUNNING);
|
||||||
tracehook_notify_signal();
|
clear_notify_signal();
|
||||||
|
if (task_work_pending(current))
|
||||||
|
task_work_run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2261,7 +2261,9 @@ static inline bool io_run_task_work(void)
|
||||||
{
|
{
|
||||||
if (test_thread_flag(TIF_NOTIFY_SIGNAL) || task_work_pending(current)) {
|
if (test_thread_flag(TIF_NOTIFY_SIGNAL) || task_work_pending(current)) {
|
||||||
__set_current_state(TASK_RUNNING);
|
__set_current_state(TASK_RUNNING);
|
||||||
tracehook_notify_signal();
|
clear_notify_signal();
|
||||||
|
if (task_work_pending(current))
|
||||||
|
task_work_run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,19 +113,8 @@ static inline void clear_notify_signal(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* called by exit_to_user_mode_loop() if ti_work & _TIF_NOTIFY_SIGNAL. This
|
* Called to break out of interruptible wait loops, and enter the
|
||||||
* is currently used by TWA_SIGNAL based task_work, which requires breaking
|
* exit_to_user_mode_loop().
|
||||||
* wait loops to ensure that task_work is noticed and run.
|
|
||||||
*/
|
|
||||||
static inline void tracehook_notify_signal(void)
|
|
||||||
{
|
|
||||||
clear_notify_signal();
|
|
||||||
if (task_work_pending(current))
|
|
||||||
task_work_run();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Called when we have work to process from exit_to_user_mode_loop()
|
|
||||||
*/
|
*/
|
||||||
static inline void set_notify_signal(struct task_struct *task)
|
static inline void set_notify_signal(struct task_struct *task)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,8 +8,11 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work)
|
||||||
do {
|
do {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
|
if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) {
|
||||||
tracehook_notify_signal();
|
clear_notify_signal();
|
||||||
|
if (task_work_pending(current))
|
||||||
|
task_work_run();
|
||||||
|
}
|
||||||
|
|
||||||
if (ti_work & _TIF_SIGPENDING) {
|
if (ti_work & _TIF_SIGPENDING) {
|
||||||
kvm_handle_signal_exit(vcpu);
|
kvm_handle_signal_exit(vcpu);
|
||||||
|
|
Loading…
Reference in New Issue