Re: [PATCH] mm: Use GFP_KERNEL allocation for the page cache in page_cache_read

From: Dave Chinner
Date: Thu Mar 19 2015 - 23:57:38 EST


On Thu, Mar 19, 2015 at 02:55:58PM +0100, Michal Hocko wrote:
> @@ -2701,13 +2701,24 @@ static int __do_fault(struct vm_area_struct *vma, unsigned long address,
> {
> struct vm_fault vmf;
> int ret;
> + struct address_space *mapping = vma->vm_file->f_mapping;
> + gfp_t mapping_gfp;
>
> vmf.virtual_address = (void __user *)(address & PAGE_MASK);
> vmf.pgoff = pgoff;
> vmf.flags = flags;
> vmf.page = NULL;
>
> + /*
> + * Some filesystems always drop __GFP_FS to prevent from reclaim
> + * recursion back to FS code. This is not the case here because
> + * we are at the top of the call chain. Add GFP_FS flags to prevent
> + * from premature OOM killer.
> + */
> + mapping_gfp = mapping_gfp_mask(mapping);
> + mapping_set_gfp_mask(mapping, mapping_gfp | __GFP_FS | __GFP_IO);
> ret = vma->vm_ops->fault(vma, &vmf);
> + mapping_set_gfp_mask(mapping, mapping_gfp);

Urk! The inode owns the mapping and makes these decisions, not the
page fault path. These mapping flags may be set for reasons you
don't expect or know about (e.g. a subsystem specific shrinker
constraint) so paths like this have no business clearing flags they
don't own.

cheers,

Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/