All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: akpm@linux-foundation.org, dan.j.williams@intel.com,
	keith.busch@intel.com, kirill.shutemov@linux.intel.com,
	pasha.tatashin@oracle.com, alexander.h.duyck@linux.intel.com,
	ira.weiny@intel.com, andreyknvl@google.com,
	arunks@codeaurora.org, vbabka@suse.cz, cl@linux.com,
	riel@surriel.com, keescook@chromium.org, hannes@cmpxchg.org,
	npiggin@gmail.com, mathieu.desnoyers@efficios.com,
	shakeelb@google.com, guro@fb.com, aarcange@redhat.com,
	hughd@google.com, jglisse@redhat.com,
	mgorman@techsingularity.net, daniel.m.jordan@oracle.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-api@vger.kernel.org
Subject: Re: [PATCH RFC 0/5] mm: process_vm_mmap() -- syscall for duplication a process mapping
Date: Thu, 16 May 2019 17:22:23 +0300	[thread overview]
Message-ID: <85562807-2a13-9aa2-e67d-15513c766eae@virtuozzo.com> (raw)
In-Reply-To: <20190516135259.GU16651@dhcp22.suse.cz>

On 16.05.2019 16:52, Michal Hocko wrote:
> On Thu 16-05-19 15:30:34, Michal Hocko wrote:
>> [You are defining a new user visible API, please always add linux-api
>>  mailing list - now done]
>>
>> On Wed 15-05-19 18:11:15, Kirill Tkhai wrote:
> [...]
>>> The proposed syscall aims to introduce an interface, which
>>> supplements currently existing process_vm_writev() and
>>> process_vm_readv(), and allows to solve the problem with
>>> anonymous memory transfer. The above example may be rewritten as:
>>>
>>> 	void *buf;
>>>
>>> 	buf = mmap(NULL, n * PAGE_SIZE, PROT_READ|PROT_WRITE,
>>> 		   MAP_PRIVATE|MAP_ANONYMOUS, ...);
>>> 	recv(sock, buf, n * PAGE_SIZE, 0);
>>>
>>> 	/* Sign of @pid is direction: "from @pid task to current" or vice versa. */
>>> 	process_vm_mmap(-pid, buf, n * PAGE_SIZE, remote_addr, PVMMAP_FIXED);
>>> 	munmap(buf, n * PAGE_SIZE);
> 
> AFAIU this means that you actually want to do an mmap of an anonymous
> memory with a COW semantic to the remote process right?

Yes.

> How does the remote process find out where and what has been mmaped?

Any way. Isn't this a trivial task? :) You may use socket or any
of appropriate linux features to communicate between them.

>What if the range collides? This sounds quite scary to me TBH.

In case of range collides, the part of old VMA becomes unmapped.
The same way we behave on ordinary mmap. You may intersect a range,
which another thread mapped, so you need a synchronization between
them. There is no a principle difference.

Also I'm going to add a flag to prevent unmapping like Kees suggested.
Please, see his message.

> Why cannot you simply use shared memory for that?

Because of remote task may want specific type of VMA. It may want not to
share a VMA with its children.

Speaking about online migration, a task wants its anonymous private VMAs
remain the same after the migration. Otherwise, imagine the situation,
when task's stack becomes a shared VMA after the migration.
Also, task wants anonymous mapping remains anonymous.

In general, in case of shared memory is enough for everything, we would
have never had process_vm_writev() and process_vm_readv() syscalls.

Kirill

  reply	other threads:[~2019-05-16 14:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 15:11 [PATCH RFC 0/5] mm: process_vm_mmap() -- syscall for duplication a process mapping Kirill Tkhai
2019-05-15 15:11 ` [PATCH RFC 1/5] mm: Add process_vm_mmap() syscall declaration Kirill Tkhai
2019-05-15 15:11 ` [PATCH RFC 2/5] mm: Extend copy_vma() Kirill Tkhai
2019-05-15 15:11 ` [PATCH RFC 3/5] mm: Extend copy_page_range() Kirill Tkhai
2019-05-15 15:11 ` [PATCH RFC 4/5] mm: Export round_hint_to_min() Kirill Tkhai
2019-05-15 15:11 ` [PATCH RFC 5/5] mm: Add process_vm_mmap() Kirill Tkhai
2019-05-15 18:29   ` Kees Cook
2019-05-16 12:54     ` Kirill Tkhai
2019-05-15 18:46 ` [PATCH RFC 0/5] mm: process_vm_mmap() -- syscall for duplication a process mapping Jann Horn
2019-05-15 18:46   ` Jann Horn
2019-05-16 13:02   ` Kirill Tkhai
2019-05-16 13:14     ` Jann Horn
2019-05-16 13:14       ` Jann Horn
2019-05-15 19:38 ` Adam Borowski
2019-05-16 13:10   ` Kirill Tkhai
2019-05-16 13:42     ` Adam Borowski
2019-05-16 14:25       ` Kirill Tkhai
2019-05-16 13:30 ` Michal Hocko
2019-05-16 13:52   ` Michal Hocko
2019-05-16 14:22     ` Kirill Tkhai [this message]
2019-05-16 13:32 ` Jann Horn
2019-05-16 13:32   ` Jann Horn
2019-05-16 13:32   ` Jann Horn
2019-05-16 13:56   ` Kirill Tkhai
2019-05-16 13:56     ` Kirill Tkhai

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=85562807-2a13-9aa2-e67d-15513c766eae@virtuozzo.com \
    --to=ktkhai@virtuozzo.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.h.duyck@linux.intel.com \
    --cc=andreyknvl@google.com \
    --cc=arunks@codeaurora.org \
    --cc=cl@linux.com \
    --cc=dan.j.williams@intel.com \
    --cc=daniel.m.jordan@oracle.com \
    --cc=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=ira.weiny@intel.com \
    --cc=jglisse@redhat.com \
    --cc=keescook@chromium.org \
    --cc=keith.busch@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=pasha.tatashin@oracle.com \
    --cc=riel@surriel.com \
    --cc=shakeelb@google.com \
    --cc=vbabka@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.