linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Nitin Gupta <ngupta@vflare.org>,
	linux-kernel@vger.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [PATCHv3 9/9] zram: add dynamic device add/remove functionality
Date: Thu, 30 Apr 2015 14:47:02 +0900	[thread overview]
Message-ID: <20150430054702.GA21771@blaptop> (raw)
In-Reply-To: <20150429072328.GA2987@swordfish>

Hello Sergey,

On Wed, Apr 29, 2015 at 04:23:28PM +0900, Sergey Senozhatsky wrote:
> On (04/29/15 16:02), Sergey Senozhatsky wrote:
> > sure. I was talking about this one:
> > 
> > 	CPU0			CPU1
> > 	umount
> > 	zram_remove()
> > 	lock ->bd_mutex
> > 	zram_reset_device()
> > 	unlock ->bd_mutex
> > 				disksize_store
> > 				mount
> > 				echo 'test' > /mnt/test
> > 	kfree zram
> > 				zram write
> > 
> 
> I'll take a look later today. currently I think of something like:
> 
> 
> 	sysfs_remove_group()
> 	lock ->bd_mutex
> 		... check ->bd_openers
> 
> 	zram_reset_device()
> 	blk_cleanup_queue()
> 	del_gendisk()
> 	put_disk()
> 
> 	unlock ->bd_mutex
> 	bdput bdev
> 
> 	idr_remove()
> 	kfree(zram)
> 
> 
> iow, idr_remove() and kfree() are done outside of ->bd_mutex lock.
> but I may be wrong. haven't tested yet. but seems reasonable: we
> invalidate ->bdev, delete partitions, etc., holding ->bd_mutex and
> then release ->bdev, which does final put. need to check that in
> detail.
> 
> 	-ss


Isn't it related to bd_mutex?
I think the problem of deadlock is that you are trying to remove sysfs file
in sysfs handler.

#> echo 1 > /sys/xxx/zram_remove

kernfs_fop_write - hold s_active
  -> zram_remove_store
    -> zram_remove
      -> sysfs_remove_group - hold s_active *again*

Right?

-- 
Kind regards,
Minchan Kim

  reply	other threads:[~2015-04-30  5:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 13:21 [PATCHv3 0/9] introduce on-demand device creation Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 1/9] zram: add `compact` sysfs entry to documentation Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 2/9] zram: cosmetic ZRAM_ATTR_RO code formatting tweak Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 3/9] zram: use idr instead of `zram_devices' array Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 4/9] zram: reorganize code layout Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 5/9] zram: remove max_num_devices limitation Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 6/9] zram: report every added and removed device Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 7/9] zram: trivial: correct flag operations comment Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 8/9] zram: return zram device_id from zram_add() Sergey Senozhatsky
2015-04-27 13:21 ` [PATCHv3 9/9] zram: add dynamic device add/remove functionality Sergey Senozhatsky
2015-04-29  0:16   ` Sergey Senozhatsky
2015-04-29  6:48     ` Minchan Kim
2015-04-29  7:02       ` Sergey Senozhatsky
2015-04-29  7:23         ` Sergey Senozhatsky
2015-04-30  5:47           ` Minchan Kim [this message]
2015-04-30  6:34             ` Sergey Senozhatsky
2015-04-30  6:44               ` Minchan Kim
2015-04-30  6:51                 ` Sergey Senozhatsky
2015-05-04  2:20                   ` Minchan Kim
2015-05-04  2:28                     ` Minchan Kim
2015-05-04  6:32                       ` Sergey Senozhatsky
2015-05-04  6:29                     ` Sergey Senozhatsky
2015-05-04 11:34                     ` Sergey Senozhatsky
2015-04-30  6:44               ` Sergey Senozhatsky
2015-04-27 13:41 ` [PATCHv3 0/9] introduce on-demand device creation Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150430054702.GA21771@blaptop \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ngupta@vflare.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).