[nacked] lib-memweightc-open-codes-bitmap_weight.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: lib/memweight.c: open code bitmap_weight()
has been removed from the -mm tree.  Its filename was
     lib-memweightc-open-codes-bitmap_weight.patch

This patch was dropped because it was nacked

------------------------------------------------------
From: Denis Efremov <efremov@xxxxxxxxx>
Subject: lib/memweight.c: open code bitmap_weight()

Open code the bitmap_weight() call.  The direct invocation of
hweight_long() permits removal of the BUG_ON and excessive "longs to bits,
bits to longs" conversion.

BUG_ON was required to check that bitmap_weight() will return a correct
value, i.e.  the computed weight will fit the int type of the return
value.  With this patch memweight() controls the computation directly with
size_t type everywhere.  Thus, the BUG_ON becomes unnecessary.

Total size reduced:
./scripts/bloat-o-meter lib/memweight.o.old lib/memweight.o.new
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-10 (-10)
Function                                     old     new   delta
memweight                                    162     152     -10

Link: http://lkml.kernel.org/r/20190824100102.1167-1-efremov@xxxxxxxxx
Signed-off-by: Erdem Tumurov <erdemus@xxxxxxxxx>
Signed-off-by: Vladimir Shelekhov <vshel@xxxxxxxxxx>
Signed-off-by: Denis Efremov <efremov@xxxxxxxxx>
Co-developed-by: Erdem Tumurov <erdemus@xxxxxxxxx>
Co-developed-by: Vladimir Shelekhov <vshel@xxxxxxxxxx>
Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 lib/memweight.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--- a/lib/memweight.c~lib-memweightc-open-codes-bitmap_weight
+++ a/lib/memweight.c
@@ -20,11 +20,13 @@ size_t memweight(const void *ptr, size_t
 
 	longs = bytes / sizeof(long);
 	if (longs) {
-		BUG_ON(longs >= INT_MAX / BITS_PER_LONG);
-		ret += bitmap_weight((unsigned long *)bitmap,
-				longs * BITS_PER_LONG);
+		const unsigned long *bitmap_long =
+			(const unsigned long *)bitmap;
+
 		bytes -= longs * sizeof(long);
-		bitmap += longs * sizeof(long);
+		for (; longs > 0; longs--, bitmap_long++)
+			ret += hweight_long(*bitmap_long);
+		bitmap = (const unsigned char *)bitmap_long;
 	}
 	/*
 	 * The reason that this last loop is distinct from the preceding
_

Patches currently in -mm which might be from efremov@xxxxxxxxx are





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux