Re: [Patch] x86,pat Update the page flags for memtype atomicallyinstead of using memtype_lock.
From: Robin Holt
Date: Mon Mar 15 2010 - 17:11:45 EST
> > static inline void set_page_memtype(struct page *pg, unsigned long memtype)
> > {
> > + unsigned long memtype_flags = _PGMT_DEFAULT;
> > + unsigned long old_flags;
> > + unsigned long new_flags;
> > +
> > switch (memtype) {
> > case _PAGE_CACHE_WC:
> > - ClearPageUncached(pg);
> > - SetPageWC(pg);
> > + memtype_flags = _PGMT_WC;
> > break;
> > case _PAGE_CACHE_UC_MINUS:
> > - SetPageUncached(pg);
> > - ClearPageWC(pg);
> > + memtype_flags = _PGMT_UC_MINUS;
> > break;
> > case _PAGE_CACHE_WB:
> > - SetPageUncached(pg);
> > - SetPageWC(pg);
> > - break;
> > - default:
> > - case -1:
> > - ClearPageUncached(pg);
> > - ClearPageWC(pg);
> > + memtype_flags = _PGMT_WB;
>
> For WB case it should be _PGMT_WB and for the case of "-1" this should
> be _PGMT_DEFAULT, as in the case of free page we mark it _PGMT_DEFAULT
> and when there is an explicit request to mark it WB, then we mark it
> _PGMT_WB
>
> Other than that it looks good to me.
This is easier to look at if you ignore the diff and just look at the
fixed up code:
static inline void set_page_memtype(struct page *pg, unsigned long memtype)
{
unsigned long memtype_flags = _PGMT_DEFAULT;
unsigned long old_flags;
unsigned long new_flags;
switch (memtype) {
case _PAGE_CACHE_WC:
memtype_flags = _PGMT_WC;
break;
case _PAGE_CACHE_UC_MINUS:
memtype_flags = _PGMT_UC_MINUS;
break;
case _PAGE_CACHE_WB:
memtype_flags = _PGMT_WB;
break;
}
do {
old_flags = pg->flags;
new_flags = (old_flags & _PGMT_CLEAR_MASK) | memtype_flags;
} while (cmpxchg(&pg->flags, old_flags, new_flags) != old_flags);
}
The memtype_flags start out cleared and only deviate when _WC, _UC_MINUS,
or _WB is specified.
Did I miss anything there?
Thanks,
Robin
--
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/