um: fix time-travel syscall scheduling hack
The schedule() call there really never did anything at least since the introduction of the EEVDF scheduler, but now I found a case where we permanently hang in a loop of -ERESTARTNOINTR (due to locking.) Work around it by making any syscalls with error return take time (and then schedule after) so we cannot hang in such a loop forever. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
ae0dc67c25
commit
381d2f95c8
@ -12,23 +12,13 @@
|
|||||||
#include <sysdep/syscalls.h>
|
#include <sysdep/syscalls.h>
|
||||||
#include <linux/time-internal.h>
|
#include <linux/time-internal.h>
|
||||||
#include <asm/unistd.h>
|
#include <asm/unistd.h>
|
||||||
|
#include <asm/delay.h>
|
||||||
|
|
||||||
void handle_syscall(struct uml_pt_regs *r)
|
void handle_syscall(struct uml_pt_regs *r)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs = container_of(r, struct pt_regs, regs);
|
struct pt_regs *regs = container_of(r, struct pt_regs, regs);
|
||||||
int syscall;
|
int syscall;
|
||||||
|
|
||||||
/*
|
|
||||||
* If we have infinite CPU resources, then make every syscall also a
|
|
||||||
* preemption point, since we don't have any other preemption in this
|
|
||||||
* case, and kernel threads would basically never run until userspace
|
|
||||||
* went to sleep, even if said userspace interacts with the kernel in
|
|
||||||
* various ways.
|
|
||||||
*/
|
|
||||||
if (time_travel_mode == TT_MODE_INFCPU ||
|
|
||||||
time_travel_mode == TT_MODE_EXTERNAL)
|
|
||||||
schedule();
|
|
||||||
|
|
||||||
/* Initialize the syscall number and default return value. */
|
/* Initialize the syscall number and default return value. */
|
||||||
UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
|
UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
|
||||||
PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);
|
PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);
|
||||||
@ -41,9 +31,25 @@ void handle_syscall(struct uml_pt_regs *r)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
syscall = UPT_SYSCALL_NR(r);
|
syscall = UPT_SYSCALL_NR(r);
|
||||||
if (syscall >= 0 && syscall < __NR_syscalls)
|
if (syscall >= 0 && syscall < __NR_syscalls) {
|
||||||
PT_REGS_SET_SYSCALL_RETURN(regs,
|
unsigned long ret = EXECUTE_SYSCALL(syscall, regs);
|
||||||
EXECUTE_SYSCALL(syscall, regs));
|
|
||||||
|
PT_REGS_SET_SYSCALL_RETURN(regs, ret);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An error value here can be some form of -ERESTARTSYS
|
||||||
|
* and then we'd just loop. Make any error syscalls take
|
||||||
|
* some time, so that it won't just loop if something is
|
||||||
|
* not ready, and hopefully other things will make some
|
||||||
|
* progress.
|
||||||
|
*/
|
||||||
|
if (IS_ERR_VALUE(ret) &&
|
||||||
|
(time_travel_mode == TT_MODE_INFCPU ||
|
||||||
|
time_travel_mode == TT_MODE_EXTERNAL)) {
|
||||||
|
um_udelay(1);
|
||||||
|
schedule();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
syscall_trace_leave(regs);
|
syscall_trace_leave(regs);
|
||||||
|
Loading…
Reference in New Issue
Block a user