From: chrubis@suse.cz
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/mmap: Check for RLIMIT_AS before unmapping
Date: Fri, 12 Apr 2013 15:42:02 +0200 [thread overview]
Message-ID: <20130412134202.GA2764@rei.scz.novell.com> (raw)
In-Reply-To: <20130411155734.911dc8bf8e555b169191be5a@linux-foundation.org>
Hi!
> > +static unsigned long count_vma_pages_range(struct mm_struct *mm,
> > + unsigned long addr, unsigned long end)
> > +{
> > + unsigned long nr_pages = 0;
> > + struct vm_area_struct *vma;
> > +
> > + /* Find first overlaping mapping */
> > + vma = find_vma_intersection(mm, addr, end);
> > + if (!vma)
> > + return 0;
> > +
> > + nr_pages = (min(end, vma->vm_end) -
> > + max(addr, vma->vm_start)) >> PAGE_SHIFT;
>
> urgh, these things always make my head spin. Is it guaranteed that
> end, vm_end, addr and vm_start are all multiples of PAGE_SIZE? If not,
> we have a problem don't we?
Yes, it takes a little of concentration before one can say what the code
does, unfortunatelly this is the most readable variant I've came up
with.
The len is page aligned right at the start of the do_mmap_pgoff() (end
is addr + len). The addr should be aligned in the get_unmapped_area()
although the codepath is more complicated to follow, but it seems to end
up in one of the arch_get_unmapped_area* and these makes sure the
address is aligned.
Moreover mmap() manual page says that the addr passed to mmap() is page
aligned (although I tend to check the code rather than the docs).
And for the vmas I belive these are page aligned by definition, correct
me if I'm wrong.
--
Cyril Hrubis
chrubis@suse.cz
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-04-12 13:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-02 9:54 Cyril Hrubis
2013-04-02 10:56 ` Mel Gorman
2013-04-02 12:29 ` Wanpeng Li
2013-04-02 12:29 ` Wanpeng Li
2013-04-11 22:57 ` Andrew Morton
2013-04-12 13:42 ` chrubis [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-03-25 13:24 Cyril Hrubis
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=20130412134202.GA2764@rei.scz.novell.com \
--to=chrubis@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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