mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Javier González" <jg@lightnvm.io>
To: mb@lightnvm.io, axboe@fb.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Javier González" <javier@cnexlabs.com>,
	"Matias Bjørling" <matias@cnexlabs.com>
Subject: [PATCH 14/20] lightnvm: pblk: choose optimal victim GC line
Date: Mon, 26 Jun 2017 11:57:23 +0200	[thread overview]
Message-ID: <1498471049-25505-15-git-send-email-javier@cnexlabs.com> (raw)
In-Reply-To: <1498471049-25505-1-git-send-email-javier@cnexlabs.com>

At the moment, we separate the closed lines on three different list
based on their number of valid sectors. GC recycles lines from each list
based on capacity. Lines from each list are taken in a FIFO fashion.

Since the number of lines is limited (it corresponds to the number of
blocks in a LUN, which is somewhere between 1000-2000), we can afford
scanning the lists to choose the optimal line to be recycled. This helps
specially in lines with a high number of valid sectors.

If the number of blocks per LUN increases, we will consider a more
efficient policy.

Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
---
 drivers/lightnvm/pblk-gc.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c
index 2e7fb7a51854..f811e4ca63f4 100644
--- a/drivers/lightnvm/pblk-gc.c
+++ b/drivers/lightnvm/pblk-gc.c
@@ -287,6 +287,20 @@ static void pblk_gc_lines(struct pblk *pblk, struct list_head *gc_list)
 	}
 }
 
+static struct pblk_line *pblk_gc_get_victim_line(struct pblk *pblk,
+						 struct list_head *group_list)
+{
+	struct pblk_line *line, *victim;
+
+	victim = list_first_entry(group_list, struct pblk_line, list);
+	list_for_each_entry(line, group_list, list) {
+		if (*line->vsc < *victim->vsc)
+			victim = line;
+	}
+
+	return victim;
+}
+
 /*
  * Lines with no valid sectors will be returned to the free list immediately. If
  * GC is activated - either because the free block count is under the determined
@@ -332,7 +346,7 @@ static void pblk_gc_run(struct pblk *pblk)
 			return;
 		}
 
-		line = list_first_entry(group_list, struct pblk_line, list);
+		line = pblk_gc_get_victim_line(pblk, group_list);
 		nr_blocks_free += atomic_read(&line->blk_in_line);
 
 		spin_lock(&line->lock);
-- 
2.7.4

  parent reply	other threads:[~2017-06-26 10:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26  9:57 [PATCH 00/20] LightNVM: pblk patches for 4.13 Javier González
2017-06-26  9:57 ` [PATCH 01/20] lightnvm: re-convert ppa format on I/O failure Javier González
2017-06-26  9:57 ` [PATCH 02/20] lightnvm: propagate right error code to target Javier González
2017-06-26  9:57 ` [PATCH 03/20] lightnvm: pblk: spare double cpu_to_le64 calc Javier González
2017-06-26  9:57 ` [PATCH 04/20] lightnvm: pblk: add debug stat for read cache hits Javier González
2017-06-26  9:57 ` [PATCH 05/20] lightnvm: pblk: expose max sec per write on sysfs Javier González
2017-06-26  9:57 ` [PATCH 06/20] lightnvm: pblk: generalize erase path Javier González
2017-06-26  9:57 ` [PATCH 07/20] lightnvm: pblk: rename read request pool Javier González
2017-06-26  9:57 ` [PATCH 08/20] lightnvm: pblk: sched. metadata on write thread Javier González
2017-09-20 18:28   ` Rakesh Pandit
2017-09-20 19:25     ` Rakesh Pandit
2017-06-26  9:57 ` [PATCH 09/20] lightnvm: pblk: delete redundant debug line stat Javier González
2017-06-26  9:57 ` [PATCH 10/20] lightnvm: pblk: delete redundant buffer pointer Javier González
2017-06-26  9:57 ` [PATCH 11/20] lightnvm: pblk: issue multiplane reads if possible Javier González
2017-06-26  9:57 ` [PATCH 12/20] lightnvm: pblk: simplify meta. memory allocation Javier González
2017-06-26  9:57 ` [PATCH 13/20] lightnvm: pblk: decouple bad block from line alloc Javier González
2017-06-26  9:57 ` Javier González [this message]
2017-06-26  9:57 ` [PATCH 15/20] lightnvm: pblk: set metadata list for all I/Os Javier González
2017-06-26  9:57 ` [PATCH 16/20] lightnvm: pblk: cleanup unnecessary code Javier González
2017-06-26  9:57 ` [PATCH 17/20] lightnvm: pblk: add lock assertions on helpers Javier González
2017-06-26  9:57 ` [PATCH 18/20] lightnvm: pblk: redesign GC algorithm Javier González
2017-06-26  9:57 ` [PATCH 19/20] lightnvm: pblk: set mempool and workqueue params Javier González
2017-06-26  9:57 ` [PATCH 20/20] lightnvm: pblk: fail gracefully on irrec. error Javier González
2017-06-26 22:29 ` [PATCH 00/20] LightNVM: pblk patches for 4.13 Jens Axboe
2017-06-27  8:00   ` Javier González

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498471049-25505-15-git-send-email-javier@cnexlabs.com \
    --to=jg@lightnvm.io \
    --cc=axboe@fb.com \
    --cc=javier@cnexlabs.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matias@cnexlabs.com \
    --cc=mb@lightnvm.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®