History

Merge tag 'io_uring-5.8-2020-07-01' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe: "One fix in here, for a regression in 5.7 where a task is waiting in the kernel for a condition, but that condition won't become true until task_work is run. And the task_work can't be run exactly because the task is waiting in the kernel, so we'll never make any progress. One example of that is registering an eventfd and queueing io_uring work, and then the task goes and waits in eventfd read with the expectation that it'll get woken (and read an event) when the io_uring request completes. The io_uring request is finished through task_work, which won't get run while the task is looping in eventfd read" * tag 'io_uring-5.8-2020-07-01' of git://git.kernel.dk/linux-block: io_uring: use signal based task_work running task_work: teach task_work_add() to do signal_wake_up()

Linus Torvalds committed 6 years ago

Commit c93493b2 parents cd77006 ce593a65 files · +52 −15Browse files

Showing the changes to kernel (2 of 5 files). Show all

Unified · Split

2 files
  1. kernel/signal.c +7 −3
  2. kernel/task_work.c +14 −2
kernel/signal.c+7−3
@@ -2529,9 +2529,6 @@ bool get_signal(struct ksignal *ksig) · 2528 unmodified lines
25292529 struct signal_struct *signal = current->signal;
25302530 int signr;
25312531
2532− if (unlikely(current->task_works))
2533− task_work_run();
2534−
25352532 if (unlikely(uprobe_deny_signal()))
25362533 return false;
25372534
@@ -2544,6 +2541,13 @@ bool get_signal(struct ksignal *ksig) · 6 unmodified lines
25442541
25452542 relock:
25462543 spin_lock_irq(&sighand->siglock);
2544+ current->jobctl &= ~JOBCTL_TASK_WORK;
2545+ if (unlikely(current->task_works)) {
2546+ spin_unlock_irq(&sighand->siglock);
2547+ task_work_run();
2548+ goto relock;
2549+ }
2550+
25472551 /*
25482552 * Every stopped thread goes here after wakeup. Check to see if
25492553 * we should notify the parent, prepare_signal(SIGCONT) encodes
kernel/task_work.c+14−2
@@ -25,9 +25,10 @@ static struct callback_head work_exited; /* all we need is ->next == NULL */ · 24 unmodified lines
2525 * 0 if succeeds or -ESRCH.
2626 */
2727 int
28−task_work_add(struct task_struct *task, struct callback_head *work, bool notify)
28+task_work_add(struct task_struct *task, struct callback_head *work, int notify)
2929 {
3030 struct callback_head *head;
31+ unsigned long flags;
3132
3233 do {
3334 head = READ_ONCE(task->task_works);
@@ -36,8 +37,19 @@ task_work_add(struct task_struct *task, struct callback_head *work, bool notify) · 2 unmodified lines
3637 work->next = head;
3738 } while (cmpxchg(&task->task_works, head, work) != head);
3839
39− if (notify)
40+ switch (notify) {
41+ case TWA_RESUME:
4042 set_notify_resume(task);
43+ break;
44+ case TWA_SIGNAL:
45+ if (lock_task_sighand(task, &flags)) {
46+ task->jobctl |= JOBCTL_TASK_WORK;
47+ signal_wake_up(task, 0);
48+ unlock_task_sighand(task, &flags);
49+ }
50+ break;
51+ }
52+
4153 return 0;
4254 }
4355

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t