From nobody Fri May 17 11:05:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1706888320; cv=none; d=zohomail.com; s=zohoarc; b=lQ1RwDhNtaBtilqjDd3FvqO5xdhDKv8bwdd2ocSHncAZr1Y0elYDWbngV2LI1eWU4m92dY2DQFsRlMtQ+CjqSZtY9z55VtpNk7PdM+ciKvjnQEMyiJ9xyXJEi8y9/7A3eb+NiBXv8Umi5ls+UomG1xPFUrIpe/v96Ukmz3mmI3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706888320; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hpMzOIqZKWVm1pXLHi8lKIHS6AP3wGi+MQkb7Zs99jY=; b=TzcAsZRRNE7xdjlTpn33TxtAH6/nRjQ5DAu4PakzqIeSE6AP7AcfbzEXxwU1BKwCOPdxofxFoLxVb7JQDig3gja60TYh3nd9eUhrlF0I7vcekc9PdVFah1/fLqH7acu7s1ktezYL9ROSRQxYskbshAV/IupjrCUodt5kse9XDFg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1706888320550839.9380204156813; Fri, 2 Feb 2024 07:38:40 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.675120.1050329 (Exim 4.92) (envelope-from ) id 1rVvcT-0005uu-28; Fri, 02 Feb 2024 15:38:21 +0000 Received: by outflank-mailman (output) from mailman id 675120.1050329; Fri, 02 Feb 2024 15:38:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rVvcS-0005un-Vl; Fri, 02 Feb 2024 15:38:20 +0000 Received: by outflank-mailman (input) for mailman id 675120; Fri, 02 Feb 2024 15:38:20 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rVvcS-0005uf-8k for xen-devel@lists.xenproject.org; Fri, 02 Feb 2024 15:38:20 +0000 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [2a00:1450:4864:20::62d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 17045854-c1e1-11ee-8a43-1f161083a0e0; Fri, 02 Feb 2024 16:38:19 +0100 (CET) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a36597a3104so309152966b.2 for ; Fri, 02 Feb 2024 07:38:19 -0800 (PST) Received: from andrewcoop.citrite.net (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id tk12-20020a170907c28c00b00a30e1f233b4sm981843ejc.128.2024.02.02.07.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:38:17 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 17045854-c1e1-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1706888298; x=1707493098; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hpMzOIqZKWVm1pXLHi8lKIHS6AP3wGi+MQkb7Zs99jY=; b=kZOrhHHB3I6hkbaymuFvYbjjRdX/ubra9jndzYT1fqPjhhkz2fThHd4/hvQqBmh+b5 4w0YiGzsaNEmkgV4bY2bWQwzh0z1/R+9PRwyUFWmY0BUJejw74qvmFz1jwVRvxIkrG3a U6beDf22yNgUADvZtHMcGXjHGgHwZZAWjzGtU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706888298; x=1707493098; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hpMzOIqZKWVm1pXLHi8lKIHS6AP3wGi+MQkb7Zs99jY=; b=J8Pb6llKC3xbbO3WG2VaOI0bjrbcM0BQweQCPWnQLEnAVNv9J+4d0xgD1B37TB5NlP dfaoedHUlD5p/xEXFb0tcCsZuveK6FmqenK71tZLmfa8AWOzFd1rDowshPW8PI+9++kk CGL/mX5tOC8kk/wRKyGHfqns2lzHgTuBCu8PTwWWMuLriN1vHJZYlJn7mJuDMLrzuARZ qM3A2or6NkKSuiTfZmRzGLcOv2tBJ/pHdqfGLMMvp0KkRTfSQPGM+sjGFlqsIPqb3GT+ C0Bbb5bzIJRvlfElqrjvDVrj25qOi9ZeOdsEmw910QNpF9/4UGd9T78qDMoO9psY1x3f lyQw== X-Gm-Message-State: AOJu0Ywz171418A4ovhPBi3jnGAAEVxjwC8Suyrv7+l++L7mrvf1daM6 DS8uiu/kFCm0a2sisrLVlZN9BtdC7iew1+NhIT5aS90CCWnvXrVpScjEx8AgAkKuoRjC1GVjWJT O X-Google-Smtp-Source: AGHT+IGfJf/bSI18m/zGA4x9m8BNqem86Eib2UTZhpa41sPerYxWf8XUt6RUvwl6OA1BynUD8pxhsQ== X-Received: by 2002:a17:906:58f:b0:a36:4908:1dcc with SMTP id 15-20020a170906058f00b00a3649081dccmr1776938ejn.29.1706888298225; Fri, 02 Feb 2024 07:38:18 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVvOIdB/Dz2ctg2y8kd2leNIHcHpFkI8VHvTWsnsonzPoGU3MT7CSbEP9TuxIGgCAuhUUGvD2I6dT9vrHSsfHnSYtEEvYnHwCIM0e9EreYFjkoxJ+xXz9yPxdwuPcPF7JkC+urpRMlMo+jj0hxsQLlQ96XPJByMeD4kXhaxeXjvVVi1kBblU+34NhJ3p/C5rQ== From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , George Dunlap , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall Subject: [PATCH] xen/bitmap: Deduplicate __bitmap_weight() implementations Date: Fri, 2 Feb 2024 15:38:16 +0000 Message-Id: <20240202153816.772594-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1706888322107100033 Content-Type: text/plain; charset="utf-8" We have two copies of __bitmap_weight() that differ by whether they make hweight32() or hweight64() calls, yet we already have hweight_long() which = is the form that __bitmap_weight() wants. Fix hweight_long() to return unsigned int like all the other hweight helper= s, and fix __bitmap_weight() to used unsigned integers. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall --- xen/common/bitmap.c | 21 +++------------------ xen/include/xen/bitops.h | 2 +- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c index c57b35f0042c..9d9ff09f3dde 100644 --- a/xen/common/bitmap.c +++ b/xen/common/bitmap.c @@ -186,33 +186,18 @@ int __bitmap_subset(const unsigned long *bitmap1, } EXPORT_SYMBOL(__bitmap_subset); =20 -#if BITS_PER_LONG =3D=3D 32 unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int bit= s) { - int k, w =3D 0, lim =3D bits/BITS_PER_LONG; + unsigned int k, w =3D 0, lim =3D bits / BITS_PER_LONG; =20 for (k =3D 0; k < lim; k++) - w +=3D hweight32(bitmap[k]); + w +=3D hweight_long(bitmap[k]); =20 if (bits % BITS_PER_LONG) - w +=3D hweight32(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); + w +=3D hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); =20 return w; } -#else -unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int bit= s) -{ - int k, w =3D 0, lim =3D bits/BITS_PER_LONG; - - for (k =3D 0; k < lim; k++) - w +=3D hweight64(bitmap[k]); - - if (bits % BITS_PER_LONG) - w +=3D hweight64(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); - - return w; -} -#endif EXPORT_SYMBOL(__bitmap_weight); =20 void __bitmap_set(unsigned long *map, unsigned int start, int len) diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index a88d45475c40..2cb7892bcca0 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -199,7 +199,7 @@ static inline unsigned int generic_hweight64(uint64_t w) return (w + (w >> 32)) & 0xFF; } =20 -static inline unsigned long hweight_long(unsigned long w) +static inline unsigned int hweight_long(unsigned long w) { return sizeof(w) =3D=3D 4 ? generic_hweight32(w) : generic_hweight64(w= ); } --=20 2.30.2