Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4296089ima; Mon, 4 Feb 2019 13:51:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ7J0anMqkfK6CTP4dTXB88uGhtdLxFIrvDDId4hYWt6NE0KPk8g2LFVZnIERAYrRWzqIY3 X-Received: by 2002:a17:902:aa07:: with SMTP id be7mr1553924plb.63.1549317105377; Mon, 04 Feb 2019 13:51:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549317105; cv=none; d=google.com; s=arc-20160816; b=Ly52c09mF+XKr+o4xGOsn36LoovPVv+uV/AfvuRLbzlClKJ/xzdN4rOObeIBR35URv FjkxWNZf6pWEAz88hrC62ZwnZypToqvWkbXnz006ONrFSzlG2sn8VnlgiJKxBnEN42sK MTQ79cbJU1yMxxHjwttjo0HmXje3DSxBVYcigUu2dB89QbjgP0vUuEbVxxEv840Mi0uH pBoXvoZ1nB2vBD/Po8yccdnNr0PtHTBM2YpYBt7pEuZspf2i0g/nl5ZNJipPPBAG5EMV hNCFJSZfns64Y4zNT/+RQjPGuQliLV01zaaBb51A44KDwn38omll603aMaff8IQeqZmk yGaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=iS2DS0EreyOW923rGTwRLJoF4/Y7vjF2KlO4voKmpYk=; b=hUqgTFjPaw2qGiCPtQRQ8fTojHSXU+iKcBp0Mjd72KCLW1Naz0Cl/TWDoBdrpGaa5q xDQB2k4nwgMk3NkS3tpFJWHRAENBlWHZKaabGIq3qPFsahMD2nC5/9M1bl/zhJbiX2Y8 y92A2bTdfx1Rka03r+O1S/yJG9lcqfuzwZPVBIRhxDMa29EbNkwB0w026xnVy/eJMJEC jDG96Eet6EhuQFea7kEEbzSlIiLnsZB9bqSo33AONjwsTMvsSGKt8d+BySL7lmdkMy8c fj2/KleL39GNU0m+BANeTmlsCf8T61UxOoVmn8M27P274u7GC4yur0cMgIynUp0/oEwb 4cIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=tf3s9lJb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb2si1291790plb.298.2019.02.04.13.51.29; Mon, 04 Feb 2019 13:51:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=tf3s9lJb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730072AbfBDVHq (ORCPT + 99 others); Mon, 4 Feb 2019 16:07:46 -0500 Received: from mail-ua1-f68.google.com ([209.85.222.68]:43830 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728004AbfBDVHo (ORCPT ); Mon, 4 Feb 2019 16:07:44 -0500 Received: by mail-ua1-f68.google.com with SMTP id z11so449519uaa.10 for ; Mon, 04 Feb 2019 13:07:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=iS2DS0EreyOW923rGTwRLJoF4/Y7vjF2KlO4voKmpYk=; b=tf3s9lJbDBaGD9GdeJyLywErJrzLLK6DAge2hzfpBSYkMFId+6VFL5XmB2CGP+syYw bAX330VvYG+RdQypCxIRg4I5fWC9nndyF6huDHYq7hAQr79tq3jz5/RSnw/zVRbTvI7F JZpc1EElv7bQBhViorKibOsa26snaO2Qq/YSndon82XBNE2wFVZLP7rj2gllc6djluYl CvZHIxdoP/nLK+T5LhR4kO6COH6ZpUqeqggu3NJgj6MPZ7shKSuGqenuQYBELT74i2lU m/1VtUNq+/sSs+ERBj23MZkKLnHyJ9y9ui6zseDSqs88i0PPsALlM022Yi2Hg4R0N9Dp GLgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=iS2DS0EreyOW923rGTwRLJoF4/Y7vjF2KlO4voKmpYk=; b=nbwHXvzHG9utoMmHt7zbcR1fuBu6/97232QA/Pd4JmKruFIXJBMuiDXqibCNa61Unb sszypXKLAyoeFOvnIW29h6evrZjaxaHamzDpE+EMec5udEQORoZgdL7x23oro1x6eeO2 WwTqgK4aemkvWttR9Hcc4oSqBqa5W7ZnXiVXMLhsJeilsURPHqAvbvUOC9SeVJ09/4af 5+iCyQT80kMzgCorvGJwdHWWCNLV2vZNiJFuYc60KFof8oNuoPIDwvJnHMlxHFUffKBl tj2bX6/5j4vdAzaC1gcKPZrFYrO//9BwGgalW5sbwr0J/wpWPeJ3ieSGqF4BVNtEXHBt 4Flw== X-Gm-Message-State: AHQUAuZHp7DAkkhgEQPErFRudvOXRZhq/ftm3yKXtyKSzVpL7Yx9ESk0 0rwRPS4athCWGEpogYBTDX2l33YjpOwDeMP4AjWVyg== X-Received: by 2002:ab0:49ee:: with SMTP id f43mr548107uad.29.1549314462969; Mon, 04 Feb 2019 13:07:42 -0800 (PST) MIME-Version: 1.0 References: <20190130102604.14496-1-javier@javigon.com> <3E3CC5BE-585A-4F0A-8EC7-7FE5F855E888@javigon.com> In-Reply-To: <3E3CC5BE-585A-4F0A-8EC7-7FE5F855E888@javigon.com> From: Hans Holmberg Date: Mon, 4 Feb 2019 22:07:32 +0100 Message-ID: Subject: Re: [PATCH V2] lightnvm: pblk: prevent stall due to wb threshold To: =?UTF-8?Q?Javier_Gonz=C3=A1lez?= Cc: =?UTF-8?Q?Matias_Bj=C3=B8rling?= , Hans Holmberg , linux-block@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 4, 2019 at 9:14 AM Javier Gonz=C3=A1lez wr= ote: > > > > On 31 Jan 2019, at 21.10, Hans Holmberg wrote: > > > > On Thu, Jan 31, 2019 at 5:33 PM Javier Gonz=C3=A1lez wrote: > >>> On 31 Jan 2019, at 11.41, Hans Holmberg wrote: > >>> > >>> Hi Javier! > >>> > >>> How did you test this? I'm trying to add a test case to our testing f= ramework. > >>> > >>> This is what i ran in qemu, and I got a hang (with this version of th= e patch) > >>> > >>> nvme lnvm create -d nvme0n1 -t pblk -n pblk0 -f -b 0 -e 0 > >> > >> I run several low configurations without problem. Can you share the qe= mu configuration and version? > > > > Of course! > > > > qemu remote: https://github.com/CNEX-Labs/qemu-nvme.git > > branch: master (cb200e3ccf9c1ff21f6275c6cb68b2801135a640) > > > > My geometry: > > parallel units: 8, secs per chk: 768, meta size 16, ws min 12, ws opt > > 24, cunits=3D0 > > You are right, lmw_cunits=3D0 gives the problem. > > What about the following? If it goes through cijoe, I'll send a V3. Please do send a V3 if it passes your testing. Thanks! Hans > > diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c > index d4ca8c64ee0f..a6133b50ed9c 100644 > --- a/drivers/lightnvm/pblk-rb.c > +++ b/drivers/lightnvm/pblk-rb.c > @@ -45,10 +45,23 @@ void pblk_rb_free(struct pblk_rb *rb) > /* > * pblk_rb_calculate_size -- calculate the size of the write buffer > */ > -static unsigned int pblk_rb_calculate_size(unsigned int nr_entries) > +static unsigned int pblk_rb_calculate_size(unsigned int nr_entries, > + unsigned int threshold) > { > - /* Alloc a write buffer that can at least fit 128 entries */ > - return (1 << max(get_count_order(nr_entries), 7)); > + unsigned int thr_sz =3D 1 << (get_count_order(threshold + NVM_MAX= _VLBA)); > + unsigned int max_sz =3D max(thr_sz, nr_entries); > + unsigned int max_io; > + > + /* Alloc a write buffer that can (i) fit at least two split bios > + * (considering max I/O size NVM_MAX_VLBA, and (ii) guarantee tha= t the > + * threshold will be respected > + */ > + max_io =3D (1 << max((int)(get_count_order(max_sz)), > + (int)(get_count_order(NVM_MAX_VLBA << 1))= )); > + if ((threshold + NVM_MAX_VLBA) >=3D max_io) > + max_io <<=3D 1; > + > + return max_io; > } > > /* > @@ -67,12 +80,12 @@ int pblk_rb_init(struct pblk_rb *rb, unsigned int siz= e, unsigned int threshold, > unsigned int alloc_order, order, iter; > unsigned int nr_entries; > > - nr_entries =3D pblk_rb_calculate_size(size); > + nr_entries =3D pblk_rb_calculate_size(size, threshold); > entries =3D vzalloc(array_size(nr_entries, sizeof(struct pblk_rb_= entry))); > if (!entries) > return -ENOMEM; > > - power_size =3D get_count_order(size); > + power_size =3D get_count_order(nr_entries); > power_seg_sz =3D get_count_order(seg_size); > > down_write(&pblk_rb_lock); > @@ -149,7 +162,7 @@ int pblk_rb_init(struct pblk_rb *rb, unsigned int siz= e, unsigned int threshold, > * Initialize rate-limiter, which controls access to the write bu= ffer > * by user and GC I/O > */ > - pblk_rl_init(&pblk->rl, rb->nr_entries); > + pblk_rl_init(&pblk->rl, rb->nr_entries, threshold); > > return 0; > } > diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c > index 76116d5f78e4..b014957dde0b 100644 > --- a/drivers/lightnvm/pblk-rl.c > +++ b/drivers/lightnvm/pblk-rl.c > @@ -207,7 +207,7 @@ void pblk_rl_free(struct pblk_rl *rl) > del_timer(&rl->u_timer); > } > > -void pblk_rl_init(struct pblk_rl *rl, int budget) > +void pblk_rl_init(struct pblk_rl *rl, int budget, int threshold) > { > struct pblk *pblk =3D container_of(rl, struct pblk, rl); > struct nvm_tgt_dev *dev =3D pblk->dev; > @@ -217,7 +217,6 @@ void pblk_rl_init(struct pblk_rl *rl, int budget) > int sec_meta, blk_meta; > unsigned int rb_windows; > > - > /* Consider sectors used for metadata */ > sec_meta =3D (lm->smeta_sec + lm->emeta_sec[0]) * l_mg->nr_free_l= ines; > blk_meta =3D DIV_ROUND_UP(sec_meta, geo->clba); > @@ -234,7 +233,7 @@ void pblk_rl_init(struct pblk_rl *rl, int budget) > /* To start with, all buffer is available to user I/O writers */ > rl->rb_budget =3D budget; > rl->rb_user_max =3D budget; > - rl->rb_max_io =3D budget >> 1; > + rl->rb_max_io =3D threshold ? (budget - threshold) : (budget - 1)= ; > rl->rb_gc_max =3D 0; > rl->rb_state =3D PBLK_RL_HIGH; > > diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h > index 72ae8755764e..a6386d5acd73 100644 > --- a/drivers/lightnvm/pblk.h > +++ b/drivers/lightnvm/pblk.h > @@ -924,7 +924,7 @@ int pblk_gc_sysfs_force(struct pblk *pblk, int force)= ; > /* > * pblk rate limiter > */ > -void pblk_rl_init(struct pblk_rl *rl, int budget); > +void pblk_rl_init(struct pblk_rl *rl, int budget, int threshold); > void pblk_rl_free(struct pblk_rl *rl); > void pblk_rl_update_rates(struct pblk_rl *rl); > int pblk_rl_high_thrs(struct pblk_rl *rl); > -- > 2.17.1 >