aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-06-24 17:49:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-06-24 20:23:52 -0400
commitf2db19719a4e789a58ac024b43f12eeb9e458074 (patch)
tree6d25b6e8f2dcccdabd2ac56d4018c393b7593f4d /fs
parenta830627b01b26452a13abb7e7b37d39365be4b05 (diff)
jbd2: get rid of superfluous __GFP_REPEAT
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. Link: http://lkml.kernel.org/r/1464599699-30131-18-git-send-email-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Reviewed-by: Jan Kara <jack@suse.cz> Cc: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/jbd2/journal.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index b31852f76f46..e3ca4b4cac84 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2329,18 +2329,10 @@ void *jbd2_alloc(size_t size, gfp_t flags)
2329 2329
2330 BUG_ON(size & (size-1)); /* Must be a power of 2 */ 2330 BUG_ON(size & (size-1)); /* Must be a power of 2 */
2331 2331
2332 flags |= __GFP_REPEAT; 2332 if (size < PAGE_SIZE)
2333 if (size == PAGE_SIZE)
2334 ptr = (void *)__get_free_pages(flags, 0);
2335 else if (size > PAGE_SIZE) {
2336 int order = get_order(size);
2337
2338 if (order < 3)
2339 ptr = (void *)__get_free_pages(flags, order);
2340 else
2341 ptr = vmalloc(size);
2342 } else
2343 ptr = kmem_cache_alloc(get_slab(size), flags); 2333 ptr = kmem_cache_alloc(get_slab(size), flags);
2334 else
2335 ptr = (void *)__get_free_pages(flags, get_order(size));
2344 2336
2345 /* Check alignment; SLUB has gotten this wrong in the past, 2337 /* Check alignment; SLUB has gotten this wrong in the past,
2346 * and this can lead to user data corruption! */ 2338 * and this can lead to user data corruption! */
@@ -2351,20 +2343,10 @@ void *jbd2_alloc(size_t size, gfp_t flags)
2351 2343
2352void jbd2_free(void *ptr, size_t size) 2344void jbd2_free(void *ptr, size_t size)
2353{ 2345{
2354 if (size == PAGE_SIZE) { 2346 if (size < PAGE_SIZE)
2355 free_pages((unsigned long)ptr, 0); 2347 kmem_cache_free(get_slab(size), ptr);
2356 return; 2348 else
2357 } 2349 free_pages((unsigned long)ptr, get_order(size));
2358 if (size > PAGE_SIZE) {
2359 int order = get_order(size);
2360
2361 if (order < 3)
2362 free_pages((unsigned long)ptr, order);
2363 else
2364 vfree(ptr);
2365 return;
2366 }
2367 kmem_cache_free(get_slab(size), ptr);
2368}; 2350};
2369 2351
2370/* 2352/*