From: Andrew Morton <akpm@linux-foundation.org>
To: Davidlohr Bueso <davidlohr@hp.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
"James E.J. Bottomley" <jejb@parisc-linux.org>,
Helge Deller <deller@gmx.de>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Robert Richter <rric@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org, aswin@hp.com
Subject: Re: [PATCH] mm: introduce for_each_vma helpers
Date: Wed, 13 Aug 2014 14:08:00 -0700 [thread overview]
Message-ID: <20140813140800.df0310a05e5fad6ed6b55886@linux-foundation.org> (raw)
In-Reply-To: <1407887208.2695.9.camel@buesod1.americas.hpqcorp.net>
On Tue, 12 Aug 2014 16:46:48 -0700 Davidlohr Bueso <davidlohr@hp.com> wrote:
> On Wed, 2014-08-13 at 00:52 +0300, Kirill A. Shutemov wrote:
> > On Tue, Aug 12, 2014 at 10:45:23AM -0700, Davidlohr Bueso wrote:
> > > The most common way of iterating through the list of vmas, is via:
> > > for (vma = mm->mmap; vma; vma = vma->vm_next)
> > >
> > > This patch replaces this logic with a new for_each_vma(vma) helper,
> > > which 1) encapsulates this logic, and 2) make it easier to read.
> >
> > Why does it need to be encapsulated?
> > Do you have problem with reading plain for()?
> >
> > Your for_each_vma(vma) assumes "mm" from the scope. This can be confusing
> > for reader: whether it uses "mm" from the scope or "current->mm". This
> > will lead to very hard to find bug one day.
>
> I think its fairly obvious to see where the mm is coming from -- the
> helpers *do not* necessarily use current, it uses whatever mm was
> already there in the first place. I have not changed anything related to
> this from the callers.
It is a bit of a hand-grenade for those (rare) situations where code is
dealing with other-tasks-mm. It's simple enough to add an `mm' arg?
> The only related change I can think of, is for some callers that do:
>
> for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next)
>
> So we just add a local mm from current->mm and replace the for() with
> for_each_vma(). I don't see anything particularly ambiguous with that.
Adding a local to support a macro which secretly uses that local is
pretty nasty.
Overall, I'm not really sure that
- for (vma = mm->mmap; vma; vma = vma->vm_next) {
+ for_each_vma(mm, vma) {
is much of an improvement. I'll wait to see what others think...
--
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:[~2014-08-13 21:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-12 17:45 Davidlohr Bueso
2014-08-12 21:52 ` Kirill A. Shutemov
2014-08-12 23:29 ` Davidlohr Bueso
2014-08-12 23:46 ` Davidlohr Bueso
2014-08-13 21:08 ` Andrew Morton [this message]
2014-08-16 1:28 ` Hugh Dickins
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=20140813140800.df0310a05e5fad6ed6b55886@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=aswin@hp.com \
--cc=benh@kernel.crashing.org \
--cc=davidlohr@hp.com \
--cc=deller@gmx.de \
--cc=heiko.carstens@de.ibm.com \
--cc=jejb@parisc-linux.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=rric@kernel.org \
--cc=schwidefsky@de.ibm.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