[PATCH] powerpc: add for_each_node_by_foo helpers

Nathan Lynch ntl at pobox.com
Wed Mar 15 16:16:57 EST 2006

Nathan Lynch wrote:
> Benjamin Herrenschmidt wrote:
> > 
> > > > I recently showed a variety of scenarios that would blow up in funny
> > > > ways.. It's not enough.
> > > 
> > > A variety of scenarios?  I'm aware of only one [1], which is kind of a
> > > corner case, and has never come up in practice to my knowledge.
> > > 
> > > If you know of others, I'd like to know the details.
> > 
> > I actually have one in mind that I remember, but I'm pretty sure I saw
> > another one...
> More details, please.  If you know of another issue besides the one
> pointed out already, I'd prefer to know the nature of it before
> putting more time into fixing this one.

Milton just pointed out to me another problem.

There is a race between add and remove operations in that a child can
be added to a node that is undergoing removal, which would cause an
inconsistent tree:

static int pSeries_reconfig_remove_node(struct device_node *np, int refs)
	struct device_node *parent, *child;

	parent = of_get_parent(np);
	if (!parent)
		return -EINVAL;

	if ((child = of_get_next_child(np, NULL))) {
		return -EBUSY;

>>>>	/* child could be added now */


	of_detach_node(np, refs);

Unlike the double-remove problem, this one seems easy to fix :)

The check for the child should be moved under the devtree_lock, or we
could serialize reconfig operations with a mutex.

More information about the Linuxppc64-dev mailing list