Re: [PATCH 3/3] mm: Simplify anon_vma refcounts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 17, 2011 at 8:19 AM, Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> 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@xxxxxxxxxx  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


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]