From nobody Thu May 9 13:08:27 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709058825686206.2424960933463; Tue, 27 Feb 2024 10:33:45 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 93DF21E58; Tue, 27 Feb 2024 13:33:44 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9EC8E1C09; Tue, 27 Feb 2024 13:30:22 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 44E341B22; Tue, 27 Feb 2024 13:30:14 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 91C8B1B01 for ; Tue, 27 Feb 2024 13:30:13 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-483-VI9RUTI8NLWl-ctmJL8zuw-1; Tue, 27 Feb 2024 13:30:09 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F4A888D283; Tue, 27 Feb 2024 18:30:09 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.225.89]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB48F39D7C; Tue, 27 Feb 2024 18:30:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: VI9RUTI8NLWl-ctmJL8zuw-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 1/2] meson: Restore check for sched_getaffinity() Date: Tue, 27 Feb 2024 19:30:05 +0100 Message-ID: <20240227183006.638380-2-abologna@redhat.com> In-Reply-To: <20240227183006.638380-1-abologna@redhat.com> References: <20240227183006.638380-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: SKJ2APPUTJEDDQZRMDNMUE2IX6QMJYCG X-Message-ID-Hash: SKJ2APPUTJEDDQZRMDNMUE2IX6QMJYCG X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Roman Bogorodskiy X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709058826471100001 Commit c07cf0a68693 replaced this check with one for the presence of cpu_set_t. The idea at the time was that only sched_{get,set}affinity() were visible by default, while making cpu_set_t visible required defining _WITH_CPU_SET_T. So libvirt would detect the function and attempt to use it, but the code would not compile because the necessary data type had not been made accessible. The commit in question brought three FreeBSD commits as evidence of this. While [1] and [2] do indeed seem to support this explanation, [3] from just a few days later made it so that not just cpu_set_t, but also the functions, required user action to be visible. This arguably would have made the change unnecessary. However, [4] from roughly a month later changed things once again: it completely removed _WITH_CPU_SET_T, making both the functions and the data type visible by default. This is the status quo that seems to have persisted until today. If one were to check any recent FreeBSD build job performed as part of our CI pipeline, for example [5] and [6] for FreeBSD 13 and 14 respectively, they would be able to confirm that in both cases cpu_set_t is detected as available. Since there is no longer a difference between the availability of the functions and that of the data type, go back to what we had before. This has the interesting side-effect of fixing a bug introduced by the commit in question. When detection was changed from the function to the data type, most uses of WITH_SCHED_GETAFFINITY were replaced with uses of WITH_DECL_CPU_SET_T, but not all of them: specifically, those that decided whether qemuProcessInitCpuAffinity() would be actually implemented or replaced with a no-op stub were not updated, which means that we've been running the stub version everywhere except on FreeBSD ever since. The code has been copied to the Cloud Hypervisor driver in the meantime, which is similarly affected. Now that we're building the actual implementation, we need to add virnuma.h to the includes. As a nice bonus this also makes things work correctly on GNU/Hurd, where cpu_set_t is available but sched_{get,set}affinity() are non-working stubs. [1] https://cgit.freebsd.org/src/commit/?id=3D160b4b922b6021848b6b48afc894d= 16b879b7af2 [2] https://cgit.freebsd.org/src/commit/?id=3D43736b71dd051212d5c55be9fa21c= 45993017fbb [3] https://cgit.freebsd.org/src/commit/?id=3D90fa9705d5cd29cf11c5dc7319299= 788dec2546a [4] https://cgit.freebsd.org/src/commit/?id=3D5e04571cf3cf4024be926976a6abf= 19626df30be [5] https://gitlab.com/libvirt/libvirt/-/jobs/6266401204 [6] https://gitlab.com/libvirt/libvirt/-/jobs/6266401205 Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- meson.build | 3 +-- src/ch/ch_process.c | 1 + src/util/virprocess.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 7845f60ff7..a80a65e447 100644 --- a/meson.build +++ b/meson.build @@ -584,6 +584,7 @@ functions =3D [ 'posix_fallocate', 'posix_memalign', 'prlimit', + 'sched_getaffinity', 'sched_setscheduler', 'setgroups', 'setrlimit', @@ -669,8 +670,6 @@ 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/ch/ch_process.c b/src/ch/ch_process.c index 3bde9d9dcf..a0aca88928 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -33,6 +33,7 @@ #include "virfile.h" #include "virjson.h" #include "virlog.h" +#include "virnuma.h" #include "virstring.h" #include "ch_interface.h" =20 diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 647f687cb8..8e4440b45f 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -500,7 +500,7 @@ virProcessGetAffinity(pid_t pid) return ret; } =20 -#elif WITH_DECL_CPU_SET_T +#elif defined(WITH_SCHED_GETAFFINITY) =20 int virProcessSetAffinity(pid_t pid, virBitmap *map, bool quiet) { @@ -592,7 +592,7 @@ virProcessGetAffinity(pid_t pid) return ret; } =20 -#else /* WITH_DECL_CPU_SET_T */ +#else /* ! (defined(WITH_BSD_CPU_AFFINITY) || defined(WITH_SCHED_GETAFFINI= TY)) */ =20 int virProcessSetAffinity(pid_t pid G_GNUC_UNUSED, virBitmap *map G_GNUC_UNUSED, @@ -612,7 +612,7 @@ virProcessGetAffinity(pid_t pid G_GNUC_UNUSED) _("Process CPU affinity is not supported on this = platform")); return NULL; } -#endif /* WITH_DECL_CPU_SET_T */ +#endif /* ! (defined(WITH_BSD_CPU_AFFINITY) || defined(WITH_SCHED_GETAFFIN= ITY)) */ =20 =20 int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids) --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 13:08:27 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709058906647338.0783072831392; Tue, 27 Feb 2024 10:35:06 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 941471816; Tue, 27 Feb 2024 13:35:05 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EA2451E17; Tue, 27 Feb 2024 13:30:27 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C22E11B09; Tue, 27 Feb 2024 13:30:14 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 232891AFC for ; Tue, 27 Feb 2024 13:30:14 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615--BQv5LlJNb2HNaT8koNXOQ-1; Tue, 27 Feb 2024 13:30:11 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 844D63C025B3; Tue, 27 Feb 2024 18:30:10 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.225.89]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4AB01BDB1; Tue, 27 Feb 2024 18:30:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: -BQv5LlJNb2HNaT8koNXOQ-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 2/2] meson: Check for sched_get_priority_min() Date: Tue, 27 Feb 2024 19:30:06 +0100 Message-ID: <20240227183006.638380-3-abologna@redhat.com> In-Reply-To: <20240227183006.638380-1-abologna@redhat.com> References: <20240227183006.638380-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: X6RSVJTTSVUNW2ZESE7GZON5FY6CRSOH X-Message-ID-Hash: X6RSVJTTSVUNW2ZESE7GZON5FY6CRSOH X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Roman Bogorodskiy X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709058908726100001 virProcessSetScheduler() uses not just sched_setscheduler() but also sched_get_priority_{min,max}(). Currently we assume that the former being available implies that the latter are as well, but that's not the case for at least GNU/Hurd. Make sure all functions are actually available before attempting to use them. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- meson.build | 1 + src/util/virprocess.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index a80a65e447..7f68c9da89 100644 --- a/meson.build +++ b/meson.build @@ -584,6 +584,7 @@ functions =3D [ 'posix_fallocate', 'posix_memalign', 'prlimit', + 'sched_get_priority_min', 'sched_getaffinity', 'sched_setscheduler', 'setgroups', diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 8e4440b45f..5cdf3e3eb9 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1573,7 +1573,7 @@ virProcessExitWithStatus(int status) exit(value); } =20 -#if WITH_SCHED_SETSCHEDULER +#if defined(WITH_SCHED_SETSCHEDULER) && defined(WITH_SCHED_GET_PRIORITY_MI= N) =20 static int virProcessSchedTranslatePolicy(virProcessSchedPolicy policy) @@ -1667,7 +1667,7 @@ virProcessSetScheduler(pid_t pid, return 0; } =20 -#else /* ! WITH_SCHED_SETSCHEDULER */ +#else /* ! (defined(WITH_SCHED_SETSCHEDULER) && defined(WITH_SCHED_GET_PRI= ORITY_MIN)) */ =20 int virProcessSetScheduler(pid_t pid G_GNUC_UNUSED, @@ -1682,7 +1682,7 @@ virProcessSetScheduler(pid_t pid G_GNUC_UNUSED, return -1; } =20 -#endif /* !WITH_SCHED_SETSCHEDULER */ +#endif /* ! (defined(WITH_SCHED_SETSCHEDULER) && defined(WITH_SCHED_GET_PR= IORITY_MIN)) */ =20 /* * Get all stat fields for a process based on pid and tid: --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org