From patchwork Thu Aug 22 23:06:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13774335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A715C5472C for ; Thu, 22 Aug 2024 23:06:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.782002.1191470 (Exim 4.92) (envelope-from ) id 1shGt9-00053G-K5; Thu, 22 Aug 2024 23:06:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 782002.1191470; Thu, 22 Aug 2024 23:06: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 1shGt9-000539-H2; Thu, 22 Aug 2024 23:06:43 +0000 Received: by outflank-mailman (input) for mailman id 782002; Thu, 22 Aug 2024 23:06: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 1shGt8-00052v-MZ for xen-devel@lists.xenproject.org; Thu, 22 Aug 2024 23:06:42 +0000 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [2a00:1450:4864:20::134]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 30dbc220-60db-11ef-8776-851b0ebba9a2; Fri, 23 Aug 2024 01:06:40 +0200 (CEST) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-533488ffaebso1516460e87.0 for ; Thu, 22 Aug 2024 16:06:40 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 16:06:38 -0700 (PDT) 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: 30dbc220-60db-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1724368000; x=1724972800; 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=m2LeyzUwL5o7T7PpRPGH34rG7BC0CEXy4TaB1P1AwTY=; b=N6y8gBZvGap8ZnbpfXZ9+SRbHNNmeLoXrEs/BrSDNHfQ8Qairt6hsLNWewZ8gVCips M+W1Bc5EMBA9qlxdRbprssDq6+cx60GA+idb7i/ku9AE6AquLxKW6UMilVF3QnBkbCJ+ CFWgohkVLDmoUAL4AHJPv+YzRr/7oTK3zsofg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724368000; x=1724972800; 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=m2LeyzUwL5o7T7PpRPGH34rG7BC0CEXy4TaB1P1AwTY=; b=SfZ1G/2ELWMod5/QUG9xeqEypEASlK+wn4w1huzO5KqtwRLb3PVWlQ7DWATfu+p/8I NAit+MhFcvjTQ7GBQdo4TfjjsJaKfg62yQ+cETeBobCBiPD8ICOmMPgJ/vEEL2OpD4mA 63ELimIYXV3Yuaup2EySTyXkk+hnkC993zjcDGR/CbSihMLIUR+55lt403DJQ+LwmqIG 51Y9aA/lSC8U/RWV4WY15Z8smAmV+KUutboj3jg3i/jCn+4PDmhsOF1wheR7yczE5BDs En4bhFibDVEoXOj6jQcUEug3o35Sp5xtcCEDKQnc84RjLCqbtaCfPMRxVv7UIL1mh192 IWvQ== X-Gm-Message-State: AOJu0Yylk3XDYEZOF9b1af/dibFC6bwk59p0B51904L8Rqcg7oVBgNuy 7xoRhJJ0EN+XO0o1SKpQ1bgPReKwEd4CB2Hgdz3SdTLhqPJGywjL6YfyUr6SLZjff4zzDfFKjGB M X-Google-Smtp-Source: AGHT+IEaVH2wJY8/h1/gFnkOs39vSqEqmt0IjwV8kWT2KBSrYXeuLEVPBeCoURFCMpIwWVDt1NBUqg== X-Received: by 2002:a05:6512:114d:b0:52e:9b68:d2d4 with SMTP id 2adb3069b0e04-534387be68cmr225605e87.56.1724367999136; Thu, 22 Aug 2024 16:06:39 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko , Shawn Anastasio Subject: [PATCH 0/9] xen/bitops: hweight() cleanup/improvements Date: Fri, 23 Aug 2024 00:06:26 +0100 Message-Id: <20240822230635.954557-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 The next phase of bitops cleanup. This series: 1) Untangles the mess around hweight() 2) Removes some unwise uses of hweight() 3) Makes it work transparently for RISC-V 4) Use the POPCNT instruction on x86 when available https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1424000649 https://cirrus-ci.com/build/4947148859506688 Andrew Cooper (9): xen/bitops: Reinstate the please tidy message xen/bitops: Introduce a multiple_bits_set() helper xen/bitops: Convert 'hweight(x) > 1' to new multiple_bits_set() xen/bitops: Drop the remnants of hweight{8,16}() xen/bitops: Introduce generic_hweightl() and hweightl() xen/bitops: Drop hweight_long() and use hweightl() xen/bitops: Implement hweight64() in terms of hweightl() xen/bitops: Implement hweight32() in terms of hweightl() x86/bitops: Use the POPCNT instruction when available xen/arch/arm/include/asm/bitops.h | 11 ---- xen/arch/ppc/include/asm/bitops.h | 11 +--- xen/arch/x86/cpu/vpmu.c | 2 +- xen/arch/x86/hvm/vlapic.c | 10 +-- xen/arch/x86/include/asm/bitops.h | 30 ++++++--- xen/common/bitmap.c | 4 +- xen/common/bitops.c | 41 ++++++++++++ xen/common/numa.c | 2 +- xen/include/xen/bitops.h | 102 +++++++++++++----------------- xen/include/xen/self-tests.h | 10 ++- xen/lib/Makefile | 2 + xen/lib/arch-generic-hweightl.S | 46 ++++++++++++++ xen/lib/generic-hweightl.c | 61 ++++++++++++++++++ 13 files changed, 232 insertions(+), 100 deletions(-) create mode 100644 xen/lib/arch-generic-hweightl.S create mode 100644 xen/lib/generic-hweightl.c