From patchwork Fri Oct 13 12:46:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 10004651 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 AC7D860360 for ; Fri, 13 Oct 2017 13:01:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DCF829002 for ; Fri, 13 Oct 2017 13:01:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 926162905F; Fri, 13 Oct 2017 13:01:30 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 33E5C29002 for ; Fri, 13 Oct 2017 13:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758199AbdJMNB1 (ORCPT ); Fri, 13 Oct 2017 09:01:27 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55877 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758096AbdJMMrS (ORCPT ); Fri, 13 Oct 2017 08:47:18 -0400 Received: by mail-wm0-f68.google.com with SMTP id u138so21641950wmu.4 for ; Fri, 13 Oct 2017 05:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7WgzfGXWXbeAKBLqN+NUo0/KDukzNdhkoN5EuoOdoOo=; b=Kk9LopncsAqJump5JI6zyLhSDT/NwKTZHYlIF9Hp9YUVcoC5WB4nnFpgMplOj2KJy9 0Ds73KFf6swiiGd7XFdDltinfAgVpuBEzABzMneNTCO6/wqClSBmjj/xXNM+lq7xtgoU YW1g9jxx5dW1qg9i/kulcHCIomY1vfnDjjOz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7WgzfGXWXbeAKBLqN+NUo0/KDukzNdhkoN5EuoOdoOo=; b=c9pweUhUx7kKfEkp45PTSuh6csUDX10LUji28z0io4d55BmY5o3Evx1U/BbAuwhZX5 Zmg1rAqU9u95lBCfQdfZUp0tTj0vM2LcZNKTxko41esu+QcSOckyWgPwdQelTo3QDKQs jfKAtE7AKKTGc7Ph6FU+oMB0NU9XEIJzCMTNc2WDqXXt8EWApxLQwkvLVP6ZHQZv/I/+ byvrPN4vTZORqLaX9vcbNzIYCQKihyUgn3xK/0WBKU1TDwCNod5LeMuBqVlfaFTGDbgJ fCl3moT4U0ExV5+4l2NXmfCI3u1lrUpyCl3gGCMhvwIlrCG3XZoIExkFZp12s2i73+/P HpHQ== X-Gm-Message-State: AMCzsaWQ16wrzWgfnUuNlA01sU9pCmAFqwUFNKcNQh8OM9q4G6ywtbGJ C4voz5kJrts2ndFISq/0Tyd6sg== X-Google-Smtp-Source: AOwi7QAZwBvqIYmprmciVi032mbinqGP2EerY2d0NDZTNoDFBd0rnD4wE7JvJftGDCn6sAQjhnl3eQ== X-Received: by 10.80.166.133 with SMTP id e5mr1983390edc.51.1507898836986; Fri, 13 Oct 2017 05:47:16 -0700 (PDT) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id p91sm735012edp.69.2017.10.13.05.47.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:16 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Rakesh Pandit , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 11/58] lightnvm: pblk: reuse pblk_gc_should_kick Date: Fri, 13 Oct 2017 14:46:00 +0200 Message-Id: <20171013124647.32668-12-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171013124647.32668-1-m@bjorling.me> References: <20171013124647.32668-1-m@bjorling.me> MIME-Version: 1.0 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 From: Rakesh Pandit 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 Made it apply to the common case. Reviewed-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 2 -- drivers/lightnvm/pblk-rl.c | 33 +++++++++------------------------ drivers/lightnvm/pblk.h | 1 - 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 8536d38..a68c6ae 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1591,8 +1591,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 2e6a536..9565c3b 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 9ece409..3a07c5b 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -824,7 +824,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);