On Fri, Apr 13, 2018 at 17:31:20 -1000, Richard Henderson wrote:
> On 04/05/2018 04:13 PM, Emilio G. Cota wrote:
> > +#ifdef CONFIG_DEBUG_TCG
> > +
> > +struct page_lock_debug {
> > + const PageDesc *pd;
> > + QLIST_ENTRY(page_lock_debug) entry;
> > +};
> > +
> > +static __thread QLIST_HEAD(, page_lock_debug) page_lock_debug_head;
> > +
> > +static struct page_lock_debug *get_page_lock_debug(const PageDesc *pd)
> > +{
> > + struct page_lock_debug *pld;
> > +
> > + QLIST_FOREACH(pld, &page_lock_debug_head, entry) {
> > + if (pld->pd == pd) {
> > + return pld;
> > + }
> > + }
> > + return NULL;
> > +}
>
> Why do you need a separate data structure for this?
The alternative would be to:
- reuse page_collection, but in some cases we lock pages without
page_collection
- Expand PageDesc with a bool, but that state would be global
and not per-thread, which could hide actual bugs (e.g. we
could see that the bool is set and not assert, despite
the bool having been set by another thread).
I figured a per-thread list would be appropriate here,
since it doesn't have the problems of the above solutions,
and is simple--and slow, which is why it's under DEBUG_TCG.
Thanks,
Emilio