Re: Regression - locking (all from 2.6.28)

From: Dave Hansen
Date: Fri Mar 06 2009 - 12:27:18 EST


On Fri, 2009-03-06 at 17:18 +0000, Catalin Marinas wrote:
> > > Are the pgdat->node_start_pfn and pgdat->node_spanned_pages always
> > > valid? Thanks.
> >
> > The variables themselves? I'm sure there's a window in early boot where
> > they aren't valid, but other than that they should be OK unless you're
> > int the middle of a hotplug operation.
> >
> > See pgdat_resize_(un)lock() in include/linux/memory_hotplug.h.
>
> I wouldn't hold a lock for that long. It's not really critical to scan
> all the page structures at a time as there are subsequent scans as well,
> so some can be missed.

I think you should be more worried about consistency rather than missing
entries. Take these two lines of code:

start_pfn = node->node_start_pfn;
/* hotplug occurs here */
end_pfn = start_pfn + node->node_spanned_pages;

What if someone comes in and adds memory to the node, at the beginning
of the node, after you have calculated start_pfn? Try to think of what
value you'll get for end_pfn and whether it is consistent and was *ever*
valid at all. Would that oops the kernel?

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/