linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH 1/2] mm/mlock: not handle NULL vma specially
Date: Sat, 7 May 2022 15:44:01 -0700	[thread overview]
Message-ID: <20220507154401.fc4d239e850a60d2e4c139ab@linux-foundation.org> (raw)
In-Reply-To: <CADZGycaK85A4A_mzXvZ2EvO2zmhDzfc88vX=yQ6dT2JLy8xvCg@mail.gmail.com>

On Sun, 8 May 2022 05:56:15 +0800 Wei Yang <richard.weiyang@gmail.com> wrote:

> > > -     vma = find_vma(mm, start);
> > > -     if (vma == NULL)
> > > -             return 0;
> > > -
> > > -     for (; vma ; vma = vma->vm_next) {
> > > +     for (vma = find_vma(mm, start); vma ; vma = vma->vm_next) {
> > >               if (start >= vma->vm_end)
> > >                       continue;
> > >               if (start + len <=  vma->vm_start)
> >
> > The mapletree patches mangle this code a lot.
> >
> > Please take a look at linux-next or the mm-unstabe branch at
> > git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm early to mid next
> > week, see if you see anything which should be addressed.
> >
> 
> I took a look at mm-unstabe branch with last commit
> 
>   2b58b3f33ba2 mm/shmem: convert shmem_swapin_page() to shmem_swapin_folio()
> 

It isn't early to mid next week yet ;)

> Function count_mm_mlocked_page_nr() looks not changed.
> 
> Do I need to rebase on top of it?

static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,
		unsigned long start, size_t len)
{
	struct vm_area_struct *vma;
	unsigned long count = 0;
	unsigned long end;
	VMA_ITERATOR(vmi, mm, start);

	if (mm == NULL)
		mm = current->mm;

	/* Don't overflow past ULONG_MAX */
	if (unlikely(ULONG_MAX - len < start))
		end = ULONG_MAX;
	else
		end = start + len;
	for_each_vma_range(vmi, vma, end) {
		if (vma->vm_flags & VM_LOCKED) {
			if (start > vma->vm_start)
				count -= (start - vma->vm_start);
			if (end < vma->vm_end) {
				count += end - vma->vm_start;
				break;
			}
			count += vma->vm_end - vma->vm_start;
		}
	}

	return count >> PAGE_SHIFT;
}



      reply	other threads:[~2022-05-07 22:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  0:39 Wei Yang
2022-05-04  0:39 ` [PATCH 2/2] mm/mlock: start is always smaller then vm_end Wei Yang
2022-05-07 21:03 ` [PATCH 1/2] mm/mlock: not handle NULL vma specially Andrew Morton
2022-05-07 21:56   ` Wei Yang
2022-05-07 22:44     ` Andrew Morton [this message]

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=20220507154401.fc4d239e850a60d2e4c139ab@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=richard.weiyang@gmail.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