From nobody Fri Apr 26 14:16:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562672069; cv=none; d=zoho.com; s=zohoarc; b=fM8L/+x89WW80AOIR1V+5/fr3a0k5f9Qd/GtMASH7F1UL3GXNMchWRcErcIC6SmgY5JHu9w8p2PwBrdGwxVX8jzjWtgRA8xRp+l4O8sBKdFNi+0eeRvy/0OeFpktSTkiUecgAo8T7/in5uP8vp+HtcMxsFZ4Ygw2A40tfahQUmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562672069; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=QkqY/My26LZIlVRXFntqVRFY2eNIvM1qT2lIIvL5h40=; b=czAL2qv6IOZ77gGaNR8gGpSG3mDn/3sChYZaq91MVQ1x7SFhbJ7hPdfE+6iAgp506fmbornF9FOU0E+r3LrHv5iofA6LjwB5mnsxY9VUCsKEVvo9D1f/N2IpphUUSt1vJs7CRryrsc3BnonEmjXWF8f+eUDpzCftGlT3ryWfZ8s= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562672069204315.3773680251594; Tue, 9 Jul 2019 04:34:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA415309264F; Tue, 9 Jul 2019 11:34:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DDA93196EE; Tue, 9 Jul 2019 11:34:11 +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 0495E206D2; Tue, 9 Jul 2019 11:34:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x69BY1uF013643 for ; Tue, 9 Jul 2019 07:34:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC2B6831A4; Tue, 9 Jul 2019 11:34:01 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-31.ams2.redhat.com [10.36.112.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id A19D2831A0; Tue, 9 Jul 2019 11:33:55 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 9 Jul 2019 12:33:54 +0100 Message-Id: <20190709113354.9304-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] util: assume modern CPU_ALLOC macros always exist 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 09 Jul 2019 11:34:27 +0000 (UTC) Support for the modern CPU_ALLOC macros was added 10 years ago in commit a73cd93b2428adbbc62bb919b6cf5ffd27728040 Author: Daniel P. Berrange Date: Mon Nov 16 16:08:29 2009 +0000 Alternate CPU affinity impl to cope with NR_CPUS > 1024 This is long enough that we can assume it always exists and drop the back compat code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Martin Kletzander --- src/util/virprocess.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index f2533f639f..66834d37d3 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -422,8 +422,6 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map) { size_t i; VIR_DEBUG("Set process affinity on %lld", (long long)pid); -# ifdef CPU_ALLOC - /* New method dynamically allocates cpu mask, allowing unlimted cpus */ int numcpus =3D 1024; size_t masklen; cpu_set_t *mask; @@ -462,22 +460,6 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map) return -1; } CPU_FREE(mask); -# else - /* Legacy method uses a fixed size cpu mask, only allows up to 1024 cp= us */ - cpu_set_t mask; - - CPU_ZERO(&mask); - for (i =3D 0; i < virBitmapSize(map); i++) { - if (virBitmapIsBitSet(map, i)) - CPU_SET(i, &mask); - } - - if (sched_setaffinity(pid, sizeof(mask), &mask) < 0) { - virReportSystemError(errno, - _("cannot set CPU affinity on process %d"), p= id); - return -1; - } -# endif =20 return 0; } @@ -491,7 +473,6 @@ virProcessGetAffinity(pid_t pid) size_t ncpus; virBitmapPtr ret =3D NULL; =20 -# ifdef CPU_ALLOC /* 262144 cpus ought to be enough for anyone */ ncpus =3D 1024 << 8; masklen =3D CPU_ALLOC_SIZE(ncpus); @@ -503,14 +484,6 @@ virProcessGetAffinity(pid_t pid) } =20 CPU_ZERO_S(masklen, mask); -# else - ncpus =3D 1024; - if (VIR_ALLOC(mask) < 0) - return NULL; - - masklen =3D sizeof(*mask); - CPU_ZERO(mask); -# endif =20 if (sched_getaffinity(pid, masklen, mask) < 0) { virReportSystemError(errno, @@ -522,22 +495,13 @@ virProcessGetAffinity(pid_t pid) goto cleanup; =20 for (i =3D 0; i < ncpus; i++) { -# ifdef CPU_ALLOC /* coverity[overrun-local] */ if (CPU_ISSET_S(i, masklen, mask)) ignore_value(virBitmapSetBit(ret, i)); -# else - if (CPU_ISSET(i, mask)) - ignore_value(virBitmapSetBit(ret, i)); -# endif } =20 cleanup: -# ifdef CPU_ALLOC CPU_FREE(mask); -# else - VIR_FREE(mask); -# endif =20 return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list