linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
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: Thu, 17 Feb 2011 10:30:07 -0800	[thread overview]
Message-ID: <AANLkTimj1d6QpzuNZ6NJvLDVvvC++mPodggFaBziU8Bj@mail.gmail.com> (raw)
In-Reply-To: <20110217162124.457572646@chello.nl>

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), 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)

                   Linus

--
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>

  parent reply	other threads:[~2011-02-17 18:30 UTC|newest]

Thread overview: 14+ 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 ` [PATCH 1/3] mm: Rename drop_anon_vma to put_anon_vma Peter Zijlstra
2011-02-17 17:44   ` Rik van Riel
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 17:49   ` Rik van Riel
2011-02-17 16:19 ` [PATCH 3/3] mm: Simplify anon_vma refcounts Peter Zijlstra
2011-02-17 17:47   ` Rik van Riel
2011-02-17 18:30   ` Linus Torvalds [this message]
2011-02-18 11:30     ` Peter Zijlstra
2011-02-18 13:44     ` Peter Zijlstra
2011-02-18 14:49       ` Rik van Riel
2011-03-09 16:38       ` Mel Gorman
2011-02-17 17:36 ` [PATCH 0/3] mm: Simplify anon_vma lifetime rules 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=AANLkTimj1d6QpzuNZ6NJvLDVvvC++mPodggFaBziU8Bj@mail.gmail.com \
    --to=torvalds@linux-foundation.org \
    --cc=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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).