From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752814AbbEFIKr (ORCPT ); Wed, 6 May 2015 04:10:47 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:32984 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbbEFIKN (ORCPT ); Wed, 6 May 2015 04:10:13 -0400 Date: Wed, 6 May 2015 17:10:29 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Sergey Senozhatsky , Andrew Morton , Nitin Gupta , linux-kernel@vger.kernel.org Subject: Re: [PATCHv4 00/10] add on-demand device creation Message-ID: <20150506081029.GA8385@swordfish> References: <1430743142-15854-1-git-send-email-sergey.senozhatsky@gmail.com> <20150506050114.GA29132@blaptop> <20150506052557.GA820@swordfish> <20150506070756.GC820@swordfish> <20150506072656.GA8163@blaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150506072656.GA8163@blaptop> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (05/06/15 16:28), Minchan Kim wrote: > > > > from your logs: > > ... > > [ 98.756017] zram: Removed device: zram2 > > [ 98.757087] ------------[ cut here ]------------ > > ... > > > > locked zram_index_mutex, removed zram2, unlocked zram_index_mutex, > > locked zram_index_mutex, attempted to create zram2: zram2 sysfs already exist. > > > > > > hm... need to think. zram hot/remove is serialized. > > I never look at the code but I doubt others(ex, some admin process on my machine) > holds a ref so kobj doesn't disapper yet but zram_add try to create it? > well, something like this is certainly happening. hm, if this is the case, then a very quick thing I can think of is to stop re-using previously used zram ids. add_disk() doesn't give us a chance to handle any errors and testing for sysfs leftovers in zram_add() looks weird. btw, do you also want me to rename zram-control sysfs handlers? zram_add -> zram_hot_add() ? i think zram_add()/zram_remove() is just ok. can you please test this patch? --- drivers/block/zram/zram_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index e6c4316..b31f0c20 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1184,7 +1184,7 @@ static int zram_add(void) if (!zram) return -ENOMEM; - ret = idr_alloc(&zram_index_idr, zram, 0, 0, GFP_KERNEL); + ret = idr_alloc_cyclic(&zram_index_idr, zram, 0, 0, GFP_KERNEL); if (ret < 0) goto out_free_dev; device_id = ret;