linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/cma_debug: fix debugging alloc/free interface
@ 2015-07-15  6:35 Joonsoo Kim
  2015-07-15  6:35 ` [PATCH 2/2] mm/cma_debug: correct size input to bitmap function Joonsoo Kim
  2015-07-15 12:03 ` [PATCH 1/2] mm/cma_debug: fix debugging alloc/free interface Michal Nazarewicz
  0 siblings, 2 replies; 4+ messages in thread
From: Joonsoo Kim @ 2015-07-15  6:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Sasha Levin, Stefan Strogin, Michal Nazarewicz, linux-kernel,
	linux-mm, Joonsoo Kim

CMA has alloc/free interface for debugging. It is intended that alloc/free
occurs in specific CMA region, but, currently, alloc/free interface is
on root dir due to the bug so we can't select CMA region where alloc/free
happens.

This patch fixes this problem by making alloc/free interface per
CMA region.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 mm/cma_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/cma_debug.c b/mm/cma_debug.c
index 7621ee3..22190a7 100644
--- a/mm/cma_debug.c
+++ b/mm/cma_debug.c
@@ -170,10 +170,10 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
 
 	tmp = debugfs_create_dir(name, cma_debugfs_root);
 
-	debugfs_create_file("alloc", S_IWUSR, cma_debugfs_root, cma,
+	debugfs_create_file("alloc", S_IWUSR, tmp, cma,
 				&cma_alloc_fops);
 
-	debugfs_create_file("free", S_IWUSR, cma_debugfs_root, cma,
+	debugfs_create_file("free", S_IWUSR, tmp, cma,
 				&cma_free_fops);
 
 	debugfs_create_file("base_pfn", S_IRUGO, tmp,
-- 
1.9.1

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] mm/cma_debug: correct size input to bitmap function
  2015-07-15  6:35 [PATCH 1/2] mm/cma_debug: fix debugging alloc/free interface Joonsoo Kim
@ 2015-07-15  6:35 ` Joonsoo Kim
  2015-07-15 12:03   ` Michal Nazarewicz
  2015-07-15 12:03 ` [PATCH 1/2] mm/cma_debug: fix debugging alloc/free interface Michal Nazarewicz
  1 sibling, 1 reply; 4+ messages in thread
From: Joonsoo Kim @ 2015-07-15  6:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Sasha Levin, Stefan Strogin, Michal Nazarewicz, linux-kernel,
	linux-mm, Joonsoo Kim

In CMA, 1 bit in bitmap means 1 << order_per_bits pages so
size of bitmap is cma->count >> order_per_bits rather than
just cma->count. This patch fixes it.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 mm/cma_debug.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/cma_debug.c b/mm/cma_debug.c
index 22190a7..f8e4b60 100644
--- a/mm/cma_debug.c
+++ b/mm/cma_debug.c
@@ -39,7 +39,7 @@ static int cma_used_get(void *data, u64 *val)
 
 	mutex_lock(&cma->lock);
 	/* pages counter is smaller than sizeof(int) */
-	used = bitmap_weight(cma->bitmap, (int)cma->count);
+	used = bitmap_weight(cma->bitmap, (int)cma_bitmap_maxno(cma));
 	mutex_unlock(&cma->lock);
 	*val = (u64)used << cma->order_per_bit;
 
@@ -52,13 +52,14 @@ static int cma_maxchunk_get(void *data, u64 *val)
 	struct cma *cma = data;
 	unsigned long maxchunk = 0;
 	unsigned long start, end = 0;
+	unsigned long bitmap_maxno = cma_bitmap_maxno(cma);
 
 	mutex_lock(&cma->lock);
 	for (;;) {
-		start = find_next_zero_bit(cma->bitmap, cma->count, end);
+		start = find_next_zero_bit(cma->bitmap, bitmap_maxno, end);
 		if (start >= cma->count)
 			break;
-		end = find_next_bit(cma->bitmap, cma->count, start);
+		end = find_next_bit(cma->bitmap, bitmap_maxno, start);
 		maxchunk = max(end - start, maxchunk);
 	}
 	mutex_unlock(&cma->lock);
-- 
1.9.1

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mm/cma_debug: fix debugging alloc/free interface
  2015-07-15  6:35 [PATCH 1/2] mm/cma_debug: fix debugging alloc/free interface Joonsoo Kim
  2015-07-15  6:35 ` [PATCH 2/2] mm/cma_debug: correct size input to bitmap function Joonsoo Kim
@ 2015-07-15 12:03 ` Michal Nazarewicz
  1 sibling, 0 replies; 4+ messages in thread
From: Michal Nazarewicz @ 2015-07-15 12:03 UTC (permalink / raw)
  To: Joonsoo Kim, Andrew Morton
  Cc: Sasha Levin, Stefan Strogin, linux-kernel, linux-mm, Joonsoo Kim

On Wed, Jul 15 2015, Joonsoo Kim wrote:
> CMA has alloc/free interface for debugging. It is intended that alloc/free
> occurs in specific CMA region, but, currently, alloc/free interface is
> on root dir due to the bug so we can't select CMA region where alloc/free
> happens.
>
> This patch fixes this problem by making alloc/free interface per
> CMA region.
>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> ---
>  mm/cma_debug.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/cma_debug.c b/mm/cma_debug.c
> index 7621ee3..22190a7 100644
> --- a/mm/cma_debug.c
> +++ b/mm/cma_debug.c
> @@ -170,10 +170,10 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
>  
>  	tmp = debugfs_create_dir(name, cma_debugfs_root);
>  
> -	debugfs_create_file("alloc", S_IWUSR, cma_debugfs_root, cma,
> +	debugfs_create_file("alloc", S_IWUSR, tmp, cma,
>  				&cma_alloc_fops);
>  
> -	debugfs_create_file("free", S_IWUSR, cma_debugfs_root, cma,
> +	debugfs_create_file("free", S_IWUSR, tmp, cma,
>  				&cma_free_fops);
>  
>  	debugfs_create_file("base_pfn", S_IRUGO, tmp,
> -- 
> 1.9.1
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] mm/cma_debug: correct size input to bitmap function
  2015-07-15  6:35 ` [PATCH 2/2] mm/cma_debug: correct size input to bitmap function Joonsoo Kim
@ 2015-07-15 12:03   ` Michal Nazarewicz
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Nazarewicz @ 2015-07-15 12:03 UTC (permalink / raw)
  To: Joonsoo Kim, Andrew Morton
  Cc: Sasha Levin, Stefan Strogin, linux-kernel, linux-mm, Joonsoo Kim

On Wed, Jul 15 2015, Joonsoo Kim wrote:
> In CMA, 1 bit in bitmap means 1 << order_per_bits pages so
> size of bitmap is cma->count >> order_per_bits rather than
> just cma->count. This patch fixes it.
>
> Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> ---
>  mm/cma_debug.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/cma_debug.c b/mm/cma_debug.c
> index 22190a7..f8e4b60 100644
> --- a/mm/cma_debug.c
> +++ b/mm/cma_debug.c
> @@ -39,7 +39,7 @@ static int cma_used_get(void *data, u64 *val)
>  
>  	mutex_lock(&cma->lock);
>  	/* pages counter is smaller than sizeof(int) */
> -	used = bitmap_weight(cma->bitmap, (int)cma->count);
> +	used = bitmap_weight(cma->bitmap, (int)cma_bitmap_maxno(cma));
>  	mutex_unlock(&cma->lock);
>  	*val = (u64)used << cma->order_per_bit;
>  
> @@ -52,13 +52,14 @@ static int cma_maxchunk_get(void *data, u64 *val)
>  	struct cma *cma = data;
>  	unsigned long maxchunk = 0;
>  	unsigned long start, end = 0;
> +	unsigned long bitmap_maxno = cma_bitmap_maxno(cma);
>  
>  	mutex_lock(&cma->lock);
>  	for (;;) {
> -		start = find_next_zero_bit(cma->bitmap, cma->count, end);
> +		start = find_next_zero_bit(cma->bitmap, bitmap_maxno, end);
>  		if (start >= cma->count)
>  			break;
> -		end = find_next_bit(cma->bitmap, cma->count, start);
> +		end = find_next_bit(cma->bitmap, bitmap_maxno, start);
>  		maxchunk = max(end - start, maxchunk);
>  	}
>  	mutex_unlock(&cma->lock);
> -- 
> 1.9.1
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-15 12:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-15  6:35 [PATCH 1/2] mm/cma_debug: fix debugging alloc/free interface Joonsoo Kim
2015-07-15  6:35 ` [PATCH 2/2] mm/cma_debug: correct size input to bitmap function Joonsoo Kim
2015-07-15 12:03   ` Michal Nazarewicz
2015-07-15 12:03 ` [PATCH 1/2] mm/cma_debug: fix debugging alloc/free interface Michal Nazarewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox