linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap.
@ 2018-12-24  7:06 Huang Shijie
  2018-12-24  7:06 ` [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool Huang Shijie
  2018-12-25  1:57 ` [PATCH 1/2 fix] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap Huang Shijie
  0 siblings, 2 replies; 8+ messages in thread
From: Huang Shijie @ 2018-12-24  7:06 UTC (permalink / raw)
  To: akpm; +Cc: sfr, alexey.skidanov, linux-kernel, shijie8, Huang Shijie

Some devices may have over 1G memory on chip.
In some cases, the nbytes may big then 4M which is the bounday of
the memory buddy system. So use vzalloc_node() to allocate the bitmap.

Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai>
---
 lib/genalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 5deb25c40a5a..0d0ff9f0483f 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -187,7 +187,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phy
 	int nbytes = sizeof(struct gen_pool_chunk) +
 				BITS_TO_LONGS(nbits) * sizeof(long);
 
-	chunk = kzalloc_node(nbytes, GFP_KERNEL, nid);
+	chunk = vzalloc_node(nbytes, nid);
 	if (unlikely(chunk == NULL))
 		return -ENOMEM;
 
-- 
2.17.1


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

* [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool
  2018-12-24  7:06 [PATCH 1/2] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap Huang Shijie
@ 2018-12-24  7:06 ` Huang Shijie
  2018-12-28  5:49   ` Andrew Morton
  2019-01-03  7:55   ` Christoph Hellwig
  2018-12-25  1:57 ` [PATCH 1/2 fix] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap Huang Shijie
  1 sibling, 2 replies; 8+ messages in thread
From: Huang Shijie @ 2018-12-24  7:06 UTC (permalink / raw)
  To: akpm; +Cc: sfr, alexey.skidanov, linux-kernel, shijie8, Huang Shijie

We may use the addr_in_gen_pool() in the driver module.
So export the addr_in_gen_pool for the compiling.

Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai>
---
 lib/genalloc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 0d0ff9f0483f..9da91a16046f 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -450,6 +450,7 @@ bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start,
 	rcu_read_unlock();
 	return found;
 }
