Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-18 Thread Steven Rostedt
On Fri, 18 Aug 2017 16:21:46 + Bart Van Assche wrote: > Sorry Waiman but personally I thoroughly detest loops around mutex_trylock() > or > mutex_timed_lock() because such loops are usually used to paper over a problem > instead of fixing the root cause. 100% agree. -- Steve

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-18 Thread Waiman Long
On 08/18/2017 12:21 PM, Bart Van Assche wrote: > On Fri, 2017-08-18 at 09:55 -0400, Waiman Long wrote: >> On 08/17/2017 05:30 PM, Steven Rostedt wrote: >>> On Thu, 17 Aug 2017 17:10:07 -0400 >>> Steven Rostedt wrote: Instead of playing games with taking the lock, the only way this race i

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-18 Thread Bart Van Assche
On Fri, 2017-08-18 at 09:55 -0400, Waiman Long wrote: > On 08/17/2017 05:30 PM, Steven Rostedt wrote: > > On Thu, 17 Aug 2017 17:10:07 -0400 > > Steven Rostedt wrote: > > > Instead of playing games with taking the lock, the only way this race > > > is hit, is if the partition is being deleted and

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-18 Thread Waiman Long
On 08/17/2017 05:30 PM, Steven Rostedt wrote: > On Thu, 17 Aug 2017 17:10:07 -0400 > Steven Rostedt wrote: > > >> Instead of playing games with taking the lock, the only way this race >> is hit, is if the partition is being deleted and the sysfs attribute is >> being read at the same time, correct

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-18 Thread Waiman Long
On 08/17/2017 07:23 PM, Steven Rostedt wrote: > On Thu, 17 Aug 2017 18:18:18 -0400 > Steven Rostedt wrote: > >> On Thu, 17 Aug 2017 18:13:20 -0400 >> Steven Rostedt wrote: >> >>> On Thu, 17 Aug 2017 17:27:22 -0400 >>> Waiman Long wrote: >>> >>> It is actually what the patch is trying to

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Steven Rostedt
On Thu, 17 Aug 2017 18:18:18 -0400 Steven Rostedt wrote: > On Thu, 17 Aug 2017 18:13:20 -0400 > Steven Rostedt wrote: > > > On Thu, 17 Aug 2017 17:27:22 -0400 > > Waiman Long wrote: > > > > > > > It is actually what the patch is trying to do by checking for the > > > deletion flag in the m

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Steven Rostedt
On Thu, 17 Aug 2017 18:13:20 -0400 Steven Rostedt wrote: > On Thu, 17 Aug 2017 17:27:22 -0400 > Waiman Long wrote: > > > > It is actually what the patch is trying to do by checking for the > > deletion flag in the mutex_trylock loop. Please note that mutex does not > > guarantee FIFO ordering

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Steven Rostedt
On Thu, 17 Aug 2017 17:27:22 -0400 Waiman Long wrote: > It is actually what the patch is trying to do by checking for the > deletion flag in the mutex_trylock loop. Please note that mutex does not > guarantee FIFO ordering of lock acquisition. As a result, cpu1 may call > mutex_lock() and wait f

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Steven Rostedt
On Thu, 17 Aug 2017 17:10:07 -0400 Steven Rostedt wrote: > Instead of playing games with taking the lock, the only way this race > is hit, is if the partition is being deleted and the sysfs attribute is > being read at the same time, correct? In that case, just return > -ENODEV, and be done with

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Waiman Long
On 08/17/2017 05:10 PM, Steven Rostedt wrote: > On Thu, 17 Aug 2017 12:24:39 -0400 > Waiman Long wrote: > + * sysfs file and then acquiring the bd_mutex. Deleting a block device + * requires acquiring the bd_mutex and then waiting for all the sysfs + * references to be gone. This ca

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Steven Rostedt
On Thu, 17 Aug 2017 12:24:39 -0400 Waiman Long wrote: > >> + * sysfs file and then acquiring the bd_mutex. Deleting a block device > >> + * requires acquiring the bd_mutex and then waiting for all the sysfs > >> + * references to be gone. This can lead to deadlock if both operations > >> + * happ

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Steven Rostedt
On Thu, 17 Aug 2017 20:41:10 + Bart Van Assche wrote: > On Thu, 2017-08-17 at 16:30 -0400, Steven Rostedt wrote: > > On Thu, 17 Aug 2017 12:24:39 -0400 > > Waiman Long wrote: > > > > > On 08/17/2017 09:34 AM, Steven Rostedt wrote: > > > > On Wed, 16 Aug 2017 16:40:40 -0400 > > > > Waima

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Bart Van Assche
On Thu, 2017-08-17 at 16:30 -0400, Steven Rostedt wrote: > On Thu, 17 Aug 2017 12:24:39 -0400 > Waiman Long wrote: > > > On 08/17/2017 09:34 AM, Steven Rostedt wrote: > > > On Wed, 16 Aug 2017 16:40:40 -0400 > > > Waiman Long wrote: > > > > > > > The lockdep code had reported the following uns

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Steven Rostedt
On Thu, 17 Aug 2017 12:24:39 -0400 Waiman Long wrote: > On 08/17/2017 09:34 AM, Steven Rostedt wrote: > > On Wed, 16 Aug 2017 16:40:40 -0400 > > Waiman Long wrote: > > > >> The lockdep code had reported the following unsafe locking scenario: > >> > >>CPU0CPU1 > >>

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Waiman Long
On 08/17/2017 09:34 AM, Steven Rostedt wrote: > On Wed, 16 Aug 2017 16:40:40 -0400 > Waiman Long wrote: > >> The lockdep code had reported the following unsafe locking scenario: >> >>CPU0CPU1 >> >> lock(s_active#228); >>

Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-17 Thread Steven Rostedt
On Wed, 16 Aug 2017 16:40:40 -0400 Waiman Long wrote: > The lockdep code had reported the following unsafe locking scenario: > >CPU0CPU1 > > lock(s_active#228); >lock(&bdev->bd_mutex/1); >

[PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops

2017-08-16 Thread Waiman Long
The lockdep code had reported the following unsafe locking scenario: CPU0CPU1 lock(s_active#228); lock(&bdev->bd_mutex/1); lock(s_active#228); lock(&bdev->bd_mutex); *