From: Keir Fraser Subject: Re: Re: First post-xenbus-change USB patch Date: Tue, 15 Nov 2005 16:55:57 +0000 Message-ID: <9a4dcd1b8bd588f15a1363d29912646e@cl.cam.ac.uk> References: <1132068201.29871.48.camel@localhost.localdomain> <20051115153748.GL14433@leeni.uk.xensource.com> Mime-Version: 1.0 (Apple Message framework v623) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: 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: Keir Fraser Cc: harry , xen-devel@lists.xensource.com, Ewan Mellor List-Id: xen-devel@lists.xenproject.org On 15 Nov 2005, at 16:12, Keir Fraser wrote: >> Yes, we really need to address that one. The code says >> >> /* Flush any currently-executing callback, unless we are it. :-) */ >> >> (IIRC, that's the deadlock point that Rusty highlighted) but I don't >> really >> know what this means. Can you shed some light here on what we ought >> to be >> doing? > > I'd love to see the xenwatch_mutex disappear -- it could well be > involved in a deadlock situation. It is only used to ensure that an > unregistered watch is not still executing when > unregister_xenbus_watch() returns, but that is kind of important if > e.g., module code is about to get blown away. :-) > > I'll have a think about it... Actually I now remember that this is a hard one to avoid. Callers will often be interested in unregister being synchronous (so they can safely unload module code, free the xenbus_watch, or whatever) but if they ever call unregister_xenbus_watch() with a resource held (e.g., a mutex) that the watch callback also may acquire, then we have possibility of a deadlock. And there are various slightly hidden mutexes in sysfs.... :-( -- Keir