Skip to content

Comments

FreeBSD: Add affinity support to tests#1950

Merged
kboyarinov merged 5 commits intouxlfoundation:masterfrom
martymac:FreeBSD-test-affinity
Jan 26, 2026
Merged

FreeBSD: Add affinity support to tests#1950
kboyarinov merged 5 commits intouxlfoundation:masterfrom
martymac:FreeBSD-test-affinity

Conversation

@martymac
Copy link
Contributor

Fixes test 63:

63 - test_hw_concurrency (Subprocess aborted)

Description

Hi,

Following PR #1945, here is a patch to fix the last failing test (63) by using sched_getaffinity() on FreeBSD.

Best regards,

Ganael Laplanche

Fixes test 63:

63 - test_hw_concurrency (Subprocess aborted)
Copy link
Contributor

@isaevil isaevil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, thanks! Small nitpick from my side though

Comment on lines 96 to 102
#if __linux__
cpu_set_t mask;
sched_getaffinity(0, sizeof(cpu_set_t), &mask);
#else /* __FreeBSD__ */
cpuset_t mask;
sched_getaffinity(0, sizeof(cpuset_t), &mask);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If name of mask type is the only difference, why not wrap only the type?

Suggested change
#if __linux__
cpu_set_t mask;
sched_getaffinity(0, sizeof(cpu_set_t), &mask);
#else /* __FreeBSD__ */
cpuset_t mask;
sched_getaffinity(0, sizeof(cpuset_t), &mask);
#endif
#if __linux__
using cpu_mask_t = cpu_set_t;
#else /* __FreeBSD__ */
using cpu_mask_t = cpuset_t;
#endif
cpu_mask_t mask;
sched_getaffinity(0, sizeof(cpu_mask_t), &mask);

The same is applicable to changes below.

Copy link
Contributor

@kboyarinov kboyarinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving a dispatch outside the functions to avoid code duplications:

martymac and others added 3 commits January 26, 2026 12:13
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
@martymac
Copy link
Contributor Author

Should be good now, thanks to both of you!

Copy link
Contributor

@kboyarinov kboyarinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, except the minor comment

Comment on lines 338 to 339
cpu_set_type mask;
sched_getaffinity(0, sizeof(cpu_set_type), &mask);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please align the indentation

@martymac
Copy link
Contributor Author

Ooops, fixed. Thanks!

Copy link
Contributor

@kboyarinov kboyarinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thank you for your contribution!

@kboyarinov kboyarinov merged commit 8b9ca4d into uxlfoundation:master Jan 26, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants