Skip to contentSkip to conversation

mm/cma_debug.c:45 cma_used_get() warn: should 'used << cma->order_per_bit' be a 64 bit type?

PATCH New Dan Carpenter 3 participants 3 messages Apr 8, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 9613/10050 mm/cma_debug.c:45 cma_used_get() warn: should 'used << cma->order_per_bit' be a 64 bit type?

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   a897436e0e233e84b664bb7f33c4e0d4d3e3bdad
commit: 8b0c0ea86849b55091281d146d62bbd9cda87556 [9613/10050] mm-cma-add-functions-to-get-region-pages-counters-fix-2

mm/cma_debug.c:45 cma_used_get() warn: should 'used << cma->order_per_bit' be a 64 bit type? mm/cma_debug.c:67 cma_maxchunk_get() warn: should 'maxchunk << cma->order_per_bit' be a 64 bit type?

git remote add next git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update next
git checkout 8b0c0ea86849b55091281d146d62bbd9cda87556
vim +45 mm/cma_debug.c

8b0c0ea8 Stefan Strogin 2015-04-08  39  	unsigned long used;
c8e6dfcb Dmitry Safonov 2015-04-08  40  
8b0c0ea8 Stefan Strogin 2015-04-08  41  	mutex_lock(&cma->lock);
8b0c0ea8 Stefan Strogin 2015-04-08  42  	/* pages counter is smaller than sizeof(int) */
8b0c0ea8 Stefan Strogin 2015-04-08  43  	used = bitmap_weight(cma->bitmap, (int)cma->count);
8b0c0ea8 Stefan Strogin 2015-04-08  44  	mutex_unlock(&cma->lock);
8b0c0ea8 Stefan Strogin 2015-04-08 @45  	*val = used << cma->order_per_bit;
c8e6dfcb Dmitry Safonov 2015-04-08  46  
c8e6dfcb Dmitry Safonov 2015-04-08  47  	return 0;
c8e6dfcb Dmitry Safonov 2015-04-08  48  }
c8e6dfcb Dmitry Safonov 2015-04-08  49  
c8e6dfcb Dmitry Safonov 2015-04-08  50  DEFINE_SIMPLE_ATTRIBUTE(cma_used_fops, cma_used_get, NULL, "%llu\n");
c8e6dfcb Dmitry Safonov 2015-04-08  51  
c8e6dfcb Dmitry Safonov 2015-04-08  52  static int cma_maxchunk_get(void *data, u64 *val)
c8e6dfcb Dmitry Safonov 2015-04-08  53  {
c8e6dfcb Dmitry Safonov 2015-04-08  54  	struct cma *cma = data;
8b0c0ea8 Stefan Strogin 2015-04-08  55  	unsigned long maxchunk = 0;
8b0c0ea8 Stefan Strogin 2015-04-08  56  	unsigned long start, end = 0;
c8e6dfcb Dmitry Safonov 2015-04-08  57  
8b0c0ea8 Stefan Strogin 2015-04-08  58  	mutex_lock(&cma->lock);
8b0c0ea8 Stefan Strogin 2015-04-08  59  	for (;;) {
8b0c0ea8 Stefan Strogin 2015-04-08  60  		start = find_next_zero_bit(cma->bitmap, cma->count, end);
8b0c0ea8 Stefan Strogin 2015-04-08  61  		if (start >= cma->count)
8b0c0ea8 Stefan Strogin 2015-04-08  62  			break;
8b0c0ea8 Stefan Strogin 2015-04-08  63  		end = find_next_bit(cma->bitmap, cma->count, start);
8b0c0ea8 Stefan Strogin 2015-04-08  64  		maxchunk = max(end - start, maxchunk);
8b0c0ea8 Stefan Strogin 2015-04-08  65  	}
8b0c0ea8 Stefan Strogin 2015-04-08  66  	mutex_unlock(&cma->lock);
8b0c0ea8 Stefan Strogin 2015-04-08 @67  	*val = maxchunk << cma->order_per_bit;
c8e6dfcb Dmitry Safonov 2015-04-08  68  
c8e6dfcb Dmitry Safonov 2015-04-08  69  	return 0;
c8e6dfcb Dmitry Safonov 2015-04-08  70  }

