lkml.org 
[lkml]   [2010]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch] x86,pat Update the page flags for memtype atomically instead of using memtype_lock.
> >  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


\
 
 \ /
  Last update: 2010-03-15 22:13    [W:0.049 / U:4.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site