Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp255832imu; Fri, 25 Jan 2019 01:37:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN4DOU6J4htE1xTLhALF2mcIDmaVBjp9eqowIOlxiUthDU9iycPExSO1EKl0QsYIYkba/HG+ X-Received: by 2002:a62:1c86:: with SMTP id c128mr10630274pfc.54.1548409074126; Fri, 25 Jan 2019 01:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548409074; cv=none; d=google.com; s=arc-20160816; b=rmekDO9pVvk8KqIjEcvqsOafqi5TOCbG+A29W0vTBj9BpeYizkKDQFt9NuZ5gqNBaJ j/MrlokUfkenEy4UPxHPSMns+nE3N4ZQuc+BXz/BHXXyv8TtETEzkNVgFJw273gno0+V lvDLK6fcnSQam4PyzlENNGt1i/+6uLGtAWsQJ9l6xcFpAZfYh0BBY8dSk5ESwW04TY6E wQzz5kNIW5P2OMfnedguVNmnMumQ4pojPRBAyqq2CbPMBVDgCePbbRFJlVOklEFwA8hQ RvryVrxCHvMTjOMsxV0xAYqDZx3h9sPVWlebs8vq1ReXAaCAULzI/2Ktnv0dJh4pfUd/ tPvg== 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=U7xWct8fpo5uF4inpPT83b7tyag62f+IlDnqulmlW28=; b=qtLiNVX6T+MUMdObGx6flbkbtDdQZlzA4ZlhSJB0fxdngI6ebvyfcZ8/qPSA+qd/qY NNT5hJqbLWo9AbZjCJbqvDQa7hj8Lu5Z/J7mqNbYmBpPdPgAMGHQXm3eJUTsDey/M/KW ugZ5eZd1MP49SIIZ2RuzTqv8vV6F52l0B4DKa0jSv7ZreKwXYAeEivkxnsGnFebZ8+6T M0nKX7lwxrVcvBamX9PeMASMy47le8eC4VKxZSNJOYBopDe+OscrMCbPwcaaNFZ9WJxb LFt6YtVDyaT0JpG3JSiTdgo+E7lh7lPgcMJrIX+TtpLfczW4wTZp1zOq+GqOS/AZvmLy MxWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@javigon-com.20150623.gappssmtp.com header.s=20150623 header.b=wDe5kDHT; 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 q189si20547672pfb.62.2019.01.25.01.37.38; Fri, 25 Jan 2019 01:37:54 -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=wDe5kDHT; 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 S1728648AbfAYJhS (ORCPT + 99 others); Fri, 25 Jan 2019 04:37:18 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46245 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbfAYJhS (ORCPT ); Fri, 25 Jan 2019 04:37:18 -0500 Received: by mail-ed1-f66.google.com with SMTP id o10so6818358edt.13 for ; Fri, 25 Jan 2019 01:37:16 -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=U7xWct8fpo5uF4inpPT83b7tyag62f+IlDnqulmlW28=; b=wDe5kDHT96ZRkEpQgeZv15Lq8/P4s1cKVJPH4eufmLrNh/i5ed8+HJ3iWukx6deoUy OZjEnkSZyvKoTBt0NZfwNy9CwhRG/Y7LddteXDHuQGvVytyreEmNUhslw+IWapazAEQP QPK0adhTvxOa7XhOYxhsaqIn7ypsPTEYI0+jgaRTdQFQCnD4Oh2hEF5poOqsLg2exOc9 S+XtlmNJr2NYQ4RVFyHG+1UQp1RY8WRjtSDpGzAMqLgj1Duh4K7sLR4RevMTgFU4iIfb giVByJtTLADcJ3es7Gfy8/wba3k7iQaQ6kU7w7foXE6Y05RE1rpkg64nrNF1RlB6VWSq ZNbg== 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=U7xWct8fpo5uF4inpPT83b7tyag62f+IlDnqulmlW28=; b=RsP4Os+w6W7OKcfTEzHOc7qtO3lsiBx33I6r4EyfZk9EUgkfRLZz0Ip98UQ4jqEJIH 29AFs7dvhzdHSYdFviHYdxOwAvWihM1VG+hRAVEtTOjg3PybLTIH4k0sXPjiScCAmHTL t9Dx6F/z8uGpkyM+WBWZIV0alui8t0OOPesc8l0sMMaNQGqsQ81AUj34yd16dhiMZ8/S XLDwMq55G1pvgne5tZXPNjj2oXEDwBwdNJD2o5jqiylfkYXlu+LETaSvk1q2oLUjQ6cy AdIBucK5fAgK4pdOECqEzZkXvumlA4t+4v+FFXyAA76gmLxnMsdDCtra+3O8SyGsjjvC Guqg== X-Gm-Message-State: AJcUukccFerTtjrJl8iT6IsYZI7QmsQL5DeLMhHSQK65DqOsGVKIksF7 QQ6K49kcs0l846eI061Y/xNWGloleIZsjw== X-Received: by 2002:a50:95b4:: with SMTP id w49mr9890358eda.186.1548409036128; Fri, 25 Jan 2019 01:37:16 -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 b45sm11629157eda.34.2019.01.25.01.37.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jan 2019 01:37:15 -0800 (PST) From: =?utf-8?Q?Javier_Gonz=C3=A1lez?= Message-Id: <7BAC034D-8992-41E4-87A9-378813C821F7@javigon.com> Content-Type: multipart/signed; boundary="Apple-Mail=_025C617B-44BF-449F-A530-B3644883D9D7"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH] lightnvm: pblk: stop taking the free lock in in pblk_lines_free Date: Fri, 25 Jan 2019 10:37:14 +0100 In-Reply-To: Cc: =?utf-8?Q?Matias_Bj=C3=B8rling?= , linux-block@vger.kernel.org, Linux Kernel Mailing List , Hans Holmberg To: Hans Holmberg References: <20190122101531.30893-1-hans@owltronix.com> <251D7CB9-A9B0-4474-85A0-B0C23DB31272@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=_025C617B-44BF-449F-A530-B3644883D9D7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 25 Jan 2019, at 10.15, Hans Holmberg = wrote: >=20 > On Thu, Jan 24, 2019 at 2:19 PM Javier Gonz=C3=A1lez = wrote: >>> On 22 Jan 2019, at 11.15, hans@owltronix.com wrote: >>>=20 >>> From: Hans Holmberg >>>=20 >>> pblk_line_meta_free might sleep (it can end up calling vfree, = depending >>> on how we allocate lba lists), and this can lead to a BUG() >>> if we wake up on a different cpu and release the lock. >>>=20 >>> As there is no point of grabbing the free lock when pblk has shut = down, >>> remove the lock. >>>=20 >>> Signed-off-by: Hans Holmberg >>> --- >>> drivers/lightnvm/pblk-init.c | 2 -- >>> 1 file changed, 2 deletions(-) >>>=20 >>> diff --git a/drivers/lightnvm/pblk-init.c = b/drivers/lightnvm/pblk-init.c >>> index f9a3e47b6a93..eb0135c77805 100644 >>> --- a/drivers/lightnvm/pblk-init.c >>> +++ b/drivers/lightnvm/pblk-init.c >>> @@ -584,14 +584,12 @@ static void pblk_lines_free(struct pblk *pblk) >>> struct pblk_line *line; >>> int i; >>>=20 >>> - spin_lock(&l_mg->free_lock); >>> for (i =3D 0; i < l_mg->nr_lines; i++) { >>> line =3D &pblk->lines[i]; >>>=20 >>> pblk_line_free(line); >>> pblk_line_meta_free(l_mg, line); >>> } >>> - spin_unlock(&l_mg->free_lock); >>>=20 >>> pblk_line_mg_free(pblk); >>>=20 >>> -- >>> 2.17.1 >>=20 >> Can you add a comment too indicating that this is only safe on a = single >> threaded shutdown? >=20 > To be able to free the lines, we need have stopped anything accessing > the lines first. That seems obvious to me. >=20 The reason I mention this is that there is assumptions on the shutdown logic that the line freeup will be single threaded - you can see that we do not lock pblk_line_mg_free() either, for the same reason as you are removing this lock. We can do this is only because we have a single open line at the time (which in close down we fill up in parallel to speed up the process BTW). If we have more open lines, it would be desirable to close them in parallel. At this point we either have a sync point when they are all closed and then free, or we allow them to free themselves. In the second case, locking will be necessary. IMHO, a comment does not hurt. > It would be nice to make a pass over the code and document pblk's > locking(and other concurrency handling, like the line krefs) though. >=20 True that - krefs specially would deserve some documentation. Let me see if I can allocate some time the following weeks to write up some documentation. > Thanks, > Hans >=20 >> Otherwise the patch looks good. >>=20 >> Reviewed-by: Javier Gonz=C3=A1lez --Apple-Mail=_025C617B-44BF-449F-A530-B3644883D9D7 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----- iQIzBAEBCgAdFiEEU1dMZpvMIkj0jATvPEYBfS0leOAFAlxK2MoACgkQPEYBfS0l eODJCA/7BPpAYB3Rmziu5rEtnitaNWmUSiZ2AZ5yHzVq7JmDXMmMqkOa1eXeoJu7 HjXC3wHDcWUoBxAGxwFIUvo36+6o4h5qh2bj+RI/vt2jMP7tbBXQ5Vd6AlAGhnl+ iTfjPf/iuB0VHpL3ViWCpf4rcgvSdk2Qi222INq2YAA9s0hihNsRiRM2SNai6UsD aSQsuz+fBOrWJzeYFwe7L8Ui67+eU80Su4f25YB4QXuvTP0Yal6S19RmxMWP51tc 5I3lyL4kVFjV6riWU7TiNrG98BKQt/pqPxQaBzgpnbuGgCtBJnY+IituwH7VKidF YftswdrvqwXeouxnvM2EaCWWnLcI+B9XB5nSwtLWbaMlbyv9WYm5J/ZOPXUMF/8b bXLsh3UDudB/3tkJJYOnwJg0i4UyMli+UX93MFJdiCKyBl5+jDvK6bk04vO0G1tM VNMkUY4BYZeCFTEXABXVyiIz9j1cobe0T05/LSqoz5HxmZTHr3CcjStx6/GimYxr 7fSdUD+nQecjmknjL/6WU4Al8jNuDkhgOrLcOiYnrvK3XchD2HGkXjpEpbhWR5gt U22vjoEvT/KZzOw3y6tofYe/wHNiUmnY4RS4UwGh7WQvLDovbIxPn4RD26jab4XV zQokB58h3ywvASzZ9+eNgKxOXKMS+VHXrU71kkkNXWByjsq3ACg= =eU8s -----END PGP SIGNATURE----- --Apple-Mail=_025C617B-44BF-449F-A530-B3644883D9D7--