---
0-DAY kernel test infrastructure Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

PATCH 1/1 mm-cma-add-functions-to-get-region-pages-counters-fix-3

Fix for the next compiler warnings:
mm/cma_debug.c:45 cma_used_get() warn: should 'used << cma->order_per_bit' be a 64 bit type? mm/cma_debug.c:67 cma_maxchunk_get() warn: should 'maxchunk << cma->order_per_bit' be a 64 bit type?

Cc Andrew Morton <[email protected]>
Cc Michal Nazarewicz <[email protected]>
Cc Stefan Strogin <[email protected]>
Cc Marek Szyprowski <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Pintu Kumar <[email protected]>
Cc Weijie Yang <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Vyacheslav Tyrtov <[email protected]>
Cc Aleksei Mateosian <[email protected]>
Cc Sasha Levin <[email protected]>
Cc Michal Hocko <[email protected]>
---
 mm/cma_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/cma_debug.c +2 -2
index 835e761..9459842 100644
@@ -42,7 +42,7 @@ static int cma_used_get(void *data, u64 *val)
 	/* pages counter is smaller than sizeof(int) */
 	used = bitmap_weight(cma->bitmap, (int)cma->count);
 	mutex_unlock(&cma->lock);
-	*val = used << cma->order_per_bit;
+	*val = (u64)used << cma->order_per_bit;
 
 	return 0;
 }
@@ -64,7 +64,7 @@ static int cma_maxchunk_get(void *data, u64 *val)
 		maxchunk = max(end - start, maxchunk);
 	}
 	mutex_unlock(&cma->lock);
-	*val = maxchunk << cma->order_per_bit;
+	*val = (u64)maxchunk << cma->order_per_bit;
 
 	return 0;
 }
Signature · 7 lines
2.3.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH] mm-cma-add-functions-to-get-region-pages-counters-fix-3

Quoted 6 lines · Dmitry Safonov

Fix for the next compiler warnings:
mm/cma_debug.c:45 cma_used_get() warn: should 'used << cma->order_per_bit' be a 64 bit type? mm/cma_debug.c:67 cma_maxchunk_get() warn: should 'maxchunk << cma->order_per_bit' be a 64 bit type?

Cc Andrew Morton <[email protected]>
Cc Michal Nazarewicz <[email protected]>
Quoted 40 lines
Cc Stefan Strogin <[email protected]>
Cc Marek Szyprowski <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Pintu Kumar <[email protected]>
Cc Weijie Yang <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Vyacheslav Tyrtov <[email protected]>
Cc Aleksei Mateosian <[email protected]>
Cc Sasha Levin <[email protected]>
Cc Michal Hocko <[email protected]>
---
 mm/cma_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/cma_debug.c +2 -2
index 835e761..9459842 100644
@@ -42,7 +42,7 @@ static int cma_used_get(void *data, u64 *val)
 	/* pages counter is smaller than sizeof(int) */
 	used = bitmap_weight(cma->bitmap, (int)cma->count);
 	mutex_unlock(&cma->lock);
-	*val = used << cma->order_per_bit;
+	*val = (u64)used << cma->order_per_bit;
 
 	return 0;
 }
@@ -64,7 +64,7 @@ static int cma_maxchunk_get(void *data, u64 *val)
 		maxchunk = max(end - start, maxchunk);
 	}
 	mutex_unlock(&cma->lock);
-	*val = maxchunk << cma->order_per_bit;
+	*val = (u64)maxchunk << cma->order_per_bit;
 
 	return 0;
 }
Signature · 1 line
2.3.5
Signature · 10 lines
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>