Skip to content

Commit

Permalink
[virt/cpu] Use better return value for SYS_sched_getaffinity.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaomy3832 committed Feb 22, 2020
1 parent 4879ffc commit 775d84b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/virt/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ PostPatchFn PatchSchedGetaffinity(PrePatchArgs args) {
return PPA_NOTHING;
}
// On success, the syscall returns the size of cpumask_t in bytes.
const int maxSize = MAX(1024, (1 << (ilog2(zinfo->numCores) + 1))) / 8;
int maxSize = -err;
// When the simulated number of cores is greater, extend cpumask_t.
maxSize = MAX(maxSize, (1 << (ilog2(zinfo->numCores - 1) + 1)) / 8);
PIN_SetSyscallNumber(args.ctxt, args.std, maxSize);
uint32_t linuxTid = PIN_GetSyscallArgument(args.ctxt, args.std, 0);
uint32_t tid = (linuxTid == 0 ? args.tid : zinfo->sched->getTidFromLinuxTid(linuxTid));
Expand Down

0 comments on commit 775d84b

Please sign in to comment.