From: Ian Campbell Subject: Re: [PATCH] tools/hotplug: fix locking Date: Wed, 4 Jul 2012 15:48:02 +0100 Message-ID: <1341413282.31696.72.camel@zakaz.uk.xensource.com> References: <650b03f412143c3057ab.1339608555@zhigang.us.oracle.com> <1340206463.4906.72.camel@zakaz.uk.xensource.com> <4FE20E27.8000108@oracle.com> <1340278976.21872.114.camel@zakaz.uk.xensource.com> <1340279364.21872.118.camel@zakaz.uk.xensource.com> <20120621122022.GO21124@redhat.com> <1340725992.3832.159.camel@zakaz.uk.xensource.com> <20120626161423.GV14451@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20120626161423.GV14451@redhat.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: "Daniel P. Berrange" Cc: Andrew Jones , Ian Jackson , xen-devel , Don Dutile , Kouya Shimura , Zhigang Wang List-Id: xen-devel@lists.xenproject.org [...] > > Thanks, this description makes sense. I'd be inclined to use it verbatim > > as the commit message. [...] > > Therefore I think it is appropriate to include your S-o-b on the new > > patch -- assuming you are OK with that? > > Yes, that's fine with me Thanks. I have applied with the following revised commit message: hotplug/Linux: use flock based locking In the normal case of a single domain booting with one disk, the disk hotplug script will fire once. In this case taking out the lock will never cause a sleep because there's no other concurrent invocations. If a domain has 4 disks configured, then the hotplug script will fire 4 times, all 4 invocations at pretty much the same time. If there is even a little load on the system, the locking function in the shell script will sleep for a few seconds - as many as 5 seconds, or potentially even time out & fail completely. If say 4 or even more domains each with 4 disks start up at once, that's 16 invocations of the hotplug script running at once. There will be alot of sleep's done & because of the very coarse 1 second granularity the delay can add up significantly. The change to using flock() removes the arbitrary 1 second sleep, so the very instant once hotplug script finishes, another can start & there is no repeated attempts & failures to lock which would add more delay. In addition the current locking implementation would allow two processes get the lock simultaneously if one decided the other had timed out. Signed-off-by: Daniel P. Berrange Signed-off-by: Zhigang Wang Acked-by: Ian Campbell