summaryrefslogtreecommitdiff
path: root/kernel/watch_queue.c
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2022-03-11 13:24:15 +0000
committerLinus Torvalds <torvalds@linux-foundation.org>2022-03-11 10:17:12 -0800
commita66bd7575b5f449ee0ba20cfd21c3bc5b04ef361 (patch)
tree2171425ee45eb2686cab062a815cface77e2cbf3 /kernel/watch_queue.c
parent96a4d8912b28451cd62825fd7caa0e66e091d938 (diff)
downloadlwn-a66bd7575b5f449ee0ba20cfd21c3bc5b04ef361.tar.gz
lwn-a66bd7575b5f449ee0ba20cfd21c3bc5b04ef361.zip
watch_queue: Use the bitmap API when applicable
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>
Diffstat (limited to 'kernel/watch_queue.c')
-rw-r--r--kernel/watch_queue.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index 4bcd400984a7..5b516eb2c7cc 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -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)
@@ -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;