Re: [Stable-review] [2/3] mm: fix up some user-visible effects of the stack guard page

From: Willy Tarreau
Date: Fri Aug 20 2010 - 16:35:56 EST


On Fri, Aug 20, 2010 at 12:43:28PM -0700, Linus Torvalds wrote:
> So switching it to the "<linux/list.h>" kind of accessors would be a major pain.
>
> There's also lots of really ugly code that is all about the "we can't
> easily get to the 'prev' entry in the list". Stuff that would be
> cleaned up if we just had a vm_prev, but where the cleanups is just
> pretty painful.
>
> > And it would be trivial to change the loops like
> >
> >    for (vma = mm->mmap; vma; vma = vma->vm_next)
> >
> > into basically just
> >
> >   list_for_each_entry(vma, &mm->mmap, vm_list)
>
> Yeah, no. It looks like adding a "vm_prev" and doing a regular doubly
> linked list thing wouldn't be too bad. But switching over to the
> list.h version looks like a nightmare.
>
> Too bad.

I've had to convert normal linked lists to a dual linked list for a project
of mine in the past, and for the same reason I could not use the lists how
we use them in Linux. However I found an interesting tradeoff which consists
in having only the ->prev list circular but keep the ->next one null-
terminated.

In the end, the API is not much different. A few tests just on the ->next
pointer at some places, but you can still use ->prev everywhere to find
the list tail, for inserting and removing. And overall that was pretty
convenient. It was a lot better than the simple linked list and almost
as easy to use as the circular ones.

Just my 2 cents,
Willy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/