From patchwork Mon Jun 26 09:57:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 9809067 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 F37B360209 for ; Mon, 26 Jun 2017 10:03:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05D0428487 for ; Mon, 26 Jun 2017 10:03:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC7C52851B; Mon, 26 Jun 2017 10:03:36 +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 712C7274D2 for ; Mon, 26 Jun 2017 10:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752388AbdFZKBX (ORCPT ); Mon, 26 Jun 2017 06:01:23 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:34535 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751858AbdFZJ6X (ORCPT ); Mon, 26 Jun 2017 05:58:23 -0400 Received: by mail-wm0-f50.google.com with SMTP id t129so816080wmt.1 for ; Mon, 26 Jun 2017 02:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DETxeqsO7yNpgigDlAkKZHteGJn6P9wvWDbje8Fnb74=; b=bjh3eEVNa6RHctchK+2ROLzsuYCqmSEspB11XT+MjIzP7tsXkG60PMIRNMcmvt5tZD f9YCn8j4YywXObT7ilWzpziwxfL3DNLKIPneZ9pMeX+H/5kcvwf4qCK153IftbRVeWQF dwF5Ev0n7X47Rn6WAYJxoMyOy9mnwx/JzX5h1v9uy7ZFmjtMNcChSfiWdVzAcVuqFUds oNrcrGSwytT8X3J2uJGrNJGQXAQx34aQ3+ZTyqHKzAJOFN+O3NdsWLbiMysSkTg9MBkp HnwYtuQK3mMf0w+rYprrJpnU9Y6ftyVDWhfItgNlysxdtMG060PzxUDR3ArpF4OJJRVu PNow== 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=DETxeqsO7yNpgigDlAkKZHteGJn6P9wvWDbje8Fnb74=; b=tXnk3TT+l7Gofwb30JZRzUYWwoG1obAs7a+Y45YgIN5zuNSI2k9vpGHCs0+nnN+yl0 AeDChxsCBjLUl1Em6z2IsHdMBcnZmTu5mybB/3ejhWniDI6r23J6i1D6muqHzOdNyZec 9Lb1pAtANe0Srs8gLTAq38NXUV7QaJdweG6OVyBsW+0NQWX9NWWnrdDeAVnFquLim3oY kSAUZFboAzFsVmR7d50zUI6MGgeTthzZYDPvpmAxmUkrBC2bzAo/hqO2YVtPmUzsfWTl xjOS3Zd4+vW49FR3ooNlN5m8JG3c0fkvSomOuQmXWBCbw1XmhbyAY8tA7ANOnMt0f3uD Exuw== X-Gm-Message-State: AKS2vOyMGWsMcJlg13/cODmP7b0WxLRGs8pqbj7AMdOJBtIcH+uJ7z4e M6AdmmSqLDll0qRq X-Received: by 10.80.145.25 with SMTP id e25mr16223063eda.8.1498471102557; Mon, 26 Jun 2017 02:58:22 -0700 (PDT) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id n26sm5212537edd.51.2017.06.26.02.58.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Jun 2017 02:58:22 -0700 (PDT) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io, axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 14/20] lightnvm: pblk: choose optimal victim GC line Date: Mon, 26 Jun 2017 11:57:23 +0200 Message-Id: <1498471049-25505-15-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498471049-25505-1-git-send-email-javier@cnexlabs.com> References: <1498471049-25505-1-git-send-email-javier@cnexlabs.com> 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 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 Signed-off-by: Matias Bjørling --- 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);