From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932631AbbBBFJQ (ORCPT ); Mon, 2 Feb 2015 00:09:16 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:62367 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751240AbbBBFJP (ORCPT ); Mon, 2 Feb 2015 00:09:15 -0500 Date: Mon, 2 Feb 2015 14:09:12 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Sergey Senozhatsky , Andrew Morton , "linux-kernel@vger.kernel.org" , Linux-MM , Nitin Gupta , Jerome Marchand , Ganesh Mahendran Subject: Re: [PATCH v1 2/2] zram: remove init_lock in zram_make_request Message-ID: <20150202050912.GA443@swordfish> References: <20150129060604.GC2555@swordfish> <20150129063505.GA32331@blaptop> <20150129070835.GD2555@swordfish> <20150130144145.GA2840@blaptop> <20150201145036.GA1290@swordfish> <20150202013028.GB6402@blaptop> <20150202014800.GA6977@swordfish> <20150202024405.GD6402@blaptop> <20150202040124.GE6977@swordfish> <20150202042847.GG6402@blaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150202042847.GG6402@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 the patch mosly looks good, except for one place: On (02/02/15 13:28), Minchan Kim wrote: > @@ -783,6 +812,8 @@ static ssize_t disksize_store(struct device *dev, > goto out_destroy_comp; > } > > + init_waitqueue_head(&zram->io_done); > + zram_meta_get(zram); it was + init_completion(&zram->io_done); + atomic_set(&zram->refcount, 1); I think we need to replace zram_meta_get(zram) with atomic_set(&zram->refcount, 1). ->refcount is 0 by default and atomic_inc_not_zero(&zram->refcount) will not increment it here, nor anywhere else. > zram->meta = meta; > zram->comp = comp; > zram->disksize = disksize; > @@ -838,8 +869,8 @@ static ssize_t reset_store(struct device *dev, > /* Make sure all pending I/O is finished */ > fsync_bdev(bdev); > bdput(bdev); > - [..] > @@ -1041,6 +1075,7 @@ static int create_device(struct zram *zram, int device_id) > int ret = -ENOMEM; > > init_rwsem(&zram->init_lock); > + atomic_set(&zram->refcount, 0); sorry, I forgot that zram is kzalloc()-ated. so we can drop atomic_set(&zram->refcount, 0) > zram->queue = blk_alloc_queue(GFP_KERNEL); > if (!zram->queue) { -ss