Skip to content

Commit bc4e54f

Browse files
Michal Hockotorvalds
authored andcommitted
drivers/md/bcache/super.c: use kvmalloc
bcache_device_init uses kmalloc for small requests and vmalloc for those which are larger than 64 pages. This alone is a strange criterion. Moreover kmalloc can fallback to vmalloc on the failure. Let's simply use kvmalloc instead as it knows how to handle the fallback properly Link: http://lkml.kernel.org/r/20170306103327.2766-5-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d224e93 commit bc4e54f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/md/bcache/super.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -767,16 +767,12 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
767767
}
768768

769769
n = d->nr_stripes * sizeof(atomic_t);
770-
d->stripe_sectors_dirty = n < PAGE_SIZE << 6
771-
? kzalloc(n, GFP_KERNEL)
772-
: vzalloc(n);
770+
d->stripe_sectors_dirty = kvzalloc(n, GFP_KERNEL);
773771
if (!d->stripe_sectors_dirty)
774772
return -ENOMEM;
775773

776774
n = BITS_TO_LONGS(d->nr_stripes) * sizeof(unsigned long);
777-
d->full_dirty_stripes = n < PAGE_SIZE << 6
778-
? kzalloc(n, GFP_KERNEL)
779-
: vzalloc(n);
775+
d->full_dirty_stripes = kvzalloc(n, GFP_KERNEL);
780776
if (!d->full_dirty_stripes)
781777
return -ENOMEM;
782778

0 commit comments

Comments
 (0)