Skip to content

Commit

Permalink
Ignore KERN_NOT_SUPPORTED from thread_policy_set on mach
Browse files Browse the repository at this point in the history
The `thread_policy_set` call in `aff_iterate` fails with
`KERN_NOT_SUPPORTED` on M1 macbooks. The reported error from the
regression tests is "Success" because `thread_policy_set` doesn't set
errno.

This patch converts `KERN_NOT_SUPPORTED` into a successful return and
sets errno to `EINVAL` on other errors.  This is ok in the regression
tests as there affinity binding is only advisory.

Fixes concurrencykit#186
  • Loading branch information
jpihlaja-bt authored and pkhuong committed Feb 10, 2022
1 parent 3dcb597 commit d6dd637
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion regressions/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,19 @@ aff_iterate(struct affinity *acb)
{
thread_affinity_policy_data_t policy;
unsigned int c;
int err;

c = ck_pr_faa_uint(&acb->request, acb->delta) % CORES;
policy.affinity_tag = c;
return thread_policy_set(mach_thread_self(),
err = thread_policy_set(mach_thread_self(),
THREAD_AFFINITY_POLICY,
(thread_policy_t)&policy,
THREAD_AFFINITY_POLICY_COUNT);
if (err == KERN_NOT_SUPPORTED)
return 0;
if (err != 0)
errno = EINVAL;
return err;
}

CK_CC_UNUSED static int
Expand Down

0 comments on commit d6dd637

Please sign in to comment.