Re: [PATCHv2, RFC 25/30] thp, mm: basic huge_fault implementation for generic_file_vm_ops
From: Hillf Danton
Date: Fri Mar 15 2013 - 03:44:57 EST
On Fri, Mar 15, 2013 at 1:50 AM, Kirill A. Shutemov
<kirill.shutemov@xxxxxxxxxxxxxxx> wrote:
>
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +static int filemap_huge_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
> +{
> + struct file *file = vma->vm_file;
> + struct address_space *mapping = file->f_mapping;
> + struct inode *inode = mapping->host;
> + pgoff_t size, offset = vmf->pgoff;
> + unsigned long address = (unsigned long) vmf->virtual_address;
> + struct page *page;
> + int ret = 0;
> +
> + BUG_ON(((address >> PAGE_SHIFT) & HPAGE_CACHE_INDEX_MASK) !=
> + (offset & HPAGE_CACHE_INDEX_MASK));
> +
> +retry:
> + page = find_get_page(mapping, offset);
> + if (!page) {
> + gfp_t gfp_mask = mapping_gfp_mask(mapping) | __GFP_COLD;
> + page = alloc_pages(gfp_mask, HPAGE_PMD_ORDER);
s/pages/pages_vma/ ?
> + if (!page) {
> + count_vm_event(THP_FAULT_FALLBACK);
> + return VM_FAULT_OOM;
> + }
--
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/