From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751557AbcEMGWe (ORCPT ); Fri, 13 May 2016 02:22:34 -0400 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:47244 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750918AbcEMGWd (ORCPT ); Fri, 13 May 2016 02:22:33 -0400 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 165.244.98.203 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 10.177.223.161 X-Original-MAILFROM: minchan@kernel.org Date: Fri, 13 May 2016 15:23:03 +0900 From: Minchan Kim To: Sergey Senozhatsky CC: Sergey Senozhatsky , Andrew Morton , , Subject: Re: [PATCH] zram: introduce per-device debug_stat sysfs node Message-ID: <20160513062303.GA21204@bbox> References: <20160511134553.12655-1-sergey.senozhatsky@gmail.com> <20160512234143.GA27204@bbox> <20160513010929.GA615@swordfish> MIME-Version: 1.0 In-Reply-To: <20160513010929.GA615@swordfish> User-Agent: Mutt/1.5.21 (2010-09-15) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB04/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/05/13 15:22:28, Serialize by Router on LGEKRMHUB04/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/05/13 15:22:28, Serialize complete at 2016/05/13 15:22:28 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 13, 2016 at 10:09:29AM +0900, Sergey Senozhatsky wrote: > Hello Minchan, > > On (05/13/16 08:41), Minchan Kim wrote: > [..] > > will fix and update, thanks! > > > > > @@ -719,6 +737,8 @@ compress_again: > > > zcomp_strm_release(zram->comp, zstrm); > > > zstrm = NULL; > > > > > > + atomic64_inc(&zram->stats.num_recompress); > > > + > > > > It should be below "goto compress_again". > > I moved it out of goto intentionally. this second zs_malloc() > > handle = zs_malloc(meta->mem_pool, clen, > GFP_NOIO | __GFP_HIGHMEM | > __GFP_MOVABLE); > > can take some time to complete, which will slow down zram for a bit, > and _theoretically_ this second zs_malloc() still can fail. yes, we > would do the error print out pr_err("Error allocating memory ... ") > and inc the `failed_writes' in zram_bvec_rw(), but zram_bvec_write() > has several more error return paths that can inc the `failed_writes'. > so by just looking at the stats we won't be able to tell that we had > failed fast path allocation combined with failed slow path allocation > (IOW, `goto recompress' never happened). > > so I'm thinking about changing its name to num_failed_fast_compress > or num_failed_fast_write, or something similar and thus count the number > of times we fell to "!handle" branch, not the number of goto-s. > what do you think? or do you want it to be num_recompress specifically? Sorry, I don't get your point. What's the problem with below? goto compress_again so atomic_inc(num_recompress) My concern isn't a performance or something but just want to be more readable and not error-prone which can increase num_compress although second zs_malloc could be failed. When I tested with heavy workload, I saw second zs_malloc can be fail but not frequently so it's not theoretical issue. What's the your concern with below? Sorry if I don't get your point. Please elaborate it more. diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index a629bd8d452b..8bdcc4b2b9b8 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -737,12 +737,12 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, zcomp_strm_release(zram->comp, zstrm); zstrm = NULL; - atomic64_inc(&zram->stats.num_recompress); - handle = zs_malloc(meta->mem_pool, clen, GFP_NOIO | __GFP_HIGHMEM); - if (handle) + if (handle) { + atomic64_inc(&zram->stats.num_recompress); goto compress_again; + } pr_err("Error allocating memory for compressed page: %u, size=%zu\n", index, clen);