Skip to content

Commit

Permalink
net/fq_impl: Use the bitmap API to allocate bitmaps
Browse files Browse the repository at this point in the history
Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/c7bf099af07eb497b02d195906ee8c11fea3b3bd.1657377335.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Christophe JAILLET authored and Jakub Kicinski committed Jul 12, 2022
1 parent e7bde1c commit 2b8bf3d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/net/fq_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ static int fq_init(struct fq *fq, int flows_cnt)
if (!fq->flows)
return -ENOMEM;

fq->flows_bitmap = kcalloc(BITS_TO_LONGS(fq->flows_cnt), sizeof(long),
GFP_KERNEL);
fq->flows_bitmap = bitmap_zalloc(fq->flows_cnt, GFP_KERNEL);
if (!fq->flows_bitmap) {
kvfree(fq->flows);
fq->flows = NULL;
Expand All @@ -383,7 +382,7 @@ static void fq_reset(struct fq *fq,
kvfree(fq->flows);
fq->flows = NULL;

kfree(fq->flows_bitmap);
bitmap_free(fq->flows_bitmap);
fq->flows_bitmap = NULL;
}

Expand Down

0 comments on commit 2b8bf3d

Please sign in to comment.