From nobody Tue Dec 3 17:26:46 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=1725490558; cv=none; d=zohomail.com; s=zohoarc; b=M+AHMqRoXmLpQGSOSKdw7cx1AV6/YiV+2//+G6alJZ/q6U1Fdd/TRilo6K+KQ7y5ThQK3s2OYJkpvl0g6cOo6Ph9RQXK6mDbx6hfo8S7SIQ57o4hciKsxZOOKyA7xfE0zlB78jJ882egm5cRehQOTiESz2f2etuHTG0WqvgtMQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725490558; 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=ER/nzcDu3sjSk/1iNkdxnTJbzqcB3fMPz6UFD3Jo2ug=; b=MGx9UetZhDSyLlQp8JBWeocmf/JULnGyWP6BMWmR4Wk7oq77mjW3h8H2j11O0a3Zm2AAsYEMbzonOrEl+YqAjS8D8ApMEYSv3ev7oa2bVg6BSE+YZBRxGJjClLyOq/si/g3dtJkeoeFKTNE4aVK4WHrQWiPlQLkB5p/PIq5/1HE= 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 1725490558369602.3440942001675; Wed, 4 Sep 2024 15:55:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790819.1200600 (Exim 4.92) (envelope-from ) id 1slyua-0001kI-IF; Wed, 04 Sep 2024 22:55:40 +0000 Received: by outflank-mailman (output) from mailman id 790819.1200600; Wed, 04 Sep 2024 22:55:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slyua-0001k9-C6; Wed, 04 Sep 2024 22:55:40 +0000 Received: by outflank-mailman (input) for mailman id 790819; Wed, 04 Sep 2024 22:55:38 +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 1slyuY-0001Vf-Rg for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 22:55:38 +0000 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [2a00:1450:4864:20::629]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ccb00216-6b10-11ef-99a1-01e77a169b0f; Thu, 05 Sep 2024 00:55:37 +0200 (CEST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a869332c2c2so230657166b.0 for ; Wed, 04 Sep 2024 15:55:37 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a679755b3sm21546166b.146.2024.09.04.15.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 15:55:34 -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: ccb00216-6b10-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725490535; x=1726095335; 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=ER/nzcDu3sjSk/1iNkdxnTJbzqcB3fMPz6UFD3Jo2ug=; b=bxBJr6seH4uOWdo5vFYBLCSdTDQ3q2DwccjNiboDO6B9diGfbe3eS/oG9NoGQwvTIx FX2wFj7XSIr+N3xiy7lRyD4i6sVIfr5eqX6X9EmC84n8JDQbcwYUamXkXAMc51WJh401 56HUuWRV7FUgfyUm42/pEBTR9rungwahy00KE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725490535; x=1726095335; 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=ER/nzcDu3sjSk/1iNkdxnTJbzqcB3fMPz6UFD3Jo2ug=; b=qQZxlfZIDEPs17Mer73YH/ur8ivcED3uAXmxdhQkPZO1BZKj6wE1yroMXS/sSs9P5v 5dcah6T9a49HP3YYC76b1ntanejzIj6t8qk+UaYoEFiFN9r1TBMrUhdrhS2KnUdRdGc8 8HJmeyYSdTruE/7Q16k1/TaPI3/6PCFVM0Fxsqm07H7T9YkDPyZafLxfzTDXDLXyFx+I TZfpVjDuQ7joWlPZMeTUfBjo8ow7Jkn1CcwW1MBW/I0N6uFlbEo1GVbDfeYI3PxPStey Zq1lG/bJQDYpTiDnZ973iP6QcPz55/T0dipCoVdY0exJV9BWudJVffBhwfmsna6vCiVU 32tg== X-Gm-Message-State: AOJu0Yxmon2JPO3jd4ItW1EPVanfC/5UIra7LdPxVoYtrHtahVmc8vWr 3IssOe+j8zv8UpuUxfS0jKPUZscs5SI+oFlWWY01Ne+x8RrTxr9zGdlpaGfWTakMKe4r0M14UNK O X-Google-Smtp-Source: AGHT+IE4/VXycofqlBccx6nNCfkKp9M1LqLlEXieroVrw0e+qFFIciENh0zxQVjHXndQmzFX2vuL7g== X-Received: by 2002:a17:907:608c:b0:a75:1923:eb2e with SMTP id a640c23a62f3a-a8a42fdbe75mr352212466b.14.1725490534997; Wed, 04 Sep 2024 15:55:34 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko , Shawn Anastasio Subject: [PATCH v3 1/5] xen/bitops: Reinstate the please tidy message Date: Wed, 4 Sep 2024 23:55:26 +0100 Message-Id: <20240904225530.3888315-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240904225530.3888315-1-andrew.cooper3@citrix.com> References: <20240904225530.3888315-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: 1725490560000116600 Recent additions have undone prior tidying at the top of the file. Signed-off-by: Andrew Cooper Acked-by: Stefano Stabellini --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko CC: Shawn Anastasio --- xen/include/xen/bitops.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index ed6b9ccc724f..6f8e36f1c755 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -210,6 +210,8 @@ static always_inline bool test_bit(int nr, const volati= le void *addr) test_bit(nr, addr); \ }) =20 +/* --------------------- Please tidy above here --------------------- */ + static always_inline attr_const unsigned int ffs(unsigned int x) { if ( __builtin_constant_p(x) ) --=20 2.39.2 From nobody Tue Dec 3 17:26:46 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=1725490565; cv=none; d=zohomail.com; s=zohoarc; b=f1/s8wAMyosviaRznRS4BAR/CA75MxpxqKaxVoiW68TQJW40CDeBvw96khYB8Ic+wsPaxhjPP1tBi1qPHnx5vrz1TUF8TQltGlgY8teneNQfQi8Ds/tfithWR17i7mEt4m1MuUdVtu3GvUC6DS6mmzCgMLMTjp5Fw0CgHGwEUCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725490565; 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=n1i07dEr5xjoYZGp4+3iu4w7N+mO8cikgWiOPeIxB34=; b=jqS5EhfhQ28DAM/bo5Paw+oSVWt76jJPDABvwPF8HmO5ko+NMh1FjIGs7YZ8/gvFvCpQeUvMPOgaLXN+vYWbG+nraWomEfhkex6RQswkFdP3WtWhM8Q7/2ieTkI/RQTJWVf1nQJJRIhv7zz9Rbdhporgu+db10+GMQQP2cJCprI= 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 1725490565109188.1537479278494; Wed, 4 Sep 2024 15:56:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790820.1200609 (Exim 4.92) (envelope-from ) id 1slyuc-0001zr-M7; Wed, 04 Sep 2024 22:55:42 +0000 Received: by outflank-mailman (output) from mailman id 790820.1200609; Wed, 04 Sep 2024 22:55:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slyuc-0001zg-JK; Wed, 04 Sep 2024 22:55:42 +0000 Received: by outflank-mailman (input) for mailman id 790820; Wed, 04 Sep 2024 22:55:40 +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 1slyua-0001Vf-L5 for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 22:55:40 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cde1f527-6b10-11ef-99a1-01e77a169b0f; Thu, 05 Sep 2024 00:55:39 +0200 (CEST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5c09fd20eddso169692a12.3 for ; Wed, 04 Sep 2024 15:55:39 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a679755b3sm21546166b.146.2024.09.04.15.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 15:55:35 -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: cde1f527-6b10-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725490538; x=1726095338; 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=n1i07dEr5xjoYZGp4+3iu4w7N+mO8cikgWiOPeIxB34=; b=HBrQW0Ucc8kdRydaiwxvOAMI4sODI+Ijlhrne5/KjYIgtyJJV/ojhIlcJTJCio0wwb Th24cl5PvXcUNH+dZuKBTjvf7uKKIQzihg4p1OAVGcCQ0ZgAI7GFnmsNn72YtnH45SLj oLRPWShDysusgLmOOo4DdhgeiMklBUrMjhHkQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725490538; x=1726095338; 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=n1i07dEr5xjoYZGp4+3iu4w7N+mO8cikgWiOPeIxB34=; b=QpbAhWQz30n73oZ0ROoXgVmTYK5ikjU3nn6L68ciMgfUxYShWsdoC3DvR6H4ITaVde MfzcsGNlFss6W7lO52Xf9IAmWrU4wV4J9gZA7mCfHEG6MsUU66ynH8CaGabxJxfEUFjl LewJN6KaAicPqD9mO2+L6Spt+RB8EI4ZMo8IwZjI/bwueKOMqPm+wjZr25Ck+KDJAlxy BoxKcSf1PcMzYzjDug3/Rd6T+oHguhMQED8U5PzzsnqOFX3KPeuzAE/wh1OAAAouf+eH wc6FcXovQh9z1DctCUQbcZfaZ0CrWhra0jTEyFQu59khNmWR8dj9L+Wm2NjtAntm8Sv3 fTgg== X-Gm-Message-State: AOJu0Ywg9LYOArvSLX8mf6UfksAZSO4qLprYoV0Ks2f6K94ACrFIiHiu Pbv9KQbZ7LBqH5DzlYnetZ+kotbwvMnozTEtDeo/RcpaidnKSQ97hQfUAu1FFjBehDqw80jRtSP o X-Google-Smtp-Source: AGHT+IGmD25QJYk6ymyce2efzSO/kxV6Ds+Iw/QZfDQRrhmzCGhKgvvxhkQ9tc8SBF+0sjO2Cyq1Ug== X-Received: by 2002:a17:907:3fa9:b0:a86:4649:28e6 with SMTP id a640c23a62f3a-a897fad290emr1957484366b.57.1725490537574; Wed, 04 Sep 2024 15:55:37 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko , Shawn Anastasio Subject: [PATCH v3 2/5] xen/bitops: Drop the remnants of hweight{8,16}() Date: Wed, 4 Sep 2024 23:55:27 +0100 Message-Id: <20240904225530.3888315-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240904225530.3888315-1-andrew.cooper3@citrix.com> References: <20240904225530.3888315-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: 1725490566052116600 They are no more. No functional change. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Acked-by: Shawn Anastasio Acked-by: Stefano Stabellini --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 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 | 2 -- xen/arch/ppc/include/asm/bitops.h | 2 -- xen/arch/x86/include/asm/bitops.h | 2 -- xen/include/xen/bitops.h | 17 ----------------- 4 files changed, 23 deletions(-) diff --git a/xen/arch/arm/include/asm/bitops.h b/xen/arch/arm/include/asm/b= itops.h index 3c023103f734..91cd167b6bbb 100644 --- a/xen/arch/arm/include/asm/bitops.h +++ b/xen/arch/arm/include/asm/bitops.h @@ -86,8 +86,6 @@ bool clear_mask16_timeout(uint16_t mask, volatile void *p, */ #define hweight64(x) generic_hweight64(x) #define hweight32(x) generic_hweight32(x) -#define hweight16(x) generic_hweight16(x) -#define hweight8(x) generic_hweight8(x) =20 #endif /* _ARM_BITOPS_H */ /* diff --git a/xen/arch/ppc/include/asm/bitops.h b/xen/arch/ppc/include/asm/b= itops.h index 6e4e112b8b92..64512e949530 100644 --- a/xen/arch/ppc/include/asm/bitops.h +++ b/xen/arch/ppc/include/asm/bitops.h @@ -134,7 +134,5 @@ static inline int test_and_set_bit(unsigned int nr, vol= atile void *addr) */ #define hweight64(x) __builtin_popcountll(x) #define hweight32(x) __builtin_popcount(x) -#define hweight16(x) __builtin_popcount((uint16_t)(x)) -#define hweight8(x) __builtin_popcount((uint8_t)(x)) =20 #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 8c0403405aa2..4c5b21907a64 100644 --- a/xen/arch/x86/include/asm/bitops.h +++ b/xen/arch/x86/include/asm/bitops.h @@ -483,7 +483,5 @@ static always_inline unsigned int arch_flsl(unsigned lo= ng x) */ #define hweight64(x) generic_hweight64(x) #define hweight32(x) generic_hweight32(x) -#define hweight16(x) generic_hweight16(x) -#define hweight8(x) generic_hweight8(x) =20 #endif /* _X86_BITOPS_H */ diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index 6f8e36f1c755..58c600155f7e 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -413,23 +413,6 @@ static inline unsigned int generic_hweight32(unsigned = int w) return (w + (w >> 16)) & 0xff; } =20 -static inline unsigned int generic_hweight16(unsigned int w) -{ - w -=3D ((w >> 1) & 0x5555); - w =3D (w & 0x3333) + ((w >> 2) & 0x3333); - w =3D (w + (w >> 4)) & 0x0f0f; - - return (w + (w >> 8)) & 0xff; -} - -static inline unsigned int generic_hweight8(unsigned int w) -{ - w -=3D ((w >> 1) & 0x55); - w =3D (w & 0x33) + ((w >> 2) & 0x33); - - return (w + (w >> 4)) & 0x0f; -} - static inline unsigned int generic_hweight64(uint64_t w) { if ( BITS_PER_LONG < 64 ) --=20 2.39.2 From nobody Tue Dec 3 17:26:46 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=1725490560; cv=none; d=zohomail.com; s=zohoarc; b=d0yuDquDo0yy31epAnbkFs0hFihXFp4guONR8deou+EqjISMuRmho6Fa90pDAsZ9sK5Wa1N/cifOj8WxenPPvcbZePahs7iZz4HIYzba86c5wTE/0gBnbxf79HZW/xBTUUO5Z9BS8VwAUTSfimyGI2BJaW3A5Xa23ZkXoIv+1G4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725490560; 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=+a9rZjwjT4T/KMzHim0E6pRI1Xb37U68VQt9wRm391Y=; b=ksZ5cNnLzSRL2OHrWpNTGQDm/WoIq9e3SwzwUyuvCIFvkrcCDWLbio08FqU0za8cErx7ZncH7YThw9sz+eEtW98ECnqi1XDikTlExJs8EdEJ+PZvmh9zD8pyyJQ2WkIjdr7E5n0MABAdI2lLPiyHTPMfBLSxku4AwHkgLacikHA= 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 1725490560017854.9095229743162; Wed, 4 Sep 2024 15:56:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790821.1200616 (Exim 4.92) (envelope-from ) id 1slyud-00023O-5P; Wed, 04 Sep 2024 22:55:43 +0000 Received: by outflank-mailman (output) from mailman id 790821.1200616; Wed, 04 Sep 2024 22:55:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slyuc-00022u-SV; Wed, 04 Sep 2024 22:55:42 +0000 Received: by outflank-mailman (input) for mailman id 790821; Wed, 04 Sep 2024 22:55:41 +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 1slyua-0001n3-Uu for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 22:55:40 +0000 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [2a00:1450:4864:20::62c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ce6dc6df-6b10-11ef-a0b3-8be0dac302b0; Thu, 05 Sep 2024 00:55:40 +0200 (CEST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a7a81bd549eso23212466b.3 for ; Wed, 04 Sep 2024 15:55:40 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a679755b3sm21546166b.146.2024.09.04.15.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 15:55:38 -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: ce6dc6df-6b10-11ef-a0b3-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725490538; x=1726095338; 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=+a9rZjwjT4T/KMzHim0E6pRI1Xb37U68VQt9wRm391Y=; b=MQUYXEfYQbuzLGQH6SCOLk4qzBCEdFl9uyS3JF9liRplrNasytPSM2us+iddx1g7Hi uu7tRAigX4obLs2MwYLJIJ3qBo3i+xppCWHiGzf4cC/Oxo/HQ3OskSLkfk8qdWrbkFit ess5uqd4E+33c525yyELNB4IgHOftpcTDdrF0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725490538; x=1726095338; 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=+a9rZjwjT4T/KMzHim0E6pRI1Xb37U68VQt9wRm391Y=; b=AW78r1d8EL1hiof8rFxdfjmd3B3f0Rzh9d3zoxrOOgExvLz0SDcgZKKCSNL7uoR5o6 rbe/prJsMzKLIyLTu4LrwO9GoXDB98IQascykt2VN7s4mttNKJAxVED8UjxDT+ilmoJU 9C6Fz+6Pil6124Yawx0AYSuPEhjFhWG2Cgv5+b+MTSA51JxVcTlmiR0A2y4zcKuLreBg wJBOGn9GtTb0SKwiqhR9CZLFuKwqDNd7LTxjDdAi91v9iyOVxPUjrdqAxyP+edPnZxhX 0ZVwJxT4IEdAmPL+8bRcMiCOV6vIQE0aHGLfsfmB+Hq3Ao9mvOH3RjZp1UdCQvg78LPV H1zA== X-Gm-Message-State: AOJu0Yxr7sOu0lkE1k9sYOV1ZrFBbBmLQcGWv4T2VtFXLdJB5CHVaTeR /wC16MnjHoaalGZWVfpldHXtcD8gXGfegxxdG39X/DC5CAleStUm6Owlw8CtLFUbjs4QH5b9HwZ + X-Google-Smtp-Source: AGHT+IG+Y7IPRGGgu1K+j4/cT54zyPqU0Sl4llXZ8+j9vxCozoA3aNlcQm4snkZPegSrROF+RnOVjQ== X-Received: by 2002:a17:906:c14a:b0:a7a:9ece:ea67 with SMTP id a640c23a62f3a-a8a1d29b713mr736725766b.9.1725490538440; Wed, 04 Sep 2024 15:55:38 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko , Shawn Anastasio Subject: [PATCH v3 3/5] xen/bitops: Implement hweight32() in terms of hweightl() Date: Wed, 4 Sep 2024 23:55:28 +0100 Message-Id: <20240904225530.3888315-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240904225530.3888315-1-andrew.cooper3@citrix.com> References: <20240904225530.3888315-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: 1725490562035116600 ... and drop generic_hweight32(). As noted previously, the only two users of hweight32() are in __init paths. The int-optimised form of generic_hweight() is only two instructions shorter than the long-optimised form, and even then only on architectures which lack fast multiplication, so there's no point providing an int-optimised form. No functional change. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich Acked-by: Shawn Anastasio Acked-by: Stefano Stabellini --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko CC: Shawn Anastasio v2: * Reorder with respect to the hweight64() patch * Rerwrite the commit message * s/__pure/attr_const/ --- xen/arch/arm/include/asm/bitops.h | 1 - xen/arch/ppc/include/asm/bitops.h | 1 - xen/arch/x86/include/asm/bitops.h | 1 - xen/include/xen/bitops.h | 5 +++++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/include/asm/bitops.h b/xen/arch/arm/include/asm/b= itops.h index 91cd167b6bbb..b28c25b3d52d 100644 --- a/xen/arch/arm/include/asm/bitops.h +++ b/xen/arch/arm/include/asm/bitops.h @@ -85,7 +85,6 @@ bool clear_mask16_timeout(uint16_t mask, volatile void *p, * The Hamming Weight of a number is the total number of bits set in it. */ #define hweight64(x) generic_hweight64(x) -#define hweight32(x) generic_hweight32(x) =20 #endif /* _ARM_BITOPS_H */ /* diff --git a/xen/arch/ppc/include/asm/bitops.h b/xen/arch/ppc/include/asm/b= itops.h index 64512e949530..f488a7c03425 100644 --- a/xen/arch/ppc/include/asm/bitops.h +++ b/xen/arch/ppc/include/asm/bitops.h @@ -133,6 +133,5 @@ static inline int test_and_set_bit(unsigned int nr, vol= atile void *addr) * The Hamming Weight of a number is the total number of bits set in it. */ #define hweight64(x) __builtin_popcountll(x) -#define hweight32(x) __builtin_popcount(x) =20 #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 4c5b21907a64..507b043b8a86 100644 --- a/xen/arch/x86/include/asm/bitops.h +++ b/xen/arch/x86/include/asm/bitops.h @@ -482,6 +482,5 @@ static always_inline unsigned int arch_flsl(unsigned lo= ng x) * The Hamming Weight of a number is the total number of bits set in it. */ #define hweight64(x) generic_hweight64(x) -#define hweight32(x) generic_hweight32(x) =20 #endif /* _X86_BITOPS_H */ diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index 58c600155f7e..a462c3065158 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -326,6 +326,11 @@ static always_inline attr_const unsigned int hweightl(= unsigned long x) #endif } =20 +static always_inline attr_const unsigned int hweight32(uint32_t x) +{ + return hweightl(x); +} + /* --------------------- Please tidy below here --------------------- */ =20 #ifndef find_next_bit --=20 2.39.2 From nobody Tue Dec 3 17:26:46 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=1725490565; cv=none; d=zohomail.com; s=zohoarc; b=P72soMAeNxrUDzZKzi4zPsbtjGIEj4LRd6ijAVWavcDetks3WdEitou1GH5V+LWlQIKI+vDgPpGQRKpUlAD9/UxrE7b0ayuhSVZLslaCsAIfUY7klQHrthl32s9GvKRztRE4vtXuDvCs+Ukar/Ap+HIrl7YzEkKuMRgSL3NxWDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725490565; 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=hd3H+h3D3FJFoKSFWHnu0JXTNonfMBRV1dP4GfZ7wVk=; b=MNIBKufmPdP/gKvMLFGh4Oxb7H3wlcJ1gqms7C/dNV/5W244CqMrgoOh65OLVlFqwpQadhhXP1cfiYtAAuLDmVpGRypCS+d7DHG6fcXKORSo3p27ZeKw5USzXr7sb8u3yucJvUF9zlEN1Ra+fYNKU285a7A1SgNMqlrTZIbp9ss= 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 1725490565552965.1974455283274; Wed, 4 Sep 2024 15:56:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790822.1200629 (Exim 4.92) (envelope-from ) id 1slyue-0002TG-Au; Wed, 04 Sep 2024 22:55:44 +0000 Received: by outflank-mailman (output) from mailman id 790822.1200629; Wed, 04 Sep 2024 22:55:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slyue-0002Sp-6x; Wed, 04 Sep 2024 22:55:44 +0000 Received: by outflank-mailman (input) for mailman id 790822; Wed, 04 Sep 2024 22:55:42 +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 1slyuc-0001Vf-KE for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 22:55:42 +0000 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [2a00:1450:4864:20::632]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cf0d46d4-6b10-11ef-99a1-01e77a169b0f; Thu, 05 Sep 2024 00:55:41 +0200 (CEST) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a8a1d78e7b0so29700166b.3 for ; Wed, 04 Sep 2024 15:55:41 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a679755b3sm21546166b.146.2024.09.04.15.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 15:55:38 -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: cf0d46d4-6b10-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725490540; x=1726095340; 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=hd3H+h3D3FJFoKSFWHnu0JXTNonfMBRV1dP4GfZ7wVk=; b=f1GZ1qryOrE+AIVt8dIDF4Cwv3AXhIjWhsBr2FZ561KeXFI2cyQ5OYkz7p9o8UNzMo cSIPYwox1axo0XiPOgXsPIh/NI4o1cNiea8uSBj0JYqlRKUeTS82AITox5PyB06baato BWJ2NuFDzaKUVOxkJ7WegpgkwEIKaPbUBUQ7M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725490540; x=1726095340; 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=hd3H+h3D3FJFoKSFWHnu0JXTNonfMBRV1dP4GfZ7wVk=; b=a8Y1lGlf3tE4FudhwKXMQrIQRr0YFOjr8KU9Uxfo+xYzEjR6Ws6eQS5/8o31tbE7Lz 2x+lpR+OtONZlXlUM6WMkkZeYpzkYjpah2JD1uzZ+M52zgTl6PTU7bVAa3zZ7vv8/rGC J6BihmPfwST0//+Go6K9qIMvW5FkLq+t//JXb7Qg0sIz/qvScudIZhGRCO+XRh+GwY0r 2kpjPpPz9xij7nz8idNoPWD/zAPmCLvMBm2LucbucFS3GRom0+kA8ha7Exx41Q54jzPq raO88WsJBVFEOgduajjA9dbdJ9HMSKiewsE9JLQnaQHsbxiCVYHrpCOkV3Skk+/SPSQB 4/ZA== X-Gm-Message-State: AOJu0Yy/25ftMedo/qmoGqete4XoZrHmp3/pbnvWhRcNRFzbJan0f8r9 PZxr2GLXG4okxeLsrZdD7nTM5WSEAREKQx0BmKJTtBHuxJjbuds3j6IaBchpJAwv3g0v5o22UE7 t X-Google-Smtp-Source: AGHT+IE9VLaaMtlNwXPcEcM6pwwWuJWcGfSEwfsF1cBZ1/BY0yP0ykTmeD26W5mnQHHrC45r7ZjwjA== X-Received: by 2002:a17:907:7e9c:b0:a7a:a06b:eecd with SMTP id a640c23a62f3a-a8a3f0ee73emr344872666b.5.1725490539513; Wed, 04 Sep 2024 15:55:39 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko , Shawn Anastasio Subject: [PATCH v3 4/5] xen/bitops: Implement hweight64() in terms of hweight{l,32}() Date: Wed, 4 Sep 2024 23:55:29 +0100 Message-Id: <20240904225530.3888315-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240904225530.3888315-1-andrew.cooper3@citrix.com> References: <20240904225530.3888315-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: 1725490566099116601 ... and drop generic_hweight{32,64}(). This is identical on all architectures except ARM32. Add one extra SELF_TE= ST to check that hweight64() works when the input is split in half. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Acked-by: Stefano Stabellini --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko CC: Shawn Anastasio v3: * Use >=3D, even if it does differ from ffs() v2: * Reorder with respect to the hweight32() patch * s/__pure/attr_const/ --- 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/common/bitops.c | 3 +++ xen/include/xen/bitops.h | 45 ++++++------------------------- 5 files changed, 11 insertions(+), 61 deletions(-) diff --git a/xen/arch/arm/include/asm/bitops.h b/xen/arch/arm/include/asm/b= itops.h index b28c25b3d52d..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 hweight64(x) generic_hweight64(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 f488a7c03425..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 hweight64(x) __builtin_popcountll(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 507b043b8a86..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 hweight64(x) generic_hweight64(x) - #endif /* _X86_BITOPS_H */ diff --git a/xen/common/bitops.c b/xen/common/bitops.c index 5e5d20d225d7..91ae961440af 100644 --- a/xen/common/bitops.c +++ b/xen/common/bitops.c @@ -144,6 +144,9 @@ static void __init test_hweight(void) =20 CHECK(hweightl, 1 | (1UL << (BITS_PER_LONG - 1)), 2); CHECK(hweightl, -1UL, BITS_PER_LONG); + + /* unsigned int hweight64(uint64_t) */ + CHECK(hweight64, -1ULL, 64); } =20 static void __init __constructor test_bitops(void) diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index a462c3065158..12eb88fb1255 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -331,6 +331,14 @@ static always_inline attr_const unsigned int hweight32= (uint32_t x) return hweightl(x); } =20 +static always_inline attr_const unsigned int hweight64(uint64_t x) +{ + if ( BITS_PER_LONG >=3D 64 ) + return hweightl(x); + else + return hweight32(x >> 32) + hweight32(x); +} + /* --------------------- Please tidy below here --------------------- */ =20 #ifndef find_next_bit @@ -399,43 +407,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; -} - -static inline unsigned int generic_hweight64(uint64_t w) -{ - if ( BITS_PER_LONG < 64 ) - return generic_hweight32(w >> 32) + generic_hweight32(w); - - w -=3D (w >> 1) & 0x5555555555555555UL; - w =3D (w & 0x3333333333333333UL) + ((w >> 2) & 0x3333333333333333UL); - w =3D (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0fUL; - - if ( IS_ENABLED(CONFIG_HAS_FAST_MULTIPLY) ) - return (w * 0x0101010101010101UL) >> 56; - - w +=3D w >> 8; - w +=3D w >> 16; - - return (w + (w >> 32)) & 0xFF; -} - /* * rol32 - rotate a 32-bit value left * --=20 2.39.2 From nobody Tue Dec 3 17:26:46 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=1725490564; cv=none; d=zohomail.com; s=zohoarc; b=FNdEQdTBq3EsEXG9+EfS9Msoho9JcmrAAp/e+4ACh+RNpCmbr1FddajL4fJO/oqIQl1JUlWvSEz5ZzhE3DP2/EuHBZguIzR9bnIrS5H2gN3sEOpj3V0rWobTnc8Vv+y7T+5I1DRZmKbtBNC22pJm5969NCx7w+hxQiCxQklT0bw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725490564; 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=E3n388Uhg0XQDTfV4nLYdZiik4UbyUOd65XJSN8jK54=; b=FIC8RfTTMtBQJTymMFoRLeNgdjZuGxVf/Y4C7LsHt5OBuriyQdNaXnbP/OAOEePvC2piBntOKukLN/x73FBgmvomSX+UKPWCgqO+9tt0uOE4tC/98dJ96jwDp/0ucsZFeako9EqrAdkdnAIH1t2ykiDuCSzBI46Hk+dx0/T9v5w= 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 17254905643461014.2678004359467; Wed, 4 Sep 2024 15:56:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.790823.1200635 (Exim 4.92) (envelope-from ) id 1slyue-0002XR-Qz; Wed, 04 Sep 2024 22:55:44 +0000 Received: by outflank-mailman (output) from mailman id 790823.1200635; Wed, 04 Sep 2024 22:55:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1slyue-0002WU-Fx; Wed, 04 Sep 2024 22:55:44 +0000 Received: by outflank-mailman (input) for mailman id 790823; Wed, 04 Sep 2024 22:55:43 +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 1slyud-0001Vf-7h for xen-devel@lists.xenproject.org; Wed, 04 Sep 2024 22:55:43 +0000 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [2a00:1450:4864:20::62a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cf5cbdc3-6b10-11ef-99a1-01e77a169b0f; Thu, 05 Sep 2024 00:55:41 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a8a1acb51a7so23032366b.2 for ; Wed, 04 Sep 2024 15:55:41 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a679755b3sm21546166b.146.2024.09.04.15.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 15:55:39 -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: cf5cbdc3-6b10-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725490540; x=1726095340; 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=E3n388Uhg0XQDTfV4nLYdZiik4UbyUOd65XJSN8jK54=; b=OEhup2o3C7aTUhghggzLRqHF5Low3JUbap/QTqnXzB+8+okIH+x0fwwOyi3vEv38LW KKr69nKaPvcPqLLq22wHC9oBU2yLINTG6JVkV/0vE4wYYVy0MidxD2QMCaXvD2JiOV+0 8SxmwhxRuMwUZxhMkDGg7XpztY3FNc5AgBIgg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725490540; x=1726095340; 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=E3n388Uhg0XQDTfV4nLYdZiik4UbyUOd65XJSN8jK54=; b=eCdLcoSC3TCpnl6btTnNW/zBxM1tepHf+vDJaN+tNCMHrJFd2h3BwHcQqf/qGqPtlh +GDpfWNaRxpvXH3m+FLh9ZtmwYxIJMrwN8u/AfHRdanWYBHlTLMI1B4faKhkMQayh0Do W0rTjXDSaIYzcKxaXKS9NnmX1nvxWdV56gahXbhSJuFwc7lxhWAzUEGChPl9+SejPyXP cHIsdv51V5NBkC6NQttVd5sd24GOeI96dt66ET5BBKwcbVkA6vsaB5mH12lKaXoonyUq mJ08tMBawukRNxMi1wn3S0FJFzaC9hg79AHudiSjPdjLdBdAPk6+9N3TA3+CG6yrDoDO RUhw== X-Gm-Message-State: AOJu0Yzvwv9EfYlF3Q6lCANBiD2RZ6K31Umhxv+37SNNHHAd+vbXz3es VJ/AyBokOM6jPJf0Ns81JBwtyg1qwxDrJGMqVDr10qzfZVXn+7RQyQOXm69zC9vXdXZBooEa5DP 9 X-Google-Smtp-Source: AGHT+IFsy1512+ns/JGyojizKQVIyhHUss1SNREsuGlaOrNEgxRK8dU2eNOoRebKvEYupzzFvK+7KQ== X-Received: by 2002:a17:907:944c:b0:a7a:bcbc:f7e1 with SMTP id a640c23a62f3a-a8a1d2c28afmr806550066b.15.1725490540492; Wed, 04 Sep 2024 15:55:40 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v3 5/5] x86/bitops: Use the POPCNT instruction when available Date: Wed, 4 Sep 2024 23:55:30 +0100 Message-Id: <20240904225530.3888315-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240904225530.3888315-1-andrew.cooper3@citrix.com> References: <20240904225530.3888315-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: 1725490566099116600 It has existed in x86 CPUs since 2008, so we're only 16 years late adding support. With all the other scafolding in place, implement arch_hweightl() for x86. The only complication is that the call to arch_generic_hweightl() is behind the compilers back. Address this by writing it in ASM and ensure that it preserves all registers. Copy the code generation from generic_hweightl(). It's not a complicated algorithm, and is easy to regenerate if needs be, but cover it with the same unit tests as test_generic_hweightl() just for piece of mind. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 v3: * Reinstate dropped CONFIG_SELF_TESTS * Leave grep fodder for CODE_FILL until we can find a nicer way of doing t= his. v2: * Fix MISRA 8.2 (parameter name) and 8.5 (single declaration) regressions. * Rename {arch->x86}-generic-hweightl.{S->c} * Adjust ASM formating --- xen/arch/x86/include/asm/bitops.h | 23 ++++++++++ xen/lib/Makefile | 1 + xen/lib/x86-generic-hweightl.c | 71 +++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 xen/lib/x86-generic-hweightl.c diff --git a/xen/arch/x86/include/asm/bitops.h b/xen/arch/x86/include/asm/b= itops.h index 642d8e58b288..39e37f1cbe55 100644 --- a/xen/arch/x86/include/asm/bitops.h +++ b/xen/arch/x86/include/asm/bitops.h @@ -6,6 +6,7 @@ */ =20 #include +#include #include =20 /* @@ -475,4 +476,26 @@ static always_inline unsigned int arch_flsl(unsigned l= ong x) } #define arch_flsl arch_flsl =20 +unsigned int arch_generic_hweightl(unsigned long x); + +static always_inline unsigned int arch_hweightl(unsigned long x) +{ + unsigned int r; + + /* + * arch_generic_hweightl() is written in ASM in order to preserve all + * registers, as the compiler can't see the call. + * + * This limits the POPCNT instruction to using the same ABI as a funct= ion + * call (input in %rdi, output in %eax) but that's fine. + */ + alternative_io("call arch_generic_hweightl", + "popcnt %[val], %q[res]", X86_FEATURE_POPCNT, + ASM_OUTPUT2([res] "=3Da" (r) ASM_CALL_CONSTRAINT), + [val] "D" (x)); + + return r; +} +#define arch_hweightl arch_hweightl + #endif /* _X86_BITOPS_H */ diff --git a/xen/lib/Makefile b/xen/lib/Makefile index b6558e108bd9..54440f628aae 100644 --- a/xen/lib/Makefile +++ b/xen/lib/Makefile @@ -36,6 +36,7 @@ lib-y +=3D strtol.o lib-y +=3D strtoll.o lib-y +=3D strtoul.o lib-y +=3D strtoull.o +lib-$(CONFIG_X86) +=3D x86-generic-hweightl.o lib-$(CONFIG_X86) +=3D xxhash32.o lib-$(CONFIG_X86) +=3D xxhash64.o =20 diff --git a/xen/lib/x86-generic-hweightl.c b/xen/lib/x86-generic-hweightl.c new file mode 100644 index 000000000000..123a5b43928d --- /dev/null +++ b/xen/lib/x86-generic-hweightl.c @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +/* + * An implementation of generic_hweightl() used on hardware without the PO= PCNT + * instruction. + * + * This function is called from within an ALTERNATIVE in arch_hweightl(). + * i.e. behind the back of the compiler. Therefore all registers are call= ee + * preserved. + * + * The ASM is what GCC-12 emits for generic_hweightl() in a release build = of + * Xen, with spilling of %rdi/%rdx to preserve the callers registers. + * + * Note: When we can use __attribute__((no_caller_saved_registers)) + * unconditionally (GCC 7, Clang 5), we can implement this in plain = C. + */ +asm ( + ".type arch_generic_hweightl, STT_FUNC\n\t" + ".globl arch_generic_hweightl\n\t" + ".hidden arch_generic_hweightl\n\t" + ".balign " STR(CONFIG_FUNCTION_ALIGNMENT) ", 0x90\n" /* CODE_FILL */ + "arch_generic_hweightl:\n\t" + + "push %rdi\n\t" + "push %rdx\n\t" + + "movabs $0x5555555555555555, %rdx\n\t" + "mov %rdi, %rax\n\t" + "shr $1, %rax\n\t" + "and %rdx, %rax\n\t" + "sub %rax, %rdi\n\t" + "movabs $0x3333333333333333, %rax\n\t" + "mov %rdi, %rdx\n\t" + "shr $2, %rdi\n\t" + "and %rax, %rdx\n\t" + "and %rax, %rdi\n\t" + "add %rdi, %rdx\n\t" + "mov %rdx, %rax\n\t" + "shr $4, %rax\n\t" + "add %rdx, %rax\n\t" + "movabs $0x0f0f0f0f0f0f0f0f, %rdx\n\t" + "and %rdx, %rax\n\t" + "movabs $0x0101010101010101, %rdx\n\t" + "imul %rdx, %rax\n\t" + "shr $" STR(BITS_PER_LONG) "- 8, %rax\n\t" + + "pop %rdx\n\t" + "pop %rdi\n\t" + + "ret\n\t" + + ".size arch_generic_hweightl, . - arch_generic_hweightl\n\t" +); + +#ifdef CONFIG_SELF_TESTS +static void __init __constructor test_arch_generic_hweightl(void) +{ + RUNTIME_CHECK(arch_generic_hweightl, 0, 0); + RUNTIME_CHECK(arch_generic_hweightl, 1, 1); + RUNTIME_CHECK(arch_generic_hweightl, 3, 2); + RUNTIME_CHECK(arch_generic_hweightl, 7, 3); + RUNTIME_CHECK(arch_generic_hweightl, 0xff, 8); + + RUNTIME_CHECK(arch_generic_hweightl, 1 | (1UL << (BITS_PER_LONG - 1)),= 2); + RUNTIME_CHECK(arch_generic_hweightl, -1UL, BITS_PER_LONG); +} +#endif --=20 2.39.2