From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, peterz@infradead.org, mingo@kernel.org
Subject: Re: [PATCH 1/8] mm: replace remap_file_pages() syscall with emulation
Date: Wed, 8 Oct 2014 12:20:37 +0530 [thread overview]
Message-ID: <5434DEBD.8040607@synopsys.com> (raw)
In-Reply-To: <1399387052-31660-2-git-send-email-kirill.shutemov@linux.intel.com>
Hi Kirill,
Due to broken PAGE_FILE on arc, I was giving this emulation patch a try and it
seems we need a minor fix to this patch. I know this is not slated for merge soon,
but u can add the fix nevertheless and my Tested-by:
Problem showed up with Ingo Korb's remap-demo.c test case from [1]
[1] https://lkml.org/lkml/2014/7/14/335
On Tuesday 06 May 2014 08:07 PM, Kirill A. Shutemov wrote:
> remap_file_pages(2) was invented to be able efficiently map parts of
> huge file into limited 32-bit virtual address space such as in database
> workloads.
>
> Nonlinear mappings are pain to support and it seems there's no
> legitimate use-cases nowadays since 64-bit systems are widely available.
>
> Let's drop it and get rid of all these special-cased code.
>
> The patch replaces the syscall with emulation which creates new VMA on
> each remap.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---
....
> -}
> diff --git a/mm/mmap.c b/mm/mmap.c
> index b1202cf81f4b..4106fc833f56 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2579,6 +2579,74 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
> return vm_munmap(addr, len);
> }
>
> +
> +/*
> + * Emulation of deprecated remap_file_pages() syscall.
> + */
> +SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
> + unsigned long, prot, unsigned long, pgoff, unsigned long, flags)
> +{
> +
> + struct mm_struct *mm = current->mm;
> + struct vm_area_struct *vma;
> + unsigned long populate;
> + int ret = -EINVAL;
> +
> + printk_once(KERN_WARNING "%s (%d) calls remap_file_pages(2) which is "
> + "deprecated and no longer supported by kernel in "
> + "an efficient way.\n"
> + "Note that emulated remap_file_pages(2) can "
> + "potentially create a lot of mappings. "
> + "Consider increasing vm.max_map_count.\n",
> + current->comm, current->pid);
> +
> + if (prot)
> + return ret;
> + start = start & PAGE_MASK;
> + size = size & PAGE_MASK;
> +
> + if (start + size <= start)
> + return ret;
> +
> + /* Does pgoff wrap? */
> + if (pgoff + (size >> PAGE_SHIFT) < pgoff)
> + return ret;
> +
> + down_write(&mm->mmap_sem);
> + vma = find_vma(mm, start);
> +
> + if (!vma || !(vma->vm_flags & VM_SHARED))
> + goto out;
> +
> + if (start < vma->vm_start || start + size > vma->vm_end)
> + goto out;
> +
> + if (pgoff == linear_page_index(vma, start)) {
> + ret = 0;
> + goto out;
> + }
> +
> + prot |= vma->vm_flags & VM_READ ? PROT_READ : 0;
> + prot |= vma->vm_flags & VM_WRITE ? PROT_WRITE : 0;
> + prot |= vma->vm_flags & VM_EXEC ? PROT_EXEC : 0;
> +
> + flags &= MAP_POPULATE;
> + flags |= MAP_SHARED | MAP_FIXED;
> + if (vma->vm_flags & VM_LOCKED) {
> + flags |= MAP_LOCKED;
> + /* drop PG_Mlocked flag for over-mapped range */
> + munlock_vma_pages_range(vma, start, start + size);
> + }
> +
> + ret = do_mmap_pgoff(vma->vm_file, start, size,
> + prot, flags, pgoff, &populate);
> + if (populate)
> + mm_populate(ret, populate);
> +out:
> + up_write(&mm->mmap_sem);
On success needs to return 0, not mapped addr.
if (!IS_ERR_VALUE(ret))
ret = 0;
> + return ret;
> +}
> +
Thx,
-Vineet
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-10-08 6:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-06 14:37 [RFC, PATCH 0/8] remap_file_pages() decommission Kirill A. Shutemov
2014-05-06 14:37 ` [PATCH 1/8] mm: replace remap_file_pages() syscall with emulation Kirill A. Shutemov
2014-10-08 6:50 ` Vineet Gupta [this message]
2014-10-08 10:03 ` Kirill A. Shutemov
2014-05-06 14:37 ` [PATCH 2/8] mm: kill vm_operations_struct->remap_pages Kirill A. Shutemov
2014-05-19 15:03 ` Christoph Hellwig
2014-05-19 15:14 ` Kirill A. Shutemov
2014-05-06 14:37 ` [PATCH 3/8] mm: kill zap_details->nonlinear_vma Kirill A. Shutemov
2014-05-06 14:37 ` [PATCH 4/8] mm, rmap: kill rmap_walk_control->file_nonlinear() Kirill A. Shutemov
2014-05-06 14:37 ` [PATCH 5/8] mm, rmap: kill vma->shared.nonlinear Kirill A. Shutemov
2014-05-06 14:37 ` [PATCH 6/8] mm, rmap: kill mapping->i_mmap_nonlinear Kirill A. Shutemov
2014-05-06 14:37 ` [PATCH 7/8] mm: kill VM_NONLINEAR and FAULT_FLAG_NONLINEAR Kirill A. Shutemov
2014-05-06 14:37 ` [PATCH 8/8] mm, x86: kill pte_to_pgoff(), pgoff_to_pte() and pte_file*() Kirill A. Shutemov
2014-05-06 21:35 ` [RFC, PATCH 0/8] remap_file_pages() decommission Andrew Morton
2014-05-06 21:51 ` Linus Torvalds
2014-05-06 23:03 ` Kirill A. Shutemov
2014-05-06 23:28 ` Andrew Morton
2014-05-07 9:12 ` Peter Zijlstra
2014-05-07 16:46 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5434DEBD.8040607@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).