Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ed6edd

Browse files
Barret RhodenPeter Zijlstra
Barret Rhoden
authored and
Peter Zijlstra
committed
perf: Add cond_resched() to task_function_call()
Under rare circumstances, task_function_call() can repeatedly fail andcause a soft lockup.There is a slight race where the process is no longer running on the cpuwe targeted by the time remote_function() runs. The code will simplytry again. If we are very unlucky, this will continue to fail, until awatchdog fires. This can happen in a heavily loaded, multi-core virtualmachine.Reported-by: syzbot+bb4935a5c09b5ff79940@syzkaller.appspotmail.comSigned-off-by: Barret Rhoden <brho@google.com>Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>Link:https://lkml.kernel.org/r/20200414222920.121401-1-brho@google.com
1 parent3a4ac12 commit2ed6edd

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

‎kernel/events/core.c‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ static void remote_function(void *data)
9595
* @info:the function call argument
9696
*
9797
* Calls the function @func when the task is currently running. This might
98-
* be on the current CPU, which just calls the function directly
98+
* be on the current CPU, which just calls the function directly. This will
99+
* retry due to any failures in smp_call_function_single(), such as if the
100+
* task_cpu() goes offline concurrently.
99101
*
100-
* returns: @func return value, or
101-
* -ESRCH - when the process isn't running
102-
* -EAGAIN - when the process moved away
102+
* returns @func return value or -ESRCH when the process isn't running
103103
*/
104104
staticint
105105
task_function_call(structtask_struct*p,remote_function_ffunc,void*info)
@@ -112,11 +112,16 @@ task_function_call(struct task_struct *p, remote_function_f func, void *info)
112112
};
113113
intret;
114114

115-
do {
116-
ret=smp_call_function_single(task_cpu(p),remote_function,&data,1);
117-
if (!ret)
118-
ret=data.ret;
119-
}while (ret==-EAGAIN);
115+
for (;;) {
116+
ret=smp_call_function_single(task_cpu(p),remote_function,
117+
&data,1);
118+
ret= !ret ?data.ret :-EAGAIN;
119+
120+
if (ret!=-EAGAIN)
121+
break;
122+
123+
cond_resched();
124+
}
120125

121126
returnret;
122127
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp