All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>,
	Avi Kivity <avi@redhat.com>, Thomas Gleixner <tglx@linutronix.de>,
	Rik van Riel <riel@redhat.com>, Ingo Molnar <mingo@elte.hu>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	David Miller <davem@davemloft.net>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Mel Gorman <mel@csn.ul.ie>, Nick Piggin <npiggin@kernel.dk>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>,
	Yanmin Zhang <yanmin_zhang@linux.intel.com>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH 3/3] mm: Simplify anon_vma refcounts
Date: Fri, 18 Feb 2011 12:30:35 +0100	[thread overview]
Message-ID: <1298028635.5226.685.camel@laptop> (raw)
In-Reply-To: <AANLkTimj1d6QpzuNZ6NJvLDVvvC++mPodggFaBziU8Bj@mail.gmail.com>

On Thu, 2011-02-17 at 10:30 -0800, Linus Torvalds wrote:
> On Thu, Feb 17, 2011 at 8:19 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> >
> > +void __put_anon_vma(struct anon_vma *anon_vma)
> > +{
> > +       if (anon_vma->root != anon_vma)
> > +               put_anon_vma(anon_vma->root);
> > +       anon_vma_free(anon_vma);
> >  }
> 
> So this makes me nervous. It looks like recursion.
> 
> Now, I don't think we can ever get a chain of these things (because
> the root should be the root of everything),

Exactly.

>  but I still preferred the
> older code that made that "one-level root" case explicit, and didn't
> have recursion.
> 
> IOW, even though it should be entirely equivalent, I think I'd really
> prefer something like
> 
>   void __put_anon_vma(struct anon_vma *anon_vma)
>   {
>     struct anon_vma *root = anon_vma->root;
> 
>     if (root != anon_vma && atomic_dec_and_test(&root->refcount))
>       anon_vma_free(root);
>     anon_vma_free(anon_vma);
>   }
> 
> instead. Exactly because it makes it very clear that the "root" is a
> root, and we're not doing some possibly arbitrarily deep list like the
> dentry tree (which avoids recursion by open-coding its freeing as a
> loop).
> 
> Hmm? (The above is obviously untested, maybe it has some stupid bug)

Looks about right, I'll give it a spin. 


WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>,
	Avi Kivity <avi@redhat.com>, Thomas Gleixner <tglx@linutronix.de>,
	Rik van Riel <riel@redhat.com>, Ingo Molnar <mingo@elte.hu>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	David Miller <davem@davemloft.net>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Mel Gorman <mel@csn.ul.ie>, Nick Piggin <npiggin@kernel.dk>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>,
	Yanmin Zhang <yanmin_zhang@linux.intel.com>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH 3/3] mm: Simplify anon_vma refcounts
Date: Fri, 18 Feb 2011 12:30:35 +0100	[thread overview]
Message-ID: <1298028635.5226.685.camel@laptop> (raw)
In-Reply-To: <AANLkTimj1d6QpzuNZ6NJvLDVvvC++mPodggFaBziU8Bj@mail.gmail.com>

On Thu, 2011-02-17 at 10:30 -0800, Linus Torvalds wrote:
> On Thu, Feb 17, 2011 at 8:19 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> >
> > +void __put_anon_vma(struct anon_vma *anon_vma)
> > +{
> > +       if (anon_vma->root != anon_vma)
> > +               put_anon_vma(anon_vma->root);
> > +       anon_vma_free(anon_vma);
> >  }
> 
> So this makes me nervous. It looks like recursion.
> 
> Now, I don't think we can ever get a chain of these things (because
> the root should be the root of everything),

Exactly.

>  but I still preferred the
> older code that made that "one-level root" case explicit, and didn't
> have recursion.
> 
> IOW, even though it should be entirely equivalent, I think I'd really
> prefer something like
> 
>   void __put_anon_vma(struct anon_vma *anon_vma)
>   {
>     struct anon_vma *root = anon_vma->root;
> 
>     if (root != anon_vma && atomic_dec_and_test(&root->refcount))
>       anon_vma_free(root);
>     anon_vma_free(anon_vma);
>   }
> 
> instead. Exactly because it makes it very clear that the "root" is a
> root, and we're not doing some possibly arbitrarily deep list like the
> dentry tree (which avoids recursion by open-coding its freeing as a
> loop).
> 
> Hmm? (The above is obviously untested, maybe it has some stupid bug)

Looks about right, I'll give it a spin. 

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-02-18 11:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17 16:19 [PATCH 0/3] mm: Simplify anon_vma lifetime rules Peter Zijlstra
2011-02-17 16:19 ` Peter Zijlstra
2011-02-17 16:19 ` [PATCH 1/3] mm: Rename drop_anon_vma to put_anon_vma Peter Zijlstra
2011-02-17 16:19   ` Peter Zijlstra
2011-02-17 17:44   ` Rik van Riel
2011-02-17 17:44     ` Rik van Riel
2011-03-09 16:28   ` Mel Gorman
2011-03-09 16:28     ` Mel Gorman
2011-02-17 16:19 ` [PATCH 2/3] mm: Move anon_vma ref out from under CONFIG_foo Peter Zijlstra
2011-02-17 16:19   ` Peter Zijlstra
2011-02-17 17:49   ` Rik van Riel
2011-02-17 17:49     ` Rik van Riel
2011-02-17 16:19 ` [PATCH 3/3] mm: Simplify anon_vma refcounts Peter Zijlstra
2011-02-17 16:19   ` Peter Zijlstra
2011-02-17 17:47   ` Rik van Riel
2011-02-17 17:47     ` Rik van Riel
2011-02-17 18:30   ` Linus Torvalds
2011-02-17 18:30     ` Linus Torvalds
2011-02-18 11:30     ` Peter Zijlstra [this message]
2011-02-18 11:30       ` Peter Zijlstra
2011-02-18 13:44     ` Peter Zijlstra
2011-02-18 13:44       ` Peter Zijlstra
2011-02-18 14:49       ` Rik van Riel
2011-02-18 14:49         ` Rik van Riel
2011-03-09 16:38       ` Mel Gorman
2011-03-09 16:38         ` Mel Gorman
2011-02-17 17:36 ` [PATCH 0/3] mm: Simplify anon_vma lifetime rules Peter Zijlstra
2011-02-17 17:36   ` Peter Zijlstra

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=1298028635.5226.685.camel@laptop \
    --to=a.p.zijlstra@chello.nl \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=avi@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=mingo@elte.hu \
    --cc=npiggin@kernel.dk \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=yanmin_zhang@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.