Skip to content

Commit 3d7d72a

Browse files
jinpuwangIngo Molnar
authored andcommitted
x86/sgx: Break up long non-preemptible delays in sgx_vepc_release()
On large enclaves we hit the softlockup warning with following call trace: xa_erase() sgx_vepc_release() __fput() task_work_run() do_exit() The latency issue is similar to the one fixed in: 8795359 ("x86/sgx: Silence softlockup detection when releasing large enclaves") The test system has 64GB of enclave memory, and all is assigned to a single VM. Release of 'vepc' takes a longer time and causes long latencies, which triggers the softlockup warning. Add cond_resched() to give other tasks a chance to run and reduce latencies, which also avoids the softlockup detector. [ mingo: Rewrote the changelog. ] Fixes: 540745d ("x86/sgx: Introduce virtual EPC for use by KVM guests") Reported-by: Yu Zhang <[email protected]> Signed-off-by: Jack Wang <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Yu Zhang <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Reviewed-by: Kai Huang <[email protected]> Acked-by: Haitao Huang <[email protected]> Cc: [email protected]
1 parent 659df86 commit 3d7d72a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/kernel/cpu/sgx/virt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ static int sgx_vepc_release(struct inode *inode, struct file *file)
204204
continue;
205205

206206
xa_erase(&vepc->page_array, index);
207+
cond_resched();
207208
}
208209

209210
/*
@@ -222,6 +223,7 @@ static int sgx_vepc_release(struct inode *inode, struct file *file)
222223
list_add_tail(&epc_page->list, &secs_pages);
223224

224225
xa_erase(&vepc->page_array, index);
226+
cond_resched();
225227
}
226228

227229
/*
@@ -243,6 +245,7 @@ static int sgx_vepc_release(struct inode *inode, struct file *file)
243245

244246
if (sgx_vepc_free_page(epc_page))
245247
list_add_tail(&epc_page->list, &secs_pages);
248+
cond_resched();
246249
}
247250

248251
if (!list_empty(&secs_pages))

0 commit comments

Comments
 (0)