Re: [RFC] backports: add remove_proc_subtree() backport

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

 



On Sun, May 12, 2013 at 10:03 PM, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> On Sun, May 12, 2013 at 09:31:38PM -0700, Luis R. Rodriguez wrote:
>
>> This implementation uses recursion then if subdirs are found
>> otherwise it treats it as a regular remove_proc_entry()
>
> Ugh...  What for?

I could not figure out a way to traverse the tree safely without being
able to use the proc_subdir_lock spinlock. Given that the way we
backport is through an external module I had to look at what ways this
could be done safely.

> It's not as if traversing the damn thing had
> been complicated:
>         de = root = root of subtree to be killed
>         unlink de
>         while true
>                 /* de is already unlinked */
>                 if de has children
>                         child = first child of de
>                         unlink child
>                         de = child
>                 else
>                         /* de can be killed now */
>                         parent = parent of de
>                         kill de
>                         if de == root
>                                 return
>                         de = parent
> and that's it.  Why bother with recursion, chew stack space, etc.?

I would pick up the same implementation if we could but not having
access to the locks and also in the case of NULL being passed as the
parent, which some drivers do pass I couldn't see how to easily get
access to &proc_root. So this is what I came up with and so I wanted
to check if perhaps I missed something.

> We do depth-first walk through the tree, unlinking the nodes from the
> lists of children on the way in and freeing them on the way out.

OK thanks for the clarification.

> The difference from your variant is that you use the stack to hold
> pointers to ancestors of the current victim.  You get to the parent
> of said victim by discarding a stack frame.  No need, since the
> victim contained an explicit pointer to its parent...

Except I thought NULL was passed?

  Luis
--
To unsubscribe from this list: send the line "unsubscribe backports" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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

  Powered by Linux