From nobody Fri Apr 26 06:16:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1637510377662413.22295188624344; Sun, 21 Nov 2021 07:59:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-597-s890l5NyNd-cMO99I1p5dg-1; Sun, 21 Nov 2021 10:59:34 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 619991006AA0; Sun, 21 Nov 2021 15:59:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E444779446; Sun, 21 Nov 2021 15:59:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DEC011832E7F; Sun, 21 Nov 2021 15:59:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ALFxMEA009171 for ; Sun, 21 Nov 2021 10:59:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4F6BB1121318; Sun, 21 Nov 2021 15:59:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AC4F1121315 for ; Sun, 21 Nov 2021 15:59:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7CEDD185A7B2 for ; Sun, 21 Nov 2021 15:59:19 +0000 (UTC) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-506-8aqgK_NMNrm5lLxDwO5hzA-1; Sun, 21 Nov 2021 10:59:17 -0500 Received: by mail-lf1-f49.google.com with SMTP id t26so68453715lfk.9 for ; Sun, 21 Nov 2021 07:59:17 -0800 (PST) Received: from kloomba.my.domain ([5.227.204.99]) by smtp.gmail.com with ESMTPSA id f10sm679300lfg.211.2021.11.21.07.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 07:59:15 -0800 (PST) X-MC-Unique: s890l5NyNd-cMO99I1p5dg-1 X-MC-Unique: 8aqgK_NMNrm5lLxDwO5hzA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Cg4ksVEojU9ErxY4MPC/LrKxv82Ig1PxciHRTHnw880=; b=ztf5kl/410m6iiJq586p9YV5QIbjrFe55MNQhC7/3Unn5DYUxUc//551n6jkXZRBuR 4uuIgYeHV9wgpq2kgfa4XkVIrDSn83O3/jU6Tf8kFHvDHpvgBk53TkyHQOWJcRoIpaAb gjCOy6jDAvInXqjAIZSC1M6eZGEkbsxGOO2ggIC5/nmaHtNTviLbC6uZYqhBQRTDOUZl UMOITor0GrD8+nrZAIQXXfnwkH4p/jF3cNO1ONGZO4z5DkavlhhHIMr1Yvcw0Mr/MNcV ObtHdnTnw1FmPj+GR2KdBF/xdtAHGwugyQkHy4Gp7TyCsomn+qmvxJSdxzlPmKBqZYQj Vclg== X-Gm-Message-State: AOAM5300hxvLibBNJt1XmuEVmv+jRtBYGEVL2fJZV4QlMYoACoirR8Fp spI9rhQIgPs6UM33yv1SXdzfnMWAfz+hEa8JOEY= X-Google-Smtp-Source: ABdhPJxmnBbdU73O00UoLZbPZY89w2JY9ZYGuxjB0EeGIC0qxMdf71bnEJxciFa204IKtz26ZjJ+lQ== X-Received: by 2002:a05:6512:1189:: with SMTP id g9mr49583684lfr.396.1637510355693; Sun, 21 Nov 2021 07:59:15 -0800 (PST) From: Roman Bogorodskiy To: libvir-list@redhat.com Subject: [PATCH] meson: improve CPU affinity routines check Date: Sun, 21 Nov 2021 19:58:55 +0400 Message-Id: <20211121155855.15213-1-bogorodskiy@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Roman Bogorodskiy X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1637510380336100001 Content-Type: text/plain; charset="utf-8" Recently, FreeBSD has got sched_get/setaffinity(3) implementations and the sched.h header as well [1]. To make these routines visible, users have to define _WITH_CPU_SET_T. This breaks current detection. Specifically, meson sees the sched_getaffinity() symbol and defines WITH_SCHED_GETAFFINITY. This define unlocks Linux implementation of virProcessSetAffinity() and other functions, which fails to build on FreeBSD because cpu_set_t is not visible as _WITH_CPU_SET_T is not defined. For now, change detection to the following: - Instead of checking sched_getaffinity(), check if 'cpu_set_t' is available through sched.h - Explicitly check the sched.h header instead of assuming its presence if WITH_SCHED_SETSCHEDULER is defined 1: https://cgit.freebsd.org/src/commit/?id=3D43736b71dd051212d5c55be9fa21c4599= 3017fbb https://cgit.freebsd.org/src/commit/?id=3D160b4b922b6021848b6b48afc894d16b8= 79b7af2 https://cgit.freebsd.org/src/commit/?id=3D90fa9705d5cd29cf11c5dc7319299788d= ec2546a Signed-off-by: Roman Bogorodskiy Reviewed-by: Martin Kletzander --- meson.build | 4 +++- src/util/virprocess.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 9022bcfdc9..e4f36e8574 100644 --- a/meson.build +++ b/meson.build @@ -553,7 +553,6 @@ functions =3D [ 'posix_fallocate', 'posix_memalign', 'prlimit', - 'sched_getaffinity', 'sched_setscheduler', 'setgroups', 'setns', @@ -602,6 +601,7 @@ headers =3D [ 'net/if.h', 'pty.h', 'pwd.h', + 'sched.h', 'sys/auxv.h', 'sys/ioctl.h', 'sys/mount.h', @@ -671,6 +671,8 @@ symbols =3D [ =20 # Check for BSD approach for setting MAC addr [ 'net/if_dl.h', 'link_addr', '#include \n#include ' ], + + [ 'sched.h', 'cpu_set_t' ], ] =20 if host_machine.system() =3D=3D 'linux' diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 6de3f36f52..81de90200e 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -35,7 +35,7 @@ # include # include #endif -#if WITH_SCHED_SETSCHEDULER +#if WITH_SCHED_H # include #endif =20 @@ -480,7 +480,7 @@ int virProcessKillPainfully(pid_t pid, bool force) return virProcessKillPainfullyDelay(pid, force, 0, false); } =20 -#if WITH_SCHED_GETAFFINITY +#if WITH_DECL_CPU_SET_T =20 int virProcessSetAffinity(pid_t pid, virBitmap *map, bool quiet) { @@ -626,7 +626,7 @@ virProcessGetAffinity(pid_t pid) return ret; } =20 -#else /* WITH_SCHED_GETAFFINITY */ +#else /* WITH_DECL_CPU_SET_T */ =20 int virProcessSetAffinity(pid_t pid G_GNUC_UNUSED, virBitmap *map G_GNUC_UNUSED, @@ -646,7 +646,7 @@ virProcessGetAffinity(pid_t pid G_GNUC_UNUSED) _("Process CPU affinity is not supported on this = platform")); return NULL; } -#endif /* WITH_SCHED_GETAFFINITY */ +#endif /* WITH_DECL_CPU_SET_T */ =20 =20 int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids) --=20 2.33.1