linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huang Shijie <sjhuang@iluvatar.ai>
To: <akpm@linux-foundation.org>
Cc: <sfr@canb.auug.org.au>, <alexey.skidanov@intel.com>,
	<linux-kernel@vger.kernel.org>, <shijie8@gmail.com>,
	Huang Shijie <sjhuang@iluvatar.ai>
Subject: [PATCH 1/2 fix] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap.
Date: Tue, 25 Dec 2018 09:57:01 +0800	[thread overview]
Message-ID: <20181225015701.6289-1-sjhuang@iluvatar.ai> (raw)
In-Reply-To: <20181224070622.22197-1-sjhuang@iluvatar.ai>

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


      parent reply	other threads:[~2018-12-25  2:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Huang Shijie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181225015701.6289-1-sjhuang@iluvatar.ai \
    --to=sjhuang@iluvatar.ai \
    --cc=akpm@linux-foundation.org \
    --cc=alexey.skidanov@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=shijie8@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).