+EXPORT_SYMBOL(addr_in_gen_pool);
 
 /**
  * gen_pool_avail - get available free space of the pool
-- 
2.17.1


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

* [PATCH 1/2 fix] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap.
  2018-12-24  7:06 [PATCH 1/2] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap Huang Shijie
  2018-12-24  7:06 ` [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool Huang Shijie
@ 2018-12-25  1:57 ` Huang Shijie
  1 sibling, 0 replies; 8+ messages in thread
From: Huang Shijie @ 2018-12-25  1:57 UTC (permalink / raw)
  To: akpm; +Cc: sfr, alexey.skidanov, linux-kernel, shijie8, Huang Shijie

Some devices may have big memory on chip, such as over 1G.
In some cases, the nbytes maybe bigger then 4M which is the bounday of
the memory buddy system (4K default).

So use vzalloc_node() to allocate the bitmap.
Also use vfree to free the it.

Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai>
---
The v1 did not free the memory with vfree.
This patch fixes it.

---
 lib/genalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 5deb25c40a5a..f365d71cdc77 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -187,7 +187,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phy
 	int nbytes = sizeof(struct gen_pool_chunk) +
 				BITS_TO_LONGS(nbits) * sizeof(long);
 
-	chunk = kzalloc_node(nbytes, GFP_KERNEL, nid);
+	chunk = vzalloc_node(nbytes, nid);
 	if (unlikely(chunk == NULL))
 		return -ENOMEM;
 
@@ -251,7 +251,7 @@ void gen_pool_destroy(struct gen_pool *pool)
 		bit = find_next_bit(chunk->bits, end_bit, 0);
 		BUG_ON(bit < end_bit);
 
-		kfree(chunk);
+		vfree(chunk);
 	}
 	kfree_const(pool->name);
 	kfree(pool);
-- 
2.17.1


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

* Re: [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool
  2018-12-24  7:06 ` [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool Huang Shijie
@ 2018-12-28  5:49   ` Andrew Morton
  2018-12-28  7:45     ` Huang Shijie
  2019-01-03  7:55   ` Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2018-12-28  5:49 UTC (permalink / raw)
  To: Huang Shijie; +Cc: sfr, alexey.skidanov, linux-kernel, shijie8

On Mon, 24 Dec 2018 15:06:22 +0800 Huang Shijie <sjhuang@iluvatar.ai> wrote:

> We may use the addr_in_gen_pool() in the driver module.
> So export the addr_in_gen_pool for the compiling.
> 
> ...
>
> --- a/lib/genalloc.c
> +++ b/lib/genalloc.c
> @@ -450,6 +450,7 @@ bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start,
>  	rcu_read_unlock();
>  	return found;
>  }
> +EXPORT_SYMBOL(addr_in_gen_pool);
>  
>  /**
>   * gen_pool_avail - get available free space of the pool

OK, but...  The name is poor.

q:/usr/src/25> grep EXPORT_SYMBOL lib/genalloc.c
EXPORT_SYMBOL(gen_pool_create);
EXPORT_SYMBOL(gen_pool_add_virt);
EXPORT_SYMBOL(gen_pool_virt_to_phys);
EXPORT_SYMBOL(gen_pool_destroy);
EXPORT_SYMBOL(gen_pool_alloc);
EXPORT_SYMBOL(gen_pool_alloc_algo);
EXPORT_SYMBOL(gen_pool_dma_alloc);
EXPORT_SYMBOL(gen_pool_free);
EXPORT_SYMBOL(gen_pool_for_each_chunk);
EXPORT_SYMBOL_GPL(gen_pool_avail);
EXPORT_SYMBOL_GPL(gen_pool_size);
EXPORT_SYMBOL(gen_pool_set_algo);
EXPORT_SYMBOL(gen_pool_first_fit);
EXPORT_SYMBOL(gen_pool_first_fit_align);
EXPORT_SYMBOL(gen_pool_fixed_alloc);
EXPORT_SYMBOL(gen_pool_first_fit_order_align);
EXPORT_SYMBOL(gen_pool_best_fit);
EXPORT_SYMBOL_GPL(gen_pool_get);
EXPORT_SYMBOL(devm_gen_pool_create);
EXPORT_SYMBOL_GPL(of_gen_pool_get);

See?  Almost everything is called gen_pool_foo.  Which is correct as
per kernel conventions.  We should globally rename this to
gen_pool_has_addr or similar.

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

* Re: [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool
  2018-12-28  5:49   ` Andrew Morton
@ 2018-12-28  7:45     ` Huang Shijie
  0 siblings, 0 replies; 8+ messages in thread
From: Huang Shijie @ 2018-12-28  7:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: sfr, alexey.skidanov, linux-kernel, shijie8

On Thu, Dec 27, 2018 at 09:49:29PM -0800, Andrew Morton wrote:
> On Mon, 24 Dec 2018 15:06:22 +0800 Huang Shijie <sjhuang@iluvatar.ai> wrote:
> 
> > We may use the addr_in_gen_pool() in the driver module.
> > So export the addr_in_gen_pool for the compiling.
> > 
> > ...
> >
> > --- a/lib/genalloc.c
> > +++ b/lib/genalloc.c
> > @@ -450,6 +450,7 @@ bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start,
> >  	rcu_read_unlock();
> >  	return found;
> >  }
> > +EXPORT_SYMBOL(addr_in_gen_pool);
> >  
> >  /**
> >   * gen_pool_avail - get available free space of the pool
> 
> OK, but...  The name is poor.
> 
> q:/usr/src/25> grep EXPORT_SYMBOL lib/genalloc.c
> EXPORT_SYMBOL(gen_pool_create);
> EXPORT_SYMBOL(gen_pool_add_virt);
> EXPORT_SYMBOL(gen_pool_virt_to_phys);
> EXPORT_SYMBOL(gen_pool_destroy);
> EXPORT_SYMBOL(gen_pool_alloc);
> EXPORT_SYMBOL(gen_pool_alloc_algo);
> EXPORT_SYMBOL(gen_pool_dma_alloc);
> EXPORT_SYMBOL(gen_pool_free);
> EXPORT_SYMBOL(gen_pool_for_each_chunk);
> EXPORT_SYMBOL_GPL(gen_pool_avail);
> EXPORT_SYMBOL_GPL(gen_pool_size);
> EXPORT_SYMBOL(gen_pool_set_algo);
> EXPORT_SYMBOL(gen_pool_first_fit);
> EXPORT_SYMBOL(gen_pool_first_fit_align);
> EXPORT_SYMBOL(gen_pool_fixed_alloc);
> EXPORT_SYMBOL(gen_pool_first_fit_order_align);
> EXPORT_SYMBOL(gen_pool_best_fit);
> EXPORT_SYMBOL_GPL(gen_pool_get);
> EXPORT_SYMBOL(devm_gen_pool_create);
> EXPORT_SYMBOL_GPL(of_gen_pool_get);
> 
> See?  Almost everything is called gen_pool_foo.  Which is correct as
> per kernel conventions.  We should globally rename this to
> gen_pool_has_addr or similar.
okay, I will do it right now..

Thanks
Huang Shijie

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

* Re: [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool
  2018-12-24  7:06 ` [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool Huang Shijie
  2018-12-28  5:49   ` Andrew Morton
@ 2019-01-03  7:55   ` Christoph Hellwig
  2019-01-03 10:11     ` Huang Shijie
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2019-01-03  7:55 UTC (permalink / raw)
  To: Huang Shijie; +Cc: akpm, sfr, alexey.skidanov, linux-kernel, shijie8

On Mon, Dec 24, 2018 at 03:06:22PM +0800, Huang Shijie wrote:
> We may use the addr_in_gen_pool() in the driver module.
> So export the addr_in_gen_pool for the compiling.

Please send this along with the driver that plans to use it.

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

* Re: [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool
  2019-01-03  7:55   ` Christoph Hellwig
@ 2019-01-03 10:11     ` Huang Shijie
  2019-01-03 15:37       ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Huang Shijie @ 2019-01-03 10:11 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: akpm, sfr, alexey.skidanov, linux-kernel, shijie8

On Wed, Jan 02, 2019 at 11:55:50PM -0800, Christoph Hellwig wrote:
> On Mon, Dec 24, 2018 at 03:06:22PM +0800, Huang Shijie wrote:
> > We may use the addr_in_gen_pool() in the driver module.
> > So export the addr_in_gen_pool for the compiling.
> 
> Please send this along with the driver that plans to use it.
The driver is still under develop with the FPGA, and our hardware chip maybe
tape out at next year.

Thanks
Huang Shijie



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

* Re: [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool
  2019-01-03 10:11     ` Huang Shijie
@ 2019-01-03 15:37       ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2019-01-03 15:37 UTC (permalink / raw)
  To: Huang Shijie
  Cc: Christoph Hellwig, akpm, sfr, alexey.skidanov, linux-kernel, shijie8

On Thu, Jan 03, 2019 at 06:11:59PM +0800, Huang Shijie wrote:
> On Wed, Jan 02, 2019 at 11:55:50PM -0800, Christoph Hellwig wrote:
> > On Mon, Dec 24, 2018 at 03:06:22PM +0800, Huang Shijie wrote:
> > > We may use the addr_in_gen_pool() in the driver module.
> > > So export the addr_in_gen_pool for the compiling.
> > 
> > Please send this along with the driver that plans to use it.
> The driver is still under develop with the FPGA, and our hardware chip maybe
> tape out at next year.

So lets wait for the driver submission or another user before we
export the symbol.

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

end of thread, other threads:[~2019-01-03 15:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-24  7:06 [PATCH 1/2] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap Huang Shijie
2018-12-24  7:06 ` [PATCH 2/2] lib/genalloc.c: export symbol addr_in_gen_pool Huang Shijie
2018-12-28  5:49   ` Andrew Morton
2018-12-28  7:45     ` Huang Shijie
2019-01-03  7:55   ` Christoph Hellwig
2019-01-03 10:11     ` Huang Shijie
2019-01-03 15:37       ` Christoph Hellwig
2018-12-25  1:57 ` [PATCH 1/2 fix] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap Huang Shijie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).