[PATCH 0/3] util: Fix setting process affinity on BSD

Andrea Bolognani posted 3 patches 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20240223010541.211981-1-abologna@redhat.com
src/util/virprocess.c | 112 +++++++++++++++++++++---------------------
1 file changed, 57 insertions(+), 55 deletions(-)
[PATCH 0/3] util: Fix setting process affinity on BSD
Posted by Andrea Bolognani 2 months ago
Commit c07cf0a68693 tried to ensure that the Linux-compatible
syscalls would not be used on FreeBSD, but something must have
changed between then and now because I can clearly see
sched_{get,set}affinity() being used instead of their cpuset_*
counterparts on FreeBSD 14.

Ensure that the BSD variants are always preferred.

Before that, fix them so that they accept either a PID or a TID.
The fact that this wasn't the case until now makes me suspect
that scenarios in which thread-level affinity is applied have
not been tested at all on the platform, because doing something
as simple as

  <vcpu placement='static' cpuset='1-2'>1</vcpu>

is enough to prevent the VM from starting, and before FreeBSD
14 the Linux compatibility APIs shouldn't have been part of the
picture at all.

Andrea Bolognani (3):
  util: Accept TIDs for virProcess{Get,Set}Affinity() on BSD
  util: Prefer cpuset_{get,set}affinity() on BSD
  util: Add debug print missing from BSD

 src/util/virprocess.c | 112 +++++++++++++++++++++---------------------
 1 file changed, 57 insertions(+), 55 deletions(-)

-- 
2.43.2
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH 0/3] util: Fix setting process affinity on BSD
Posted by Martin Kletzander 2 months ago
On Fri, Feb 23, 2024 at 02:05:38AM +0100, Andrea Bolognani wrote:
>Commit c07cf0a68693 tried to ensure that the Linux-compatible
>syscalls would not be used on FreeBSD, but something must have
>changed between then and now because I can clearly see
>sched_{get,set}affinity() being used instead of their cpuset_*
>counterparts on FreeBSD 14.
>

At first I thought this is because back then FreeBSD did not yet have
sched_setaffinity in the linux ABI, but that was added in 7.1, so that's
probably not it.  I did not dig into it more since this change makes
sense regardless.

>Ensure that the BSD variants are always preferred.
>
>Before that, fix them so that they accept either a PID or a TID.
>The fact that this wasn't the case until now makes me suspect
>that scenarios in which thread-level affinity is applied have
>not been tested at all on the platform, because doing something
>as simple as
>
>  <vcpu placement='static' cpuset='1-2'>1</vcpu>
>
>is enough to prevent the VM from starting, and before FreeBSD
>14 the Linux compatibility APIs shouldn't have been part of the
>picture at all.
>
>Andrea Bolognani (3):
>  util: Accept TIDs for virProcess{Get,Set}Affinity() on BSD
>  util: Prefer cpuset_{get,set}affinity() on BSD
>  util: Add debug print missing from BSD
>

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

> src/util/virprocess.c | 112 +++++++++++++++++++++---------------------
> 1 file changed, 57 insertions(+), 55 deletions(-)
>
>-- 
>2.43.2
>_______________________________________________
>Devel mailing list -- devel@lists.libvirt.org
>To unsubscribe send an email to devel-leave@lists.libvirt.org
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org