Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1569508

[PATCH 8/9] bcache: use kvmalloc

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 8/9] bcache: use kvmalloc
Date 2017-01-30 11:00 +0100
Message-ID <t5gUG-2oF-19@gated-at.bofh.it> (permalink)
References <t5gUF-2oF-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Michal Hocko <mhocko@suse.com>

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

Cc: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
 drivers/md/bcache/super.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 3a19cbc8b230..4cb6b88a1465 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -767,16 +767,12 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
 	}
 
 	n = d->nr_stripes * sizeof(atomic_t);
-	d->stripe_sectors_dirty = n < PAGE_SIZE << 6
-		? kzalloc(n, GFP_KERNEL)
-		: vzalloc(n);
+	d->stripe_sectors_dirty = kvzalloc(n, GFP_KERNEL);
 	if (!d->stripe_sectors_dirty)
 		return -ENOMEM;
 
 	n = BITS_TO_LONGS(d->nr_stripes) * sizeof(unsigned long);
-	d->full_dirty_stripes = n < PAGE_SIZE << 6
-		? kzalloc(n, GFP_KERNEL)
-		: vzalloc(n);
+	d->full_dirty_stripes = kvzalloc(n, GFP_KERNEL);
 	if (!d->full_dirty_stripes)
 		return -ENOMEM;
 
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6 v3] kvmalloc Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
  [PATCH 8/9] bcache: use kvmalloc Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
    Re: [PATCH 8/9] bcache: use kvmalloc Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 18:00 +0100
      Re: [PATCH 8/9] bcache: use kvmalloc Michal Hocko <mhocko@kernel.org> - 2017-01-30 18:30 +0100
  [PATCH 9/9] net, bpf: use kvzalloc helper Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
    Re: [PATCH 9/9] net, bpf: use kvzalloc helper Michal Hocko <mhocko@kernel.org> - 2017-01-30 18:30 +0100
  [PATCH 4/9] ila: simplify a strange allocation pattern Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
    Re: [PATCH 4/9] ila: simplify a strange allocation pattern Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 16:30 +0100
  [PATCH 2/9] mm: support __GFP_REPEAT in kvmalloc_node for >32kB Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
  [PATCH 7/9] md: use kvmalloc rather than opencoded variant Michal Hocko <mhocko@kernel.org> - 2017-01-30 11:00 +0100
    Re: [PATCH 7/9] md: use kvmalloc rather than opencoded variant Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 18:00 +0100
    Re: [PATCH 7/9] md: use kvmalloc rather than opencoded variant Mikulas Patocka <mpatocka@redhat.com> - 2017-02-01 18:40 +0100
      Re: [PATCH 7/9] md: use kvmalloc rather than opencoded variant Michal Hocko <mhocko@kernel.org> - 2017-02-01 19:00 +0100
  Re: [PATCH 5/9] treewide: use kv[mz]alloc* rather than opencoded  variants Leon Romanovsky <leon@kernel.org> - 2017-01-30 11:40 +0100
  Re: [PATCH 5/9] treewide: use kv[mz]alloc* rather than opencoded  variants Vlastimil Babka <vbabka@suse.cz> - 2017-01-30 17:40 +0100
  Re: [PATCH 5/9] treewide: use kv[mz]alloc* rather than opencoded variants Kees Cook <keescook@chromium.org> - 2017-01-30 20:30 +0100
  Re: [PATCH 0/6 v3] kvmalloc Michal Hocko <mhocko@kernel.org> - 2017-02-05 11:30 +0100

csiph-web