linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)" <longpeng2@huawei.com>
To: Steven Sistare <steven.sistare@oracle.com>,
	Anthony Yznaga <anthony.yznaga@oracle.com>,
	<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Cc: "Gonglei (Arei)" <arei.gonglei@huawei.com>, <willy@infradead.org>
Subject: Re: [RFC PATCH 0/5] madvise MADV_DOEXEC
Date: Mon, 12 Jul 2021 09:05:45 +0800	[thread overview]
Message-ID: <a1dbf12e-9949-109e-122c-ba7ba609801b@huawei.com> (raw)
In-Reply-To: <43471cbb-67c6-f189-ef12-0f8302e81b06@oracle.com>

Hi Steven,

在 2021/7/8 20:48, Steven Sistare 写道:
> On 7/8/2021 5:52 AM, Longpeng (Mike, Cloud Infrastructure Service Product Dept.) wrote:
>> Hi Anthony and Steven,
>>
>> 在 2020/7/28 1:11, Anthony Yznaga 写道:
>>> This patchset adds support for preserving an anonymous memory range across
>>> exec(3) using a new madvise MADV_DOEXEC argument.  The primary benefit for
>>> sharing memory in this manner, as opposed to re-attaching to a named shared
>>> memory segment, is to ensure it is mapped at the same virtual address in
>>> the new process as it was in the old one.  An intended use for this is to
>>> preserve guest memory for guests using vfio while qemu exec's an updated
>>> version of itself.  By ensuring the memory is preserved at a fixed address,
>>> vfio mappings and their associated kernel data structures can remain valid.
>>> In addition, for the qemu use case, qemu instances that back guest RAM with
>>> anonymous memory can be updated.
>>
>> We have a requirement like yours, but ours seems more complex. We want to
>> isolate some memory regions from the VM's memory space and the start a child
>> process who will using these memory regions.
>>
>> I've wrote a draft to support this feature, but I just find that my draft is
>> pretty like yours.
>>
>> It seems that you've already abandoned this patchset, why ?
> 
> Hi Longpeng,
>   The reviewers did not like the proposal for several reasons, but the showstopper
> was that they did not want to add complexity to the exec path in the kernel.  You
> can read the email archive for details.
> 
I've read the archive and did some study these days, maybe this soluation is
more sutiable for my use case.

Let me describe my use case more clearly (just ignore if you're not interested
in it):

1. Prog A mmap() 4GB memory (anon or file-mapping), suppose the allocated VA
range is [0x40000000,0x140000000)

2. Prog A specifies [0x48000000,0x50000000) and [0x80000000,0x100000000) will be
shared by its child.

3. Prog A fork() Prog B and then Prog B exec() a new ELF binary.

4. Prog B notice the shared ranges (e.g. by input parameters or ...) and remap
them to a continuous VA range.

Do you have any suggestions ?

