From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Anthony Yznaga <anthony.yznaga@oracle.com>
Cc: akpm@linux-foundation.org, willy@infradead.org,
markhemm@googlemail.com, viro@zeniv.linux.org.uk,
david@redhat.com, khalid@kernel.org, andreyknvl@gmail.com,
dave.hansen@intel.com, luto@kernel.org, brauner@kernel.org,
arnd@arndb.de, ebiederm@xmission.com, catalin.marinas@arm.com,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, mhiramat@kernel.org, rostedt@goodmis.org,
vasily.averin@linux.dev, xhao@linux.alibaba.com, pcc@google.com,
neilb@suse.de, maz@kernel.org
Subject: Re: [RFC PATCH v3 09/10] mm: create __do_mmap() to take an mm_struct * arg
Date: Mon, 7 Oct 2024 11:44:05 +0300 [thread overview]
Message-ID: <sgrdkcwjzoazuqqutzmzlsjo5outzsp5gh7zsn6ur5qvhaslgw@b74envmtrahz> (raw)
In-Reply-To: <20240903232241.43995-10-anthony.yznaga@oracle.com>
On Tue, Sep 03, 2024 at 04:22:40PM -0700, Anthony Yznaga wrote:
> In preparation for mapping objects into an mshare region, create
> __do_mmap() to allow mapping into a specified mm. There are no
> functional changes otherwise.
>
> Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com>
> ---
> include/linux/mm.h | 18 +++++++++++++++++-
> mm/mmap.c | 12 +++++-------
> 2 files changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 3aa0b3322284..a9afbda73cb0 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3409,11 +3409,27 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>
> extern unsigned long mmap_region(struct file *file, unsigned long addr,
> unsigned long len, vm_flags_t vm_flags, unsigned long pgoff,
> - struct list_head *uf);
> + struct list_head *uf, struct mm_struct *mm);
> +#ifdef CONFIG_MMU
> +extern unsigned long __do_mmap(struct file *file, unsigned long addr,
> + unsigned long len, unsigned long prot, unsigned long flags,
> + vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate,
> + struct list_head *uf, struct mm_struct *mm);
> +static inline unsigned long do_mmap(struct file *file, unsigned long addr,
> + unsigned long len, unsigned long prot, unsigned long flags,
> + vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate,
> + struct list_head *uf)
> +{
> + return __do_mmap(file, addr, len, prot, flags, vm_flags, pgoff,
> + populate, uf, current->mm);
> +}
> +#else
> extern unsigned long do_mmap(struct file *file, unsigned long addr,
> unsigned long len, unsigned long prot, unsigned long flags,
> vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate,
> struct list_head *uf);
> +#endif
> +
> extern int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm,
> unsigned long start, size_t len, struct list_head *uf,
> bool unlock);
> diff --git a/mm/mmap.c b/mm/mmap.c
> index d0dfc85b209b..4112f18e7302 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1250,15 +1250,14 @@ static inline bool file_mmap_ok(struct file *file, struct inode *inode,
> }
>
> /*
> - * The caller must write-lock current->mm->mmap_lock.
> + * The caller must write-lock mm->mmap_lock.
> */
> -unsigned long do_mmap(struct file *file, unsigned long addr,
> +unsigned long __do_mmap(struct file *file, unsigned long addr,
> unsigned long len, unsigned long prot,
> unsigned long flags, vm_flags_t vm_flags,
> unsigned long pgoff, unsigned long *populate,
> - struct list_head *uf)
> + struct list_head *uf, struct mm_struct *mm)
Argument list getting too long. At some point we need to have a struct to
pass them around.
> {
> - struct mm_struct *mm = current->mm;
> int pkey = 0;
>
> *populate = 0;
> @@ -1465,7 +1464,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
> vm_flags |= VM_NORESERVE;
> }
>
> - addr = mmap_region(file, addr, len, vm_flags, pgoff, uf);
> + addr = mmap_region(file, addr, len, vm_flags, pgoff, uf, mm);
> if (!IS_ERR_VALUE(addr) &&
> ((vm_flags & VM_LOCKED) ||
> (flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE))
> @@ -2848,9 +2847,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
>
> unsigned long mmap_region(struct file *file, unsigned long addr,
> unsigned long len, vm_flags_t vm_flags, unsigned long pgoff,
> - struct list_head *uf)
> + struct list_head *uf, struct mm_struct *mm)
> {
> - struct mm_struct *mm = current->mm;
> struct vm_area_struct *vma = NULL;
> struct vm_area_struct *next, *prev, *merge;
> pgoff_t pglen = len >> PAGE_SHIFT;
> --
> 2.43.5
>
--
Kiryl Shutsemau / Kirill A. Shutemov
next prev parent reply other threads:[~2024-10-07 8:44 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 23:22 [RFC PATCH v3 00/10] Add support for shared PTEs across processes Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 01/10] mm: Add msharefs filesystem Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 02/10] mm/mshare: pre-populate msharefs with information file Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 03/10] mm/mshare: make msharefs writable and support directories Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 04/10] mm/mshare: allocate an mm_struct for msharefs files Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 05/10] mm/mshare: Add ioctl support Anthony Yznaga
2024-10-14 20:08 ` Jann Horn
2024-10-16 0:49 ` Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 06/10] mm/mshare: Add vm flag for shared PTEs Anthony Yznaga
2024-09-03 23:40 ` James Houghton
2024-09-03 23:58 ` Anthony Yznaga
2024-10-07 10:24 ` David Hildenbrand
2024-10-07 23:03 ` Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 07/10] mm/mshare: Add mmap support Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 08/10] mm/mshare: Add basic page table sharing support Anthony Yznaga
2024-10-07 8:41 ` Kirill A. Shutemov
2024-10-07 17:45 ` Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 09/10] mm: create __do_mmap() to take an mm_struct * arg Anthony Yznaga
2024-10-07 8:44 ` Kirill A. Shutemov [this message]
2024-10-07 17:46 ` Anthony Yznaga
2024-09-03 23:22 ` [RFC PATCH v3 10/10] mshare: add MSHAREFS_CREATE_MAPPING Anthony Yznaga
2024-10-02 17:35 ` [RFC PATCH v3 00/10] Add support for shared PTEs across processes Dave Hansen
2024-10-02 19:30 ` Anthony Yznaga
2024-10-02 23:11 ` Dave Hansen
2024-10-03 0:24 ` Anthony Yznaga
2024-10-07 8:44 ` David Hildenbrand
2024-10-07 15:58 ` Dave Hansen
2024-10-07 16:27 ` David Hildenbrand
2024-10-07 16:45 ` Sean Christopherson
2024-10-08 1:37 ` Anthony Yznaga
2024-10-07 8:48 ` David Hildenbrand
2024-10-07 9:01 ` Kirill A. Shutemov
2024-10-07 19:23 ` Anthony Yznaga
2024-10-07 19:41 ` David Hildenbrand
2024-10-07 19:46 ` Anthony Yznaga
2024-10-14 20:07 ` Jann Horn
2024-10-16 0:59 ` Anthony Yznaga
2024-10-16 13:25 ` Jann Horn
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=sgrdkcwjzoazuqqutzmzlsjo5outzsp5gh7zsn6ur5qvhaslgw@b74envmtrahz \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=anthony.yznaga@oracle.com \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@intel.com \
--cc=david@redhat.com \
--cc=ebiederm@xmission.com \
--cc=khalid@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=markhemm@googlemail.com \
--cc=maz@kernel.org \
--cc=mhiramat@kernel.org \
--cc=neilb@suse.de \
--cc=pcc@google.com \
--cc=rostedt@goodmis.org \
--cc=vasily.averin@linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=xhao@linux.alibaba.com \
/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