Re: [PATCH 2/2] io_uring: use TWA_SIGNAL for task_work if the task isn't running

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/10/20 3:12 PM, Jens Axboe wrote:
> On 8/10/20 3:10 PM, Peter Zijlstra wrote:
>> On Mon, Aug 10, 2020 at 03:06:49PM -0600, Jens Axboe wrote:
>>
>>> should work as far as I can tell, but I don't even know if there's a
>>> reliable way to do task_in_kernel().
>>
>> Only on NOHZ_FULL, and tracking that is one of the things that makes it
>> so horribly expensive.
> 
> Probably no other way than to bite the bullet and just use TWA_SIGNAL
> unconditionally...

Is there a safe way to make TWA_SIGNAL notification cheaper? I won't
pretend to fully understand the ordering, Oleg probably has a much
better idea then me...

diff --git a/kernel/task_work.c b/kernel/task_work.c
index 5c0848ca1287..ea2c683c8563 100644
--- a/kernel/task_work.c
+++ b/kernel/task_work.c
@@ -42,7 +42,8 @@ task_work_add(struct task_struct *task, struct callback_head *work, int notify)
 		set_notify_resume(task);
 		break;
 	case TWA_SIGNAL:
-		if (lock_task_sighand(task, &flags)) {
+		if (!(task->jobctl & JOBCTL_TASK_WORK) &&
+		    lock_task_sighand(task, &flags)) {
 			task->jobctl |= JOBCTL_TASK_WORK;
 			signal_wake_up(task, 0);
 			unlock_task_sighand(task, &flags);

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux