From nobody Sun Nov 24 05:54:19 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=1724368035; cv=none; d=zohomail.com; s=zohoarc; b=AWleJWVvGvLD7NG0ooVYwCEWgt2S9TjKiqIxA2qtA00kASpUY0qigdjDpMGQ1eF25e1S3VO+IriezQtwwZ6XztowjKM2tqFfqaC3d9NczowHb5pSlqdiM8IWgwfljFUwmLA7k+4dL9/hkSuwvVwCTtsGA+HLpjbNGSGIUtwrGok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724368035; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Hv9HlPwXrRYZdKJJ+1+hjJMFB9PxOUm7mKL1fwt8sqc=; b=aeao6fxm/t6sbBtGpziW9VCO7KAhUC6urdE8zdSeqKA5HOl5rHNd7/DVF36kbwFGCTf/UuJuWRdnc1M3iyVLwFlH7qENv2GJAZjVfI6xIDwkNrE0q3ln9A46PKiwczq4LPd9unV6/dAgyaks+TelOSRg8ZzBokMp7sV9LlEEdAY= 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 1724368035560785.3385454239153; Thu, 22 Aug 2024 16:07:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.782011.1191553 (Exim 4.92) (envelope-from ) id 1shGtJ-0007Bq-JP; Thu, 22 Aug 2024 23:06:53 +0000 Received: by outflank-mailman (output) from mailman id 782011.1191553; Thu, 22 Aug 2024 23:06:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1shGtJ-0007B6-Fd; Thu, 22 Aug 2024 23:06:53 +0000 Received: by outflank-mailman (input) for mailman id 782011; Thu, 22 Aug 2024 23:06:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1shGtH-00052v-SP for xen-devel@lists.xenproject.org; Thu, 22 Aug 2024 23:06:51 +0000 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [2a00:1450:4864:20::12e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3699e577-60db-11ef-8776-851b0ebba9a2; Fri, 23 Aug 2024 01:06:50 +0200 (CEST) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-533462b9428so2424368e87.3 for ; Thu, 22 Aug 2024 16:06:50 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a868f21ff19sm174676866b.39.2024.08.22.16.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 16:06:46 -0700 (PDT) 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: 3699e577-60db-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1724368009; x=1724972809; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Hv9HlPwXrRYZdKJJ+1+hjJMFB9PxOUm7mKL1fwt8sqc=; b=LkHq+bj66eQWwX2bfzMPnXlvAKAFUu3jUVVFazOW9yIp53btyNksaiUTQ+FCBUNB+8 Bu0CBDtqz0qY/inO45Pd4c+F8f0Jn0RiQ76XAEF7dIzRj8C16tDCM6zeu1FwO7OG9O/Z i5mXyA13Kkehef4hC0S5xKA6LNiCj98HfrMwQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724368009; x=1724972809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hv9HlPwXrRYZdKJJ+1+hjJMFB9PxOUm7mKL1fwt8sqc=; b=hyb6h/6ctauQtAulfnXTrRmePhuZx6e5NcWTnMQUs4hGzqrV7gRNfeigU1mzT8riV7 53eSVp2I6Zt2Q8mu0EgBtm6lbYt7j0rmubLKYPO7pIhgLmh3g0sr11ThO49MY+gOpXY2 mHJZYftURAVO5AmPqIlGL7uH4wreYfAoE9CaCK+TdUpGUBLNu7D3jZgiSi3cPK217t3H 3hQMPdpGfltpRpm6gBfw1GHLO2L6jUXOSO3sEoCARzCYZaT90xqfHxcg+g/Gg8uwGC4r nPdZbnFu8B51xk5Kt07w2QX3FId01hWUImaQleclgDHYmfckzR67uhAE3CXiRqBdVbZd +upQ== X-Gm-Message-State: AOJu0YzxZwpF8TaIFxyTxGtsCzcWQwfwrRzLLYbf0xxr51WWqUxinlWv SXEYGwbeUrirXtZcBCOg4ut3vQAZYBEyH3mqX6PJ06kSnoFWLfiD/bH9NtPRLRXukodIkNwrqpZ 9 X-Google-Smtp-Source: AGHT+IE7t0IfrG/EKoPzKoWKQ7aMXt59Dnlv0A5uSbNgbXpz8Nz7/5pY6zVU/KKdUSpN6o8Cct/2wA== X-Received: by 2002:a05:6512:114b:b0:52e:9808:3f48 with SMTP id 2adb3069b0e04-5343884701cmr433413e87.21.1724368008957; Thu, 22 Aug 2024 16:06:48 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko , Shawn Anastasio Subject: [PATCH 8/9] xen/bitops: Implement hweight32() in terms of hweightl() Date: Fri, 23 Aug 2024 00:06:34 +0100 Message-Id: <20240822230635.954557-9-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240822230635.954557-1-andrew.cooper3@citrix.com> References: <20240822230635.954557-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1724368037562116600 ... and drop generic_hweight32(). As noted previously, the only two users of hweight32() and they're both singleton callers in __init paths, so it's not interesting to have a sub-GPR optimised generic. No functional change. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko CC: Shawn Anastasio --- xen/arch/arm/include/asm/bitops.h | 8 -------- xen/arch/ppc/include/asm/bitops.h | 8 -------- xen/arch/x86/include/asm/bitops.h | 8 -------- xen/include/xen/bitops.h | 24 +++++------------------- 4 files changed, 5 insertions(+), 43 deletions(-) diff --git a/xen/arch/arm/include/asm/bitops.h b/xen/arch/arm/include/asm/b= itops.h index bed6b3b98e08..f163d9bb4578 100644 --- a/xen/arch/arm/include/asm/bitops.h +++ b/xen/arch/arm/include/asm/bitops.h @@ -78,14 +78,6 @@ bool clear_mask16_timeout(uint16_t mask, volatile void *= p, #define arch_fls(x) ((x) ? 32 - __builtin_clz(x) : 0) #define arch_flsl(x) ((x) ? BITS_PER_LONG - __builtin_clzl(x) : 0) =20 -/** - * hweightN - returns the hamming weight of a N-bit word - * @x: the word to weigh - * - * The Hamming Weight of a number is the total number of bits set in it. - */ -#define hweight32(x) generic_hweight32(x) - #endif /* _ARM_BITOPS_H */ /* * Local variables: diff --git a/xen/arch/ppc/include/asm/bitops.h b/xen/arch/ppc/include/asm/b= itops.h index 24dc35ef644d..c942e9432e20 100644 --- a/xen/arch/ppc/include/asm/bitops.h +++ b/xen/arch/ppc/include/asm/bitops.h @@ -126,12 +126,4 @@ static inline int test_and_set_bit(unsigned int nr, vo= latile void *addr) =20 #define arch_hweightl(x) __builtin_popcountl(x) =20 -/** - * hweightN - returns the hamming weight of a N-bit word - * @x: the word to weigh - * - * The Hamming Weight of a number is the total number of bits set in it. - */ -#define hweight32(x) __builtin_popcount(x) - #endif /* _ASM_PPC_BITOPS_H */ diff --git a/xen/arch/x86/include/asm/bitops.h b/xen/arch/x86/include/asm/b= itops.h index 9d3a2448036e..642d8e58b288 100644 --- a/xen/arch/x86/include/asm/bitops.h +++ b/xen/arch/x86/include/asm/bitops.h @@ -475,12 +475,4 @@ static always_inline unsigned int arch_flsl(unsigned l= ong x) } #define arch_flsl arch_flsl =20 -/** - * hweightN - returns the hamming weight of a N-bit word - * @x: the word to weigh - * - * The Hamming Weight of a number is the total number of bits set in it. - */ -#define hweight32(x) generic_hweight32(x) - #endif /* _X86_BITOPS_H */ diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index e97516552a2e..bad2601b0fe6 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -302,6 +302,11 @@ static always_inline __pure unsigned int hweightl(unsi= gned long x) #endif } =20 +static always_inline __pure unsigned int hweight32(uint32_t x) +{ + return hweightl(x); +} + static always_inline __pure unsigned int hweight64(uint64_t x) { if ( BITS_PER_LONG =3D=3D 64 ) @@ -378,25 +383,6 @@ static inline int get_count_order(unsigned int count) return order; } =20 -/* - * hweightN: returns the hamming weight (i.e. the number - * of bits set) of a N-bit word - */ - -static inline unsigned int generic_hweight32(unsigned int w) -{ - w -=3D (w >> 1) & 0x55555555; - w =3D (w & 0x33333333) + ((w >> 2) & 0x33333333); - w =3D (w + (w >> 4)) & 0x0f0f0f0f; - - if ( IS_ENABLED(CONFIG_HAS_FAST_MULTIPLY) ) - return (w * 0x01010101) >> 24; - - w +=3D w >> 8; - - return (w + (w >> 16)) & 0xff; -} - /* * rol32 - rotate a 32-bit value left * --=20 2.39.2