lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 15 Mar 2010 16:11:36 -0500
From:	Robin Holt <holt@....com>
To:	Suresh Siddha <suresh.b.siddha@...el.com>
Cc:	Robin Holt <holt@....com>, Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	"Pallipadi, Venkatesh" <venkatesh.pallipadi@...il.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	"x86@...nel.org" <x86@...nel.org>
Subject: Re: [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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