WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] locking in drivers/xen/xen-pciback/passthrough.c:__xen_pcibk

To: "Konrad Rzeszutek Wilk" <konrad.wilk@xxxxxxxxxx>
Subject: [Xen-devel] locking in drivers/xen/xen-pciback/passthrough.c:__xen_pcibk_publish_pci_roots()
From: "Jan Beulich" <JBeulich@xxxxxxxx>
Date: Fri, 16 Sep 2011 15:08:07 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 16 Sep 2011 07:08:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Konrad,

this function, before calling the passed in callback, drops the lock it
acquired at the beginning of the function, and re-acquires it after the
callback returned. It also uses list_for_each_entry_safe() in an
apparent attempt to deal with races here. However, I'm getting the
impression that this wouldn't really work (as the construct really isn't
meant for this case): If in the meantime the successor element got
removed from the list, the loop continuation would access data that
may already have got freed.

I see two possible solutions: Either after re-acquiring the lock the
function checks whether the current object is sill on the list, starting
over if not found (xen_pcibk_publish_pci_root() makes sure a
device doesn't get published twice), or (if so possible) the lock gets
converted to a mutex (which should be safe to be held across the
callback invocation).

What are your thoughts here?

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>