> We solved part of our problem by adding new vfio interfaces: VFIO_DMA_UNMAP_FLAG_VADDR
> and VFIO_DMA_MAP_FLAG_VADDR.  That solves the vfio problem for shared memory, but not
> for mmap MAP_ANON memory.
> 
> - Steve
> 
>>> Patches 1 and 2 ensure that loading of ELF load segments does not silently
>>> clobber existing VMAS, and remove assumptions that the stack is the only
>>> VMA in the mm when the stack is set up.  Patch 1 re-introduces the use of
>>> MAP_FIXED_NOREPLACE to load ELF binaries that addresses the previous issues
>>> and could be considered on its own.
>>>
>>> Patches 3, 4, and 5 introduce the feature and an opt-in method for its use
>>> using an ELF note.
>>>
>>> Anthony Yznaga (5):
>>>   elf: reintroduce using MAP_FIXED_NOREPLACE for elf executable mappings
>>>   mm: do not assume only the stack vma exists in setup_arg_pages()
>>>   mm: introduce VM_EXEC_KEEP
>>>   exec, elf: require opt-in for accepting preserved mem
>>>   mm: introduce MADV_DOEXEC
>>>
>>>  arch/x86/Kconfig                       |   1 +
>>>  fs/binfmt_elf.c                        | 196 +++++++++++++++++++++++++--------
>>>  fs/exec.c                              |  33 +++++-
>>>  include/linux/binfmts.h                |   7 +-
>>>  include/linux/mm.h                     |   5 +
>>>  include/uapi/asm-generic/mman-common.h |   3 +
>>>  kernel/fork.c                          |   2 +-
>>>  mm/madvise.c                           |  25 +++++
>>>  mm/mmap.c                              |  47 ++++++++
>>>  9 files changed, 266 insertions(+), 53 deletions(-)
>>>
>>
> .
> 


  reply	other threads:[~2021-07-12  1:06 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 17:11 [RFC PATCH 0/5] madvise MADV_DOEXEC Anthony Yznaga
2020-07-27 17:07 ` Eric W. Biederman
2020-07-27 18:00   ` Steven Sistare
2020-07-28 13:40     ` Christian Brauner
2020-07-27 17:11 ` [RFC PATCH 1/5] elf: reintroduce using MAP_FIXED_NOREPLACE for elf executable mappings Anthony Yznaga
2020-07-27 17:11 ` [RFC PATCH 2/5] mm: do not assume only the stack vma exists in setup_arg_pages() Anthony Yznaga
2020-07-27 17:11 ` [RFC PATCH 3/5] mm: introduce VM_EXEC_KEEP Anthony Yznaga
2020-07-28 13:38   ` Eric W. Biederman
2020-07-28 17:44     ` Anthony Yznaga
2020-07-29 13:52   ` Kirill A. Shutemov
2020-07-29 23:20     ` Anthony Yznaga
2020-07-27 17:11 ` [RFC PATCH 4/5] exec, elf: require opt-in for accepting preserved mem Anthony Yznaga
2020-07-27 17:11 ` [RFC PATCH 5/5] mm: introduce MADV_DOEXEC Anthony Yznaga
2020-07-28 13:22   ` Kirill Tkhai
2020-07-28 14:06     ` Steven Sistare
2020-07-28 11:34 ` [RFC PATCH 0/5] madvise MADV_DOEXEC Kirill Tkhai
2020-07-28 17:28   ` Anthony Yznaga
2020-07-28 14:23 ` Andy Lutomirski
2020-07-28 14:30   ` Steven Sistare
2020-07-30 15:22 ` Matthew Wilcox
2020-07-30 15:27   ` Christian Brauner
2020-07-30 15:34     ` Matthew Wilcox
2020-07-30 15:54       ` Christian Brauner
2020-07-31  9:12     ` Stefan Hajnoczi
2020-07-30 15:59   ` Steven Sistare
2020-07-30 17:12     ` Matthew Wilcox
2020-07-30 17:35       ` Steven Sistare
2020-07-30 17:49         ` Matthew Wilcox
2020-07-30 18:27           ` Steven Sistare
2020-07-30 21:58             ` Eric W. Biederman
2020-07-31 14:57               ` Steven Sistare
2020-07-31 15:27                 ` Matthew Wilcox
2020-07-31 16:11                   ` Steven Sistare
2020-07-31 16:56                     ` Jason Gunthorpe
2020-07-31 17:15                       ` Steven Sistare
2020-07-31 17:48                         ` Jason Gunthorpe
2020-07-31 17:55                           ` Steven Sistare
2020-07-31 17:23                     ` Matthew Wilcox
2020-08-03 15:28                 ` Eric W. Biederman
2020-08-03 15:42                   ` James Bottomley
2020-08-03 20:03                     ` Steven Sistare
     [not found]                     ` <9371b8272fd84280ae40b409b260bab3@AcuMS.aculab.com>
2020-08-04 11:13                       ` Matthew Wilcox
2020-08-03 19:29                   ` Steven Sistare
2020-07-31 19:41 ` Steven Sistare
2021-07-08  9:52 ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-07-08 12:48   ` Steven Sistare
2021-07-12  1:05     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.) [this message]
2021-07-12  1:30       ` Matthew Wilcox
2021-07-13  0:57         ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-08-13 19:49           ` Khalid Aziz
2021-08-14 20:07             ` David Laight
2021-08-16  0:26               ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-08-16  8:07                 ` David Laight
2021-08-16  6:54             ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-08-16  8:02             ` David Hildenbrand
2021-08-16 12:07               ` Matthew Wilcox
2021-08-16 12:20                 ` David Hildenbrand
2021-08-16 12:42                   ` David Hildenbrand
2021-08-16 12:46                   ` Matthew Wilcox
2021-08-16 13:24                     ` David Hildenbrand
2021-08-16 13:32                       ` Matthew Wilcox
2021-08-16 14:10                         ` David Hildenbrand
2021-08-16 14:27                           ` Matthew Wilcox
2021-08-16 14:33                             ` David Hildenbrand
2021-08-16 14:40                               ` Matthew Wilcox
2021-08-16 15:01                                 ` David Hildenbrand
2021-08-16 15:59                                   ` Matthew Wilcox
2021-08-16 16:06                                     ` Khalid Aziz
2021-08-16 16:15                                       ` Matthew Wilcox
2021-08-16 16:13                                     ` David Hildenbrand
2021-08-16 12:27                 ` [private] " David Hildenbrand
2021-08-16 12:30                   ` David Hildenbrand
2021-08-17  0:47                 ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-08-17  0:55                   ` Matthew Wilcox

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=a1dbf12e-9949-109e-122c-ba7ba609801b@huawei.com \
    --to=longpeng2@huawei.com \
    --cc=anthony.yznaga@oracle.com \
    --cc=arei.gonglei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=steven.sistare@oracle.com \
    --cc=willy@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).