Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1375709
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 19/19] jbd2: get rid of superfluous __GFP_REPEAT |
| Date | 2016-04-11 13:20 +0200 |
| Message-ID | <rmI2S-4Vk-15@gated-at.bofh.it> (permalink) |
| References | <rmHTb-4Qu-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Michal Hocko <mhocko@suse.com>
jbd2_alloc is explicit about its allocation preferences wrt. the
allocation size. Sub page allocations go to the slab allocator
and larger are using either the page allocator or vmalloc. This
is all good but the logic is unnecessarily complex.
1) as per Ted, the vmalloc fallback is a left-over:
: jbd2_alloc is only passed in the bh->b_size, which can't be >
: PAGE_SIZE, so the code path that calls vmalloc() should never get
: called. When we conveted jbd2_alloc() to suppor sub-page size
: allocations in commit d2eecb039368, there was an assumption that it
: could be called with a size greater than PAGE_SIZE, but that's
: certaily not true today.
Moreover vmalloc allocation might even lead to a deadlock because
the callers expect GFP_NOFS context while vmalloc is GFP_KERNEL.
2) __GFP_REPEAT for requests <= PAGE_ALLOC_COSTLY_ORDER is ignored
since the flag was introduced.
Let's simplify the code flow and use the slab allocator for sub-page
requests and the page allocator for others. Even though order > 0 is
not currently used as per above leave that option open.
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
fs/jbd2/journal.c | 32 +++++++-------------------------
1 file changed, 7 insertions(+), 25 deletions(-)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 435f0b26ac20..bd7c31d8c05e 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2328,18 +2328,10 @@ void *jbd2_alloc(size_t size, gfp_t flags)
BUG_ON(size & (size-1)); /* Must be a power of 2 */
- flags |= __GFP_REPEAT;
- if (size == PAGE_SIZE)
- ptr = (void *)__get_free_pages(flags, 0);
- else if (size > PAGE_SIZE) {
- int order = get_order(size);
-
- if (order < 3)
- ptr = (void *)__get_free_pages(flags, order);
- else
- ptr = vmalloc(size);
- } else
+ if (size < PAGE_SIZE)
ptr = kmem_cache_alloc(get_slab(size), flags);
+ else
+ ptr = (void *)__get_free_pages(flags, get_order(size));
/* Check alignment; SLUB has gotten this wrong in the past,
* and this can lead to user data corruption! */
@@ -2350,20 +2342,10 @@ void *jbd2_alloc(size_t size, gfp_t flags)
void jbd2_free(void *ptr, size_t size)
{
- if (size == PAGE_SIZE) {
- free_pages((unsigned long)ptr, 0);
- return;
- }
- if (size > PAGE_SIZE) {
- int order = get_order(size);
-
- if (order < 3)
- free_pages((unsigned long)ptr, order);
- else
- vfree(ptr);
- return;
- }
- kmem_cache_free(get_slab(size), ptr);
+ if (size < PAGE_SIZE)
+ kmem_cache_free(get_slab(size), ptr);
+ else
+ free_pages((unsigned long)ptr, get_order(size));
};
/*
--
2.8.0.rc3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/19] get rid of superfluous __GFP_REPORT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:10 +0200
[PATCH 15/19] tile: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:10 +0200
[PATCH 18/19] crypto: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:10 +0200
Re: [PATCH 18/19] crypto: get rid of superfluous __GFP_REPEAT Herbert Xu <herbert@gondor.apana.org.au> - 2016-04-14 08:30 +0200
Re: [PATCH 18/19] crypto: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-14 09:10 +0200
Re: [PATCH 18/19] crypto: get rid of superfluous __GFP_REPEAT Herbert Xu <herbert@gondor.apana.org.au> - 2016-04-14 10:20 +0200
[PATCH resend] crypto: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-14 11:00 +0200
Re: [PATCH resend] crypto: get rid of superfluous __GFP_REPEAT Herbert Xu <herbert@gondor.apana.org.au> - 2016-04-15 16:40 +0200
[PATCH 09/19] parisc: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:10 +0200
[PATCH 16/19] unicore32: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:10 +0200
[PATCH 08/19] nios2: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
[PATCH 01/19] tree wide: get rid of __GFP_REPEAT for order-0 allocations part I Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
Re: [PATCH 01/19] tree wide: get rid of __GFP_REPEAT for order-0 allocations part I David Rientjes <rientjes@google.com> - 2016-04-14 22:00 +0200
Re: [PATCH 01/19] tree wide: get rid of __GFP_REPEAT for order-0 allocations part I Michal Hocko <mhocko@kernel.org> - 2016-04-15 09:50 +0200
[PATCH 06/19] arc: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
Re: [PATCH 06/19] arc: get rid of superfluous __GFP_REPEAT Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-04-11 16:30 +0200
[PATCH 11/19] powerpc: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
[PATCH 10/19] score: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
[PATCH 07/19] mips: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
[PATCH 19/19] jbd2: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
[PATCH 13/19] s390: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
Re: [PATCH 13/19] s390: get rid of superfluous __GFP_REPEAT Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-04-11 13:30 +0200
Re: [PATCH 13/19] s390: get rid of superfluous __GFP_REPEAT Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-04-11 14:50 +0200
[PATCH 12/19] sparc: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
[PATCH 04/19] arm: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
[PATCH 03/19] x86/efi: get rid of superfluous __GFP_REPEAT Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
Re: [PATCH 03/19] x86/efi: get rid of superfluous __GFP_REPEAT Matt Fleming <matt@codeblueprint.co.uk> - 2016-04-12 18:00 +0200
[PATCH 17/19] dm: get rid of superfluous gfp flags Michal Hocko <mhocko@kernel.org> - 2016-04-11 13:20 +0200
Re: [PATCH 17/19] dm: get rid of superfluous gfp flags Mikulas Patocka <mpatocka@redhat.com> - 2016-04-15 14:30 +0200
Re: [PATCH 17/19] dm: get rid of superfluous gfp flags Michal Hocko <mhocko@kernel.org> - 2016-04-15 15:10 +0200
CC in git cover letter vs patches (was Re: [PATCH 0/19] get rid of superfluous __GFP_REPORT) Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-04-13 13:30 +0200
Re: CC in git cover letter vs patches (was Re: [PATCH 0/19] get rid of superfluous __GFP_REPORT) Michal Hocko <mhocko@kernel.org> - 2016-04-13 15:40 +0200
csiph-web