Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3518252ima; Mon, 4 Feb 2019 00:16:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IYixvAxifbYZlw6f2A5Q7M3dg8/5WH87YS4GelIDMt3Yr1eaRCubEXpwBAt7gIWwWzpsvd8 X-Received: by 2002:a63:2744:: with SMTP id n65mr12038009pgn.65.1549268179839; Mon, 04 Feb 2019 00:16:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549268179; cv=none; d=google.com; s=arc-20160816; b=HYOc1h2/3Af2bgFPFvcQPnuGcqzzsY6j0TZk2LeXwunVmJ8o4rL8Nd+TnMW90Yt6wj 4Oi4XwugFQhHaO0Sv9meKdgnmyBAslMcAsGFMtrqN0QpG/yc8l7hD+56LufDMX22qwkH r/dR6ONfBPIOpQCUp1+PGKPVzH9MZC1+KF6dw/1PSG06zVqqh/8I+RSCpyQpCx/hkq1F 9xF8M2N6kpNRKGIxhUcuXqDR97U9U4UTwjiEZdss2vPpI6YfYIvrDxDHPLZrCzAIY2ZL i5dbVTWEbyd/lka47N9KCuEPxh5/aupYjatTUIjXIMGqEifvUem35oliWv2bEPCQIyEv Ctwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:to:cc:in-reply-to:date:subject :mime-version:message-id:from:dkim-signature; bh=5eyM7QfCDVFlJmGpD8M7Hj09aS6UMjXYaF9KvLang+0=; b=aCcnnVsozSjQlIs5SvP2Vca0PmWoGhXdzLUVN7nSiVi6nTyu+P2YpX5Ig2Cr49O4In JPmLD+M01DpRAbIpvlm7cWrAhIZNtpGolDmDBkFCq1ksqCsLeUMDnR61ntjwnVLeE6iV cc0DiYqB9xpSGN2aTNEYIOLpAu8f69TMrwuQoDRxrPuPlWHHv7OZKSmrfWK/ZW9CYhuP 42exJOhT1OJ66COa+89OY+u+S2kGenDIWqhqajQcHufAHks3dwiGBgLNPa9+cbXlQ4st OYhO69yLWcx95Bdile5zCGIW8Az+XolQs3Flbsajik7BRG62JCgZLmG81beyrrhAdfLz 4/Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=cRvEnZy1; 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 2si15767061pfd.154.2019.02.04.00.16.03; Mon, 04 Feb 2019 00:16:19 -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=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=cRvEnZy1; 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 S1727964AbfBDIOP (ORCPT + 99 others); Mon, 4 Feb 2019 03:14:15 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:44693 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbfBDIOO (ORCPT ); Mon, 4 Feb 2019 03:14:14 -0500 Received: by mail-ed1-f67.google.com with SMTP id y56so10428524edd.11 for ; Mon, 04 Feb 2019 00:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=javigon-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=5eyM7QfCDVFlJmGpD8M7Hj09aS6UMjXYaF9KvLang+0=; b=cRvEnZy1QBcNokBANV8JA5sNfoqUDRPwv0dm98urFhnIcRAo9Rqcem2Rdj8TrRztOx /OBF/qj87MZ6dr572TxDK+NFejf51JIYQ9NlgPWSSUgx0N087wAlJjQY71RUA/xuYb90 As4pt88ZWhMc7vOrDaZ5d2GaTpu6o8KBvMuU3jh/IgzkZ4Cfz+EJaVLdE+JseXnjXorP vVW8iSwkJisp1pkAalmXYXpThQCgjjE71RIScZZo6TSudrLwUK5g7zlN0B8dqYqFW0k8 01M+bMqfOMxYfvPaqg68M5Bh/E52rZ6JNm6R3+Hjk2/qU27ZVcBIGrzYRAliA6/ihZ8l nvfQ== 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=5eyM7QfCDVFlJmGpD8M7Hj09aS6UMjXYaF9KvLang+0=; b=QaL4TzNf7OxJCckLHuAADoNYftt6aOo19BnIk8D8Ygws4Fbxl6T4QebeUCFWEMFAUs TfD3t0ZI2x229THXcclmU60H6OfLJygM3QbX3ExC7HcX+qWS4fIZ5HBCu3pRHfZ6Wrrq fhtB/YjYYaZGwlYP6gYnEpVnw8RurCYh0bNXwIk5VH0A+J2CIRiafjnuANtEALpbm+RU +DLovuG1u8JQGSLXMvZrYiPlFNh7Sgq9NlIW83dDEFVmiUwamO5Wo1ZnmEoavK69TcwU 0bWE9tVddGCJnEn4eecJMyUIXzMpAsLb+y62pUcpVM/Nvj85nxjvrGuoqPeWL5UB1haP bCLw== X-Gm-Message-State: AJcUukdO6925LL7wkQd7Ya2qTh6xm/N7pKtcfZxq3Glgsem6b0ZCoMXS 6AZ+LfAcjhxiQqNctlatgy/n3w== X-Received: by 2002:a17:906:a4cd:: with SMTP id cc13mr28661493ejb.121.1549268052163; Mon, 04 Feb 2019 00:14:12 -0800 (PST) Received: from [192.168.1.85] (ip-5-186-122-168.cgn.fibianet.dk. [5.186.122.168]) by smtp.gmail.com with ESMTPSA id i46sm4062621eda.37.2019.02.04.00.14.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Feb 2019 00:14:11 -0800 (PST) From: =?utf-8?Q?Javier_Gonz=C3=A1lez?= Message-Id: <3E3CC5BE-585A-4F0A-8EC7-7FE5F855E888@javigon.com> Content-Type: multipart/signed; boundary="Apple-Mail=_3C636952-BFDB-4A27-8C39-EF94106AC829"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH V2] lightnvm: pblk: prevent stall due to wb threshold Date: Mon, 4 Feb 2019 09:14:10 +0100 In-Reply-To: Cc: =?utf-8?Q?Matias_Bj=C3=B8rling?= , Hans Holmberg , linux-block@vger.kernel.org, Linux Kernel Mailing List To: Hans Holmberg References: <20190130102604.14496-1-javier@javigon.com> X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Apple-Mail=_3C636952-BFDB-4A27-8C39-EF94106AC829 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 31 Jan 2019, at 21.10, Hans Holmberg wrote: >=20 > On Thu, Jan 31, 2019 at 5:33 PM Javier Gonz=C3=A1lez = wrote: >>> On 31 Jan 2019, at 11.41, Hans Holmberg wrote: >>>=20 >>> Hi Javier! >>>=20 >>> How did you test this? I'm trying to add a test case to our testing = framework. >>>=20 >>> This is what i ran in qemu, and I got a hang (with this version of = the patch) >>>=20 >>> nvme lnvm create -d nvme0n1 -t pblk -n pblk0 -f -b 0 -e 0 >>=20 >> I run several low configurations without problem. Can you share the = qemu configuration and version? >=20 > Of course! >=20 > qemu remote: https://github.com/CNEX-Labs/qemu-nvme.git > branch: master (cb200e3ccf9c1ff21f6275c6cb68b2801135a640) >=20 > 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. 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 = that 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 = size, 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 = size, unsigned int threshold, * Initialize rate-limiter, which controls access to the write = buffer * 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_lines; 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 --Apple-Mail=_3C636952-BFDB-4A27-8C39-EF94106AC829 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEU1dMZpvMIkj0jATvPEYBfS0leOAFAlxX9FIACgkQPEYBfS0l eOBo6BAAtCOpOkZMt5ie2vRW+w8MKCE3BKQXAQZXFR/6p5dFc5c6ztOkSKL553kg lBW/VpIdtqA8ZuJHW5TajN2ICqL3Y/9/269YfMzq/vQrivnBt8LAesrMzKYbkWxi L+quEopcuDMywfIIPq03QZmykz7CZdlQGnx31QC4B8rICSron5X758XjAhNrFP/w OZfoJLmZ/JowDkiBFnzCEqXE0zzVEk4uUo09ZgWb554APUS2vlVlvFaPjZ2uxgAF C6wAGhZAXEBjOb4YaAL+FUuEL9fx5AGew6qAGqU2CdPQKwWrh1ccW1wsVr5kAFJY t2eCKabZ3pBLsu6p1uPlBcww7iXz1e7z2pZOJE0/7JW3mypJiySEZRFSOgMQrwjV 8z2HDOzhHn9aBIBf9BJZhbUhl4NqHqnMWh3gl1++CKnLJabkEwSFKpzgk4k8aVsV StuGm/kPgdTT1Kb+yaLTgma8KQU0OOiO2ZcSzxUeNEhkZVt+R+pS8JeCEi1oZn0F HppsfmLbdZmseUNqFsRch2rNKAJRaPLo5n+IDJXuKIjNE5oVX4yt+/rMy85SzCjU 2RJX+hzNW8I+Pqx4yH2DtQ8M9zqYbIo0ZtrMBVmfweQZiS0qsvKAi6/zk+8jZ+gO BxkMXtDHmtQ1BzLiqDJeX6HoZf4W2KznT9j9fURkdLJIP7Jlbr0= =RPX4 -----END PGP SIGNATURE----- --Apple-Mail=_3C636952-BFDB-4A27-8C39-EF94106AC829--