linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: "Jakub Matěna" <matenajakub@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	patches@lists.linux.dev, linux-kernel@vger.kernel.org,
	vbabka@suse.cz, mhocko@kernel.org, mgorman@techsingularity.net,
	willy@infradead.org, liam.howlett@oracle.com, hughd@google.com,
	riel@surriel.com, rostedt@goodmis.org, peterz@infradead.org
Subject: Re: [PATCH 2/2] [PATCH 2/2] mm: add merging after mremap resize
Date: Sat, 28 May 2022 02:46:57 +0300	[thread overview]
Message-ID: <20220527234657.nsn6e7jjwttblzyi@box.shutemov.name> (raw)
In-Reply-To: <20220527104810.24736-3-matenajakub@gmail.com>

On Fri, May 27, 2022 at 12:48:10PM +0200, Jakub Matěna wrote:
> When mremap call results in expansion, it might be possible to merge the
> VMA with the next VMA which might become adjacent. This patch adds
> vma_merge call after the expansion is done to try and merge.
> 
> Signed-off-by: Jakub Matěna <matenajakub@gmail.com>
> ---
>  mm/mremap.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/mremap.c b/mm/mremap.c
> index 303d3290b938..c41237e62156 100644
> --- a/mm/mremap.c
> +++ b/mm/mremap.c
> @@ -9,6 +9,7 @@
>   */
>  
>  #include <linux/mm.h>
> +#include <linux/mm_inline.h>
>  #include <linux/hugetlb.h>
>  #include <linux/shm.h>
>  #include <linux/ksm.h>
> @@ -1022,8 +1023,11 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
>  				}
>  			}
>  
> -			if (vma_adjust(vma, vma->vm_start, addr + new_len,
> -				       vma->vm_pgoff, NULL)) {
> +			vma = vma_merge(mm, vma, addr + old_len, addr + new_len,
> +					vma->vm_flags, vma->anon_vma, vma->vm_file,
> +					vma->vm_pgoff + (old_len >> PAGE_SHIFT), vma_policy(vma),
> +					vma->vm_userfaultfd_ctx, anon_vma_name(vma));

The arguement list gets busy. Maybe some variables would help.
Calculation around vm_pgoff is not obvious and requires some explanation.

> +			if (!vma) {
>  				vm_unacct_memory(pages);
>  				ret = -ENOMEM;
>  				goto out;
> -- 
> 2.35.1
> 

-- 
 Kirill A. Shutemov


  parent reply	other threads:[~2022-05-27 23:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 10:48 [PATCH 0/2] Refactor of vma_merge and new merge call Jakub Matěna
2022-05-27 10:48 ` [PATCH 1/2] [PATCH 1/2] mm: refactor of vma_merge() Jakub Matěna
2022-05-27 23:39   ` Kirill A. Shutemov
2022-05-28  6:41     ` Jakub Matěna
2022-05-27 10:48 ` [PATCH 2/2] [PATCH 2/2] mm: add merging after mremap resize Jakub Matěna
2022-05-27 16:19   ` kernel test robot
2022-05-27 23:46   ` Kirill A. Shutemov [this message]
2022-05-30 10:53     ` Jakub Matěna
2022-06-02 14:56 [PATCH v2 0/2] Refactor of vma_merge and new merge call Jakub Matěna
2022-06-02 14:56 ` [PATCH 2/2] [PATCH 2/2] mm: add merging after mremap resize Jakub Matěna

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=20220527234657.nsn6e7jjwttblzyi@box.shutemov.name \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=liam.howlett@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matenajakub@gmail.com \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=rostedt@goodmis.org \
    --cc=vbabka@suse.cz \
    --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