mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
mm, memcg: use consistent gfp flags during readahead
Vladimir has noticed that we might declare memcg oom even during readahead because read_pages only uses GFP_KERNEL (with mapping_gfp restriction) while __do_page_cache_readahead uses page_cache_alloc_readahead which adds __GFP_NORETRY to prevent from OOMs. This gfp mask discrepancy is really unfortunate and easily fixable. Drop page_cache_alloc_readahead() which only has one user and outsource the gfp_mask logic into readahead_gfp_mask and propagate this mask from __do_page_cache_readahead down to read_pages. This alone would have only very limited impact as most filesystems are implementing ->readpages and the common implementation mpage_readpages does GFP_KERNEL (with mapping_gfp restriction) again. We can tell it to use readahead_gfp_mask instead as this function is called only during readahead as well. The same applies to read_cache_pages. ext4 has its own ext4_mpage_readpages but the path which has pages != NULL can use the same gfp mask. Btrfs, cifs, f2fs and orangefs are doing a very similar pattern to mpage_readpages so the same can be applied to them as well. [[email protected]: coding-style fixes] [[email protected]: restrict gfp mask in mpage_alloc] Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Michal Hocko <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: Chris Mason <[email protected]> Cc: Steve French <[email protected]> Cc: Theodore Ts'o <[email protected]> Cc: Jan Kara <[email protected]> Cc: Mike Marshall <[email protected]> Cc: Jaegeuk Kim <[email protected]> Cc: Changman Lee <[email protected]> Cc: Chao Yu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
e5e3f4c4f0
commit
8a5c743e30
8 changed files with 19 additions and 16 deletions
|
|
@ -71,6 +71,8 @@ mpage_alloc(struct block_device *bdev,
|
|||
{
|
||||
struct bio *bio;
|
||||
|
||||
/* Restrict the given (page cache) mask for slab allocations */
|
||||
gfp_flags &= GFP_KERNEL;
|
||||
bio = bio_alloc(gfp_flags, nr_vecs);
|
||||
|
||||
if (bio == NULL && (current->flags & PF_MEMALLOC)) {
|
||||
|
|
@ -362,7 +364,7 @@ mpage_readpages(struct address_space *mapping, struct list_head *pages,
|
|||
sector_t last_block_in_bio = 0;
|
||||
struct buffer_head map_bh;
|
||||
unsigned long first_logical_block = 0;
|
||||
gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL);
|
||||
gfp_t gfp = readahead_gfp_mask(mapping);
|
||||
|
||||
map_bh.b_state = 0;
|
||||
map_bh.b_size = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue