ksched: bug fixes

This commit is contained in:
Adam Belay 2018-07-12 21:50:29 +00:00
parent 0ab4d36cb0
commit ecbbaa66ee
2 changed files with 17 additions and 4 deletions

View File

@ -138,7 +138,16 @@ static long ksched_park(void)
put_cpu();
/* put this task to sleep and reschedule so the next task can run */
__set_current_state(TASK_UNINTERRUPTIBLE);
__set_current_state(TASK_INTERRUPTIBLE);
schedule();
__set_current_state(TASK_RUNNING);
return 0;
}
static long ksched_start(void)
{
/* put this task to sleep and reschedule so the next task can run */
__set_current_state(TASK_INTERRUPTIBLE);
schedule();
__set_current_state(TASK_RUNNING);
return 0;
@ -150,6 +159,7 @@ static void ksched_ipi(void *unused)
struct task_struct *t;
unsigned long gen;
/* if last_gen is the current gen, ksched_park() beat us here */
gen = smp_load_acquire(&p->gen);
if (gen == p->last_gen)
@ -227,6 +237,8 @@ ksched_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
switch (cmd) {
case KSCHED_IOC_PARK:
return ksched_park();
case KSCHED_IOC_START:
return ksched_start();
case KSCHED_IOC_WAKE:
return ksched_wake((void __user *)arg);
default:
@ -271,7 +283,7 @@ static int __init ksched_init(void)
return ret;
}
printk(KERN_INFO "ksched: scheduler interface ready");
printk(KERN_INFO "ksched: API V1 ready");
return 0;
}

View File

@ -28,7 +28,8 @@ struct ksched_wake_req {
};
#define KSCHED_MAGIC 0xF0
#define KSCHED_IOC_MAXNR 2
#define KSCHED_IOC_MAXNR 3
#define KSCHED_IOC_PARK _IO(KSCHED_MAGIC, 1)
#define KSCHED_IOC_WAKE _IOW(KSCHED_MAGIC, 2, struct ksched_wake_req)
#define KSCHED_IOC_START _IO(KSCHED_MAGIC, 2)
#define KSCHED_IOC_WAKE _IOW(KSCHED_MAGIC, 3, struct ksched_wake_req)