From: Tim Deegan Subject: Re: Is this a racing bug in page_make_sharable()? Date: Tue, 17 Jan 2012 10:53:23 +0000 Message-ID: <20120117105323.GA74654@ocelot.phlegethon.org> References: <4F14345B.4040807@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Nai Xia Cc: xen-devel@lists.xensource.com, Grzegorz Milos List-Id: xen-devel@lists.xenproject.org At 22:43 +0800 on 16 Jan (1326753834), Nai Xia wrote: > Hi Grzegorz, > > As I understand, the purpose of the code in page_make_sharable() > checking the ref count is to ensure that nobody unexpected is working > on the page, and so we can migrate it to dom_cow, right? > > ==== > /* Check if the ref count is 2. The first from PGT_allocated, and > * the second from get_page_and_type at the top of this function */ > if(page->count_info != (PGC_allocated | (2 + expected_refcnt))) > { > /* Return type count back to zero */ > put_page_and_type(page); > spin_unlock(&d->page_alloc_lock); > return -E2BIG; > } > ==== > > However, it seems to me that this ref check and the following page > migration is not atomic( although the operations for type_info ref > check seems good) i.e. it's possible that it passed this ref > check but just before it goes to dom_cow, someone else gets this page? Yes, there are a number of races around the p2m code; Anders Lagar-Cavilla has been working on fixing the locking around p2m lookups to take care of this. Tim.