From: "Jan Beulich" Subject: Re: [PATCH] Don't trigger unnecessary shadow scans on p2m entry update Date: Fri, 25 Nov 2011 08:45:30 +0000 Message-ID: <4ECF63BA02000078000633AA@nat28.tlf.novell.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser , Andres Lagar-Cavilla , xen-devel@lists.xensource.com Cc: andres@gridcentric.ca, tim@xen.org, adin@gridcentric.ca List-Id: xen-devel@lists.xenproject.org >>> On 24.11.11 at 19:31, Keir Fraser wrote: > On 24/11/2011 17:58, "Andres Lagar-Cavilla" wrote: >> @@ -815,6 +815,12 @@ static inline unsigned long vtlb_lookup( >> } >> #endif /* (SHADOW_OPTIMIZATIONS & SHOPT_VIRTUAL_TLB) */ >> >> +static inline int __check_page_no_refs(struct page_info *page) >> +{ >> + unsigned long __count = page->count_info; >> + return ( (__count & PGC_count_mask) == >> + ((__count & PGC_allocated) ? 1 : 0) ); > > It's a fussy point, but it might be better to use > atomic_read_ulong(&page->count_info) here, to ensure that the compiler reads > the field once only. It's cheap (compiles to a single mov instruction), but > atomic_read_ulong doesn't exist so you'd have to add its (obvious) > definition to asm-x86/atomic.h I think Tim suggested anyway to use (__count & (PGC_count_mask|PGC_allocated)) matched against (1|PGC_allocated) here, which would eliminate the multiple read potential if used in a switch statement. Also, for clarity the function should probably return bool_t. Jan