From: Keir Fraser Subject: Re: [PATCH] x86: remove use of per-domain lock frompage table entry handling Date: Tue, 22 Apr 2008 14:51:33 +0100 Message-ID: References: <480E06A8.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <480E06A8.76E4.0078.0@novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On 22/4/08 14:39, "Jan Beulich" wrote: >> I'm pretty sure we don't need per-page locks. > > If you want to make serialization by the caller part of the ABI - yes. > If not (and I think everything else would be wrong, as a malicious guest > could take advantage of that), then the window between reading of > the old entry and writing the new one must be protected against racing > updates, as otherwise the page type and reference counters could get > screwed up. Ah, yes my statement assumes we return to doing cmpxchg for all PTE updates (and retry on failure). As to whether that is better than your approach, I suppose it depends on whether you can amortise the locking overheads across multiple PTE updates. Right now it appears you lock/unlock on every PTE update, which is double the number of locked cmpxchg operations compared with just doing the cmpxchg on the pte itself. Bear in mind that all the page reference counting was designed in the first place to be safe, assuming the PTE update itself is done as an atomic read-modify-write operation. It's just that we changed the latter to a simple write some time ago because of course we observed that that's a safe thing to do under the big lock. -- Keir