From: Tejun Heo <tj@kernel.org>
To: Cody P Schafer <dev@codyps.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
John de la Garza <john@jjdev.com>,
Michel Lespinasse <walken@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Rusty Russell <rusty@rustcorp.com.au>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rbtree: clarify documentation of rbtree_postorder_for_each_entry_safe()
Date: Tue, 6 Oct 2015 13:25:55 -0400 [thread overview]
Message-ID: <20151006172555.GA3931@mtj.duckdns.org> (raw)
In-Reply-To: <1443997973-1700-1-git-send-email-dev@codyps.com>
Hello,
On Sun, Oct 04, 2015 at 06:32:50PM -0400, Cody P Schafer wrote:
> Doing this will cause random nodes to be missed by the iteration because
> rb_erase() may rebalance the tree, changing the ordering that we're
> trying to iterate over.
>
> The previous documentation for rbtree_postorder_for_each_entry_safe()
> wasn't clear that this wasn't allowed, it was taken from the docs for
> list_for_each_entry_safe(), where erasing isn't a problem due to
> list_del() not reordering.
Ugh... that's a misleading name for an iterator if it doesn't allow
removal of elements during iteration.
> Explicitly warn developers about this potential pit-fall.
>
> Note that I haven't fixed the actual issue that (it appears) the commit
> referenced above introduced (not familiar enough with that code).
>
> In general (and in this case), the patterns to follow are:
> - switch to rb_first() + rb_erase(), don't use
> rbtree_postorder_for_each_entry_safe().
I'll update it to a while loop on rb_first().
Thanks.
--
tejun
next prev parent reply other threads:[~2015-10-06 17:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-04 22:32 Cody P Schafer
2015-10-06 17:25 ` Tejun Heo [this message]
2015-10-13 22:14 ` [PATCH block/for-linus] writeback: remove broken rbtree_postorder_for_each_entry_safe() usage in cgwb_bdi_destroy() Tejun Heo
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=20151006172555.GA3931@mtj.duckdns.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dev@codyps.com \
--cc=john@jjdev.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rusty@rustcorp.com.au \
--cc=walken@google.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
Powered by JetHome