From: Al Viro <viro@ZenIV.linux.org.uk>
To: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Cc: backports@vger.kernel.org
Subject: Re: [RFC] backports: add remove_proc_subtree() backport
Date: Mon, 13 May 2013 06:03:05 +0100 [thread overview]
Message-ID: <20130513050305.GT25399@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1368419498-15809-1-git-send-email-mcgrof@do-not-panic.com>
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? 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.?
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.
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...
next prev parent reply other threads:[~2013-05-13 5:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-13 4:31 [RFC] backports: add remove_proc_subtree() backport Luis R. Rodriguez
2013-05-13 5:03 ` Al Viro [this message]
2013-05-13 5:21 ` Luis R. Rodriguez
2013-05-13 5:40 ` Al Viro
2013-05-13 6:14 ` Luis R. Rodriguez
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=20130513050305.GT25399@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=backports@vger.kernel.org \
--cc=mcgrof@do-not-panic.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.