Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp132506rdb; Thu, 1 Feb 2024 04:29:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGm3cRkAlMNBv8xCYQhjM3Mxczy/Sr1oWm2kFkLsO9DFZaLJxWNn80m4zlUvJT645WST0zo X-Received: by 2002:a05:6a20:4281:b0:19c:a3f0:c19 with SMTP id o1-20020a056a20428100b0019ca3f00c19mr10973250pzj.1.1706790547182; Thu, 01 Feb 2024 04:29:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706790547; cv=pass; d=google.com; s=arc-20160816; b=AERTUoYjP4lrEy2Kpa/yyg1Z1W9gYjcJg7KORzSbfHoryIpG7QohaB24DZpVhk90dd jVHrQbqT6yxDQLCP9r5XRW/BUoUGzt3JkHzVfBPl3S9ietfeBFlCsPe+AV5PUUtIQ3Zm 1UOk2p8eLpiEzv7lyo7zCHsT/ysRuexauSxkhTfz1zlhAoU1R5kSYSArXkhhdqfLUwux m8kzSCwRytymH+vmnb5O/Eh55szX3Vf7BgZnIQ+n/JP22EyT29pEPgpVzU84GikR8yEe sOuGR774LJcbrSEkAVLO/f0Tauxiy/BXLayTC3y5r3rseB+DOTz+QMRQOxUR/dUEVoo8 OuyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=n5HcvItoLtNtV2tRoN4qbfvnYFQSx7Pm/R4/zzyldig=; fh=hHMo7s3o/IoztLwaMnLW0Eh2yKq5+Y2MtcbN/19XsAg=; b=XWsFv1fLGoPke52zN2ZgaabbMFij06P9Bpwmbi7NUJBrqooLGtYMBr3eyvMLSqj2DO Q4lo7M1s8Zzcn9xE1FYe98rRlXO/OodJIryC3Lib45cd1NFFv9oL8dA6NhJDDy1gJTYG VpgCVDY8fLE59jS9W0mqlGJa4AEHn1BHCjKZZww7WR0HswbN5ezMT6blG6fhrJBnsAHT WvEXC/PstRjEyQHq96i08cnrmy9SQzJXVDCbRMJOLjeSjVCLifaTiD4VbSsl9QAzAe9z NdZpS4PX+ogqV+XUEXmSEW/9FpRspfPXT3kYioYSXhlpYyLbd1VYk3VJNVOr/ViQjz56 +6eQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KfZM5k3T; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-48125-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48125-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCUc6qAkPaQnwnLPwcJI3ML0EMQjWNBOsOJ9jvbE38lOeo7E+Y2OXfS+f6NQQUH3xN/asqeO0uETeNS9gKKZF7kMTXf5Oj44MbE4TkCb4g== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 15-20020a630d4f000000b005ce004c1886si12262567pgn.468.2024.02.01.04.29.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 04:29:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48125-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KfZM5k3T; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-48125-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48125-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1DD4E295789 for ; Thu, 1 Feb 2024 12:29:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 625FB5F466; Thu, 1 Feb 2024 12:24:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KfZM5k3T" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02F3F16086B; Thu, 1 Feb 2024 12:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706790280; cv=none; b=BHh2ywbEacOqC0w1n1kNbFz343W1VL+CukKRmM31c9NEWF1gPzytVZrAyybuG6pByBxw84d2QEhq201IC+LvjyK11gVEnA57wtN7kUTo5xtcBfsTbl9wJxLJtaxH9XRNJ3Tfw6yQsklGFYYlzkrP59Fb1RR9nO//nrx2Qalh7+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706790280; c=relaxed/simple; bh=6P+IyUknljgPeM0LGZKzZ3a8q7uN5OUI3RLSrY33oAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C6xy8a24/rr6rHs7VCAuu0zHA53CVQURmCsFf3Wyvfp3c1hvlwYiPNEot8jraNVurSqGSk1eD2HoljT6HFOI62GT8qQ90x3dATLC2J3mN6UFrdo5fYeI6vFS57taqsyxTCa8hh4HD/kyjq+wvPioLenGj68YTbSJQr/QlgS4vQU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KfZM5k3T; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706790280; x=1738326280; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6P+IyUknljgPeM0LGZKzZ3a8q7uN5OUI3RLSrY33oAY=; b=KfZM5k3TDIOaWxinl6wDl77TYY9gxnjc1wQ4fjf88LQkWcKEOSN66Pha piu1RxBBPD18IQzxCMsXUTvHHjoRJP5NOpaaEF6IJvT3xMCP6oebXkxAl ODdjz4OvOdpdfa+1yaUq+cEBflJpHvFNFTUtI13ZYpSL6xjtD4okBWzBB DborzWdcB19oX9ZZbCREgOPvrvNO0m0+re3OsDjnKGj8/t6OQtSJbxiuA y7rts5osEUqj7ASnqMQFm56tNszGwCPJM/pGL+jop1jubcbXs/8XT6ASP qqDSm5jTTrsmVOGOq120s74YMSBX9Y21vSVAqKxX3ir9nx8Uv8yPHusVc A==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="3747121" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="3747121" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 04:24:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="4499128" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa004.jf.intel.com with ESMTP; 01 Feb 2024 04:24:34 -0800 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Michal Swiatkowski , Marcin Szycik , Wojciech Drewek , Yury Norov , Andy Shevchenko , Rasmus Villemoes , Alexander Potapenko , Jiri Pirko , Ido Schimmel , Przemek Kitszel , Simon Horman , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, ntfs3@lists.linux.dev, linux-s390@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v5 13/21] bitmap: make bitmap_{get,set}_value8() use bitmap_{read,write}() Date: Thu, 1 Feb 2024 13:22:08 +0100 Message-ID: <20240201122216.2634007-14-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240201122216.2634007-1-aleksander.lobakin@intel.com> References: <20240201122216.2634007-1-aleksander.lobakin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that we have generic bitmap_read() and bitmap_write(), which are inline and try to take care of non-bound-crossing and aligned cases to keep them optimized, collapse bitmap_{get,set}_value8() into simple wrappers around the former ones. bloat-o-meter shows no difference in vmlinux and -2 bytes for gpio-pca953x.ko, which says the optimization didn't suffer due to that change. The converted helpers have the value width embedded and always compile-time constant and that helps a lot. Suggested-by: Yury Norov Signed-off-by: Alexander Lobakin --- include/linux/bitmap.h | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 9a6a27a7f675..f80e116b8f60 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -609,39 +609,6 @@ static inline void bitmap_from_u64(unsigned long *dst, u64 mask) bitmap_from_arr64(dst, &mask, 64); } -/** - * bitmap_get_value8 - get an 8-bit value within a memory region - * @map: address to the bitmap memory region - * @start: bit offset of the 8-bit value; must be a multiple of 8 - * - * Returns the 8-bit value located at the @start bit offset within the @src - * memory region. - */ -static inline unsigned long bitmap_get_value8(const unsigned long *map, - unsigned long start) -{ - const size_t index = BIT_WORD(start); - const unsigned long offset = start % BITS_PER_LONG; - - return (map[index] >> offset) & 0xFF; -} - -/** - * bitmap_set_value8 - set an 8-bit value within a memory region - * @map: address to the bitmap memory region - * @value: the 8-bit value; values wider than 8 bits may clobber bitmap - * @start: bit offset of the 8-bit value; must be a multiple of 8 - */ -static inline void bitmap_set_value8(unsigned long *map, unsigned long value, - unsigned long start) -{ - const size_t index = BIT_WORD(start); - const unsigned long offset = start % BITS_PER_LONG; - - map[index] &= ~(0xFFUL << offset); - map[index] |= value << offset; -} - /** * bitmap_read - read a value of n-bits from the memory region * @map: address to the bitmap memory region @@ -715,6 +682,11 @@ static inline void bitmap_write(unsigned long *map, unsigned long value, map[index + 1] |= (value >> space); } +#define bitmap_get_value8(map, start) \ + bitmap_read(map, start, BITS_PER_BYTE) +#define bitmap_set_value8(map, value, start) \ + bitmap_write(map, value, start, BITS_PER_BYTE) + #endif /* __ASSEMBLY__ */ #endif /* __LINUX_BITMAP_H */ -- 2.43.0