From mboxrd@z Thu Jan 1 00:00:00 1970 From: Euan Harris Subject: Re: [RFC PATCH v2 00/29] libxl: Cancelling asynchronous operations Date: Tue, 7 Apr 2015 18:08:42 +0100 Message-ID: <20150407170842.GD3099@citrix.com> References: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> <20150218161035.GA4022@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20150218161035.GA4022@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: xen-devel@lists.xensource.com, james.bulpin@citrix.com List-Id: xen-devel@lists.xenproject.org Hi, On Wed, Feb 18, 2015 at 04:10:35PM +0000, Euan Harris wrote: > We had a chat about testing these changes, and integrating them into xenopsd. > We agreed that we each had slightly different expectations of what we were > going to do, and when. I think we came to the following major conclusions: > > - I will start work on a simple test framework for cancellation, > hopefully to have first results in a fortnight or so. > - Once the test framework is available you will fix whatever bugs it > unearths, then we will rinse and repeat. > - You will think some more about the possibility of adding cancellation > to the xl command line tool, but since this is tricky there is no > expectation of when it might happen. I think the most straightforward way to test the cancellation mechanism in LibXL will be to adapt the way we test similar functionality in xenopsd: * define numbered 'cancellation points' at which cancellable operations can be cancelled * before testing a cancellable operation, pre-set the cancellation point at which cancellation should be attempted * when execution reaches the pre-set cancellation point, run the cancellation procedure This approach alone will not allow us to test asynchronous cancellation in the middle of long-running operations, such as writing a suspend image to disk - that will require a way to synchronize the test program with the long-running operation. My first guess about how this might be done was: * add current cancellation point and a trigger point variables to the context struct * increment the counter and fire the cancellation logic in libxl__ao_cancellable_register() In this way we could write a loop which iterated through all possible cancellation points. However you pointed out that we cannot call libxl_ao_cancel() while holding the context lock, so this idea needs some refinement. One possibility would be to tell another thread to try to do the cancellation immediately after we release the lock; another option, if we didn't want to write a multi-thread test driver, would be to do the cancellation at the top of libxl's event loop. I think this captures roughly what we talked about. Please let me know if I misunderstood or missed out any details. Thanks, Euan