[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1407887208.2695.9.camel@buesod1.americas.hpqcorp.net>
Date: Tue, 12 Aug 2014 16:46:48 -0700
From: Davidlohr Bueso <davidlohr@...com>
To: "Kirill A. Shutemov" <kirill@...temov.name>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Martin Schwidefsky <schwidefsky@...ibm.com>,
Heiko Carstens <heiko.carstens@...ibm.com>,
"James E.J. Bottomley" <jejb@...isc-linux.org>,
Helge Deller <deller@....de>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Robert Richter <rric@...nel.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, aswin@...com
Subject: Re: [PATCH] mm: introduce for_each_vma helpers
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.
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists