Skip to content

lwksched: Fix deadlock during thread exit #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions kernel/sched/mos.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,14 @@ static void uncommit_cpu(struct task_struct *p)
struct mos_rq *mos_rq;
int cpu = p->mos.cpu_home;
int underflow = 0;
unsigned long flags;

if (cpu < 0)
return;
mos_rq = &cpu_rq(cpu)->mos;
p->mos.cpu_home = -1;

raw_spin_lock(&mos_rq->lock);
raw_spin_lock_irqsave(&mos_rq->lock, flags);
if (p->mos.thread_type == mos_thread_type_normal) {
if (mos_rq->compute_commits > 0)
mos_rq->compute_commits--;
Expand All @@ -364,7 +365,7 @@ static void uncommit_cpu(struct task_struct *p)
else
underflow = 1;
}
raw_spin_unlock(&mos_rq->lock);
raw_spin_unlock_irqrestore(&mos_rq->lock, flags);

trace_mos_cpu_uncommit(p, cpu, mos_rq->compute_commits,
mos_rq->utility_commits, underflow);
Expand All @@ -375,11 +376,12 @@ static void commit_cpu(struct task_struct *p, int cpu)
struct mos_rq *mos_rq;
unsigned int newval = 0;
int overflow = 0;
unsigned long flags;

if (cpu < 0)
return;
mos_rq = &cpu_rq(cpu)->mos;
raw_spin_lock(&mos_rq->lock);
raw_spin_lock_irqsave(&mos_rq->lock, flags);
if (p->mos.thread_type == mos_thread_type_normal) {
if (mos_rq->compute_commits < INT_MAX) {
newval = ++mos_rq->compute_commits;
Expand All @@ -395,7 +397,7 @@ static void commit_cpu(struct task_struct *p, int cpu)
} else
overflow = 1;
}
raw_spin_unlock(&mos_rq->lock);
raw_spin_unlock_irqrestore(&mos_rq->lock, flags);
p->mos.cpu_home = cpu;
trace_mos_cpu_commit(p, cpu, mos_rq->compute_commits,
mos_rq->utility_commits, overflow);
Expand Down