From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751389AbdAaQPQ (ORCPT ); Tue, 31 Jan 2017 11:15:16 -0500 Received: from smtp.nue.novell.com ([195.135.221.5]:44461 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbdAaQPN (ORCPT ); Tue, 31 Jan 2017 11:15:13 -0500 Subject: Re: [PATCH] genhd: Do not hold event lock when scheduling workqueue elements To: Bart Van Assche , "hare@suse.de" , "axboe@kernel.dk" References: <1484732896-22941-1-git-send-email-hare@suse.de> <1485822639.2669.16.camel@sandisk.com> Cc: "hch@lst.de" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "jth@kernel.org" From: Hannes Reinecke Message-ID: <532c55c4-15da-d2f9-401c-36bc4343756b@suse.com> Date: Tue, 31 Jan 2017 17:15:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <1485822639.2669.16.camel@sandisk.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/31/2017 01:31 AM, Bart Van Assche wrote: > On Wed, 2017-01-18 at 10:48 +0100, Hannes Reinecke wrote: >> @@ -1488,26 +1487,13 @@ static unsigned long disk_events_poll_jiffies(struct gendisk *disk) >> void disk_block_events(struct gendisk *disk) >> { >> struct disk_events *ev = disk->ev; >> - unsigned long flags; >> - bool cancel; >> >> if (!ev) >> return; >> >> - /* >> - * Outer mutex ensures that the first blocker completes canceling >> - * the event work before further blockers are allowed to finish. >> - */ >> - mutex_lock(&ev->block_mutex); >> - >> - spin_lock_irqsave(&ev->lock, flags); >> - cancel = !ev->block++; >> - spin_unlock_irqrestore(&ev->lock, flags); >> - >> - if (cancel) >> + if (atomic_inc_return(&ev->block) == 1) >> cancel_delayed_work_sync(&disk->ev->dwork); >> >> - mutex_unlock(&ev->block_mutex); >> } > > Hello Hannes, > > I have already encountered a few times a deadlock that was caused by the > event checking code so I agree with you that it would be a big step forward > if such deadlocks wouldn't occur anymore. However, this patch realizes a > change that has not been described in the patch description, namely that > disk_block_events() calls are no longer serialized. Are you sure it is safe > to drop the serialization of disk_block_events() calls? > Well, this whole synchronization stuff it a bit weird; I so totally fail to see the rationale for it. But anyway, once we've converted ev->block to atomics I _think_ the mutex_lock can remain; will be checking. Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage hare@suse.com +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)