From: Vlastimil Babka <vbabka@suse.cz>
To: Dave Hansen <dave@sr71.net>, linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, x86@kernel.org, dave.hansen@linux.intel.com,
akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
aarcange@redhat.com, n-horiguchi@ah.jp.nec.com,
srikar@linux.vnet.ibm.com, jack@suse.cz
Subject: Re: [PATCH] mm, gup: introduce concept of "foreign" get_user_pages()
Date: Wed, 27 Jan 2016 12:30:54 +0100 [thread overview]
Message-ID: <56A8AA6E.2080705@suse.cz> (raw)
In-Reply-To: <20160122180219.164259F1@viggo.jf.intel.com>
On 01/22/2016 07:02 PM, Dave Hansen wrote:
> One of Vlastimil's comments made me go dig back in to the uprobes
> code's use of get_user_pages(). I decided to change both of them
> to be "foreign" accesses.
>
> This also fixes the nommu breakage that Vlastimil noted last time.
>
> Srikar, I'd appreciate if you can have a look at the uprobes.c
> modifications, especially the comment. I don't think this will
> change any behavior, but I want to make sure the comment is
> accurate.
>
> ---
>
> From: Dave Hansen <dave.hansen@linux.intel.com>
>
> For protection keys, we need to understand whether protections
> should be enforced in software or not. In general, we enforce
> protections when working on our own task, but not when on others.
> We call these "current" and "foreign" operations.
>
> This patch introduces a new get_user_pages() variant:
>
> get_user_pages_foreign()
>
> We modify the vanilla get_user_pages() so it can no longer be
> used on mm/tasks other than 'current/current->mm', which is by
> far the most common way it is called. Using it makes a few of
> the call sites look a bit nicer.
>
> In other words, get_user_pages_foreign() is a replacement for
> when get_user_pages() is called on non-current tsk/mm.
>
> This also switches get_user_pages_(un)locked() over to be like
> get_user_pages() and not take a tsk/mm. There is no
> get_user_pages_foreign_(un)locked(). If someone wants that
> behavior they just have to use "__" variant and pass in
> FOLL_FOREIGN explicitly.
>
> The uprobes is_trap_at_addr() location holds mmap_sem and
> calls get_user_pages(current->mm) on an instruction address. This
> makes it a pretty unique gup caller. Being an instruction access
> and also really originating from the kernel (vs. the app), I opted
> to consider this a 'foreign' access where protection keys will not
> be enforced.
>
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Cc: vbabka@suse.cz
Acked-by: Vlastimil Babka <vbabka@suse.cz>
But,
> long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
> unsigned long start, unsigned long nr_pages,
> int write, int force, struct page **pages,
> unsigned int gup_flags)
> {
> long ret;
> - down_read(&mm->mmap_sem);
> - ret = get_user_pages(tsk, mm, start, nr_pages, write, force,
> - pages, NULL);
> - up_read(&mm->mmap_sem);
> + down_read(¤t->mm->mmap_sem);
> + ret = get_user_pages(start, nr_pages, write, force, pages, NULL);
> + up_read(¤t->mm->mmap_sem);
I understand your reply to lkp report also means that this no longer locks
current's mmap_sem? :)
Vlastimil
--
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:[~2016-01-27 11:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-22 18:02 [PATCH] mm, gup: introduce concept of "foreign" get_user_pages() Dave Hansen
2016-01-22 18:16 ` kbuild test robot
2016-01-22 21:31 ` Dave Hansen
2016-01-25 13:17 ` Srikar Dronamraju
2016-01-25 18:18 ` Oleg Nesterov
2016-01-27 11:30 ` Vlastimil Babka [this message]
2016-01-27 22:59 ` Dave Hansen
-- strict thread matches above, loose matches on Subject: below --
2016-01-20 17:35 Dave Hansen
2016-01-20 17:56 ` Vlastimil Babka
2016-01-20 18:48 ` Dave Hansen
2016-01-20 19:30 ` Vlastimil Babka
2016-01-15 18:11 Dave Hansen
2016-01-18 15:20 ` Vlastimil Babka
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=56A8AA6E.2080705@suse.cz \
--to=vbabka@suse.cz \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=dave@sr71.net \
--cc=jack@suse.cz \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=srikar@linux.vnet.ibm.com \
--cc=x86@kernel.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).