Skip to content

Commit

Permalink
watch_queue: Use the bitmap API when applicable
Browse files Browse the repository at this point in the history
Use bitmap_alloc() to simplify code, improve the semantic and reduce
some open-coded arithmetic in allocator arguments.

Also change a memset(0xff) into an equivalent bitmap_fill() to keep
consistency.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Christophe JAILLET authored and Linus Torvalds committed Mar 11, 2022
1 parent 96a4d89 commit a66bd75
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions kernel/watch_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
struct page **pages;
unsigned long *bitmap;
unsigned long user_bufs;
unsigned int bmsize;
int ret, i, nr_pages;

if (!wqueue)
Expand Down Expand Up @@ -259,13 +258,11 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
pages[i]->index = i * WATCH_QUEUE_NOTES_PER_PAGE;
}

bmsize = (nr_notes + BITS_PER_LONG - 1) / BITS_PER_LONG;
bmsize *= sizeof(unsigned long);
bitmap = kmalloc(bmsize, GFP_KERNEL);
bitmap = bitmap_alloc(nr_notes, GFP_KERNEL);
if (!bitmap)
goto error_p;

memset(bitmap, 0xff, bmsize);
bitmap_fill(bitmap, nr_notes);
wqueue->notes = pages;
wqueue->notes_bitmap = bitmap;
wqueue->nr_pages = nr_pages;
Expand Down

0 comments on commit a66bd75

Please sign in to comment.