From patchwork Fri Sep 22 08:40:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 9965537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7E346020C for ; Fri, 22 Sep 2017 08:41:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4643292DD for ; Fri, 22 Sep 2017 08:41:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A92122980A; Fri, 22 Sep 2017 08:41:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34D172981A for ; Fri, 22 Sep 2017 08:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751881AbdIVIlC (ORCPT ); Fri, 22 Sep 2017 04:41:02 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:47955 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751871AbdIVIlB (ORCPT ); Fri, 22 Sep 2017 04:41:01 -0400 Received: by mail-wm0-f51.google.com with SMTP id r136so1788415wmf.2 for ; Fri, 22 Sep 2017 01:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=ng5yEolGJZrBVOOFb2qYXnnp/6MPrMZ2qH738LSUWL0=; b=zUdb7+Wu+Vt7oh8bUSBU1iOsxEJp7Gks6nFI897joKH73YhJo6QIQ21ykq3O6MuaXa hTjlladimm9TOtSUZFvD3Waijt6HmHy1vCw6RHTAq1PSEwEV8lVem70aC7//XTLlzgd5 u/j/dH/NMv4zVcHVga0RZd8ziO6aBwS+7NcXuFk8kFVRj4asULNw+3r5Uvt7gzFp1uSB M1ExkGy8PnZtzJl8CRVuBoZ3rDQ+AQho8L0MrZts3m2nLJ3tjNdIj96TV6pwnJA1Tzbb xU5yYNODx7wYIv4G9ETPf/yq/FJOxuIo6FxlCESBudXQ0HmIN16TwAFi2oXBGtcyKtLT UddA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=ng5yEolGJZrBVOOFb2qYXnnp/6MPrMZ2qH738LSUWL0=; b=dNp7un+s0g4nJ5ri1LMKGq0HZarZ9e0mtnEKu+S+qJQ2x/TtXmuMhV5AnKI+E2HHqT n1bBnO2XDBLYKA/HAdcfb0BUL7wlrLTC9pMFTpMXyQqwq04K6FWGAI5rMWyjlp0kbGvm wYagSVoCDPU3ptGiVzu/we4BhIkuk+GlpjPkj+2XA8peGLeK0VseUEq0f+ppTCLAPjIC ezGWZnMaief9GidCZAmZ0fiTCMx9xeH9p4NMm1LpB2QWaCS+H+0sHmDbbn/JxeFwcT4L 47F774YiiULORv4bMKOeMOPS/5ZqSjKWkmMykIpIrd98fnaicA4NrKaCHnLYpoL6ta6/ 3/wQ== X-Gm-Message-State: AHPjjUhzspGkvFfC5k2MRPRmRlFxExBldcUq/brttNPJsfV7XuKOX3lD nIaD5GDZSkTZzK5LYP3QAt4fbA== X-Google-Smtp-Source: AOwi7QAzk9jz2ZfVGhQNEPjHCQy6v2jvSf9BmDw9g5pjODfiMXWCC+A6z0V+Qo5I17vNtz/LUcczUA== X-Received: by 10.80.179.120 with SMTP id r53mr4164863edd.174.1506069660076; Fri, 22 Sep 2017 01:41:00 -0700 (PDT) Received: from mac-halley13.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id q24sm1812415edb.49.2017.09.22.01.40.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 01:40:59 -0700 (PDT) From: =?utf-8?Q?Javier_Gonz=C3=A1lez?= Message-Id: Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH 1/6] lightnvm: pblk: reuse pblk_gc_should_kick Date: Fri, 22 Sep 2017 10:40:57 +0200 In-Reply-To: <20170921112539.GA28510@dhcp-216.srv.tuxera.com> Cc: =?utf-8?Q?Matias_Bj=C3=B8rling?= , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org To: Rakesh Pandit References: <20170921112539.GA28510@dhcp-216.srv.tuxera.com> X-Mailer: Apple Mail (2.3273) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > On 21 Sep 2017, at 13.25, Rakesh Pandit wrote: > > This is a trivial change which reuses pblk_gc_should_kick instead of > repeating it again in pblk_rl_free_lines_inc. > > Signed-off-by: Rakesh Pandit > --- > drivers/lightnvm/pblk-core.c | 1 + > drivers/lightnvm/pblk-rl.c | 9 --------- > 2 files changed, 1 insertion(+), 9 deletions(-) > > diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c > index 64a6a25..a230125 100644 > --- a/drivers/lightnvm/pblk-core.c > +++ b/drivers/lightnvm/pblk-core.c > @@ -1478,6 +1478,7 @@ static void __pblk_line_put(struct pblk *pblk, struct pblk_line *line) > spin_unlock(&l_mg->free_lock); > > pblk_rl_free_lines_inc(&pblk->rl, line); > + pblk_gc_should_kick(pblk); > } > > static void pblk_line_put_ws(struct work_struct *work) > diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c > index 596bdec..e7c162a 100644 > --- a/drivers/lightnvm/pblk-rl.c > +++ b/drivers/lightnvm/pblk-rl.c > @@ -129,18 +129,9 @@ static int pblk_rl_update_rates(struct pblk_rl *rl, unsigned long max) > > void pblk_rl_free_lines_inc(struct pblk_rl *rl, struct pblk_line *line) > { > - struct pblk *pblk = container_of(rl, struct pblk, rl); > int blk_in_line = atomic_read(&line->blk_in_line); > - int ret; > > atomic_add(blk_in_line, &rl->free_blocks); > - /* Rates will not change that often - no need to lock update */ > - ret = pblk_rl_update_rates(rl, rl->rb_budget); > - > - if (ret == (PBLK_RL_MID | PBLK_RL_LOW)) > - pblk_gc_should_start(pblk); > - else > - pblk_gc_should_stop(pblk); > } > > void pblk_rl_free_lines_dec(struct pblk_rl *rl, struct pblk_line *line) > -- > 2.5.0 Looking at the patch, I can see that a more general cleanup can be done. What do you think about this? We can merge it in this patch if you are OK with it. From 944936663c7eef7bc32243b89cc554e40ec436c5 Mon Sep 17 00:00:00 2001 From: Rakesh Pandit Date: Thu, 21 Sep 2017 14:25:40 +0300 Subject: [PATCH] lightnvm: pblk: reuse pblk_gc_should_kick This is a trivial change which reuses pblk_gc_should_kick instead of repeating it again in pblk_rl_free_lines_inc. Signed-off-by: Rakesh Pandit --- drivers/lightnvm/pblk-core.c | 2 -- drivers/lightnvm/pblk-rl.c | 33 +++++++++------------------------ drivers/lightnvm/pblk.h | 1 - 3 files changed, 9 insertions(+), 27 deletions(-) -- 2.7.4 diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 64a6a255514e..c92113b0a2e7 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1633,8 +1633,6 @@ void pblk_line_close(struct pblk *pblk, struct pblk_line *line) spin_unlock(&line->lock); spin_unlock(&l_mg->gc_lock); - - pblk_gc_should_kick(pblk); } void pblk_line_close_meta(struct pblk *pblk, struct pblk_line *line) diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c index 596bdec433c3..0896439a91b0 100644 --- a/drivers/lightnvm/pblk-rl.c +++ b/drivers/lightnvm/pblk-rl.c @@ -96,9 +96,11 @@ unsigned long pblk_rl_nr_free_blks(struct pblk_rl *rl) * * Only the total number of free blocks is used to configure the rate limiter. */ -static int pblk_rl_update_rates(struct pblk_rl *rl, unsigned long max) +static void pblk_rl_update_rates(struct pblk_rl *rl) { + struct pblk *pblk = container_of(rl, struct pblk, rl); unsigned long free_blocks = pblk_rl_nr_free_blks(rl); + int max = rl->rb_budget; if (free_blocks >= rl->high) { rl->rb_user_max = max; @@ -124,23 +126,18 @@ static int pblk_rl_update_rates(struct pblk_rl *rl, unsigned long max) rl->rb_state = PBLK_RL_LOW; } - return rl->rb_state; + if (rl->rb_state == (PBLK_RL_MID | PBLK_RL_LOW)) + pblk_gc_should_start(pblk); + else + pblk_gc_should_stop(pblk); } void pblk_rl_free_lines_inc(struct pblk_rl *rl, struct pblk_line *line) { - struct pblk *pblk = container_of(rl, struct pblk, rl); int blk_in_line = atomic_read(&line->blk_in_line); - int ret; atomic_add(blk_in_line, &rl->free_blocks); - /* Rates will not change that often - no need to lock update */ - ret = pblk_rl_update_rates(rl, rl->rb_budget); - - if (ret == (PBLK_RL_MID | PBLK_RL_LOW)) - pblk_gc_should_start(pblk); - else - pblk_gc_should_stop(pblk); + pblk_rl_update_rates(rl); } void pblk_rl_free_lines_dec(struct pblk_rl *rl, struct pblk_line *line) @@ -148,19 +145,7 @@ void pblk_rl_free_lines_dec(struct pblk_rl *rl, struct pblk_line *line) int blk_in_line = atomic_read(&line->blk_in_line); atomic_sub(blk_in_line, &rl->free_blocks); -} - -void pblk_gc_should_kick(struct pblk *pblk) -{ - struct pblk_rl *rl = &pblk->rl; - int ret; - - /* Rates will not change that often - no need to lock update */ - ret = pblk_rl_update_rates(rl, rl->rb_budget); - if (ret == (PBLK_RL_MID | PBLK_RL_LOW)) - pblk_gc_should_start(pblk); - else - pblk_gc_should_stop(pblk); + pblk_rl_update_rates(rl); } int pblk_rl_high_thrs(struct pblk_rl *rl) diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index eaf539715d71..d4b7dee0ef50 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -829,7 +829,6 @@ int pblk_gc_init(struct pblk *pblk); void pblk_gc_exit(struct pblk *pblk); void pblk_gc_should_start(struct pblk *pblk); void pblk_gc_should_stop(struct pblk *pblk); -void pblk_gc_should_kick(struct pblk *pblk); void pblk_gc_kick(struct pblk *pblk); void pblk_gc_sysfs_state_show(struct pblk *pblk, int *gc_enabled, int *gc_active);