From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D1C3C43334 for ; Wed, 6 Jul 2022 10:48:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B55B46B0071; Wed, 6 Jul 2022 06:48:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B05F36B0073; Wed, 6 Jul 2022 06:48:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CF226B0074; Wed, 6 Jul 2022 06:48:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9012F6B0071 for ; Wed, 6 Jul 2022 06:48:54 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0D76F2153A for ; Wed, 6 Jul 2022 10:48:54 +0000 (UTC) X-FDA: 79656352188.10.964DC51 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by imf29.hostedemail.com (Postfix) with ESMTP id 7A7A812004E for ; Wed, 6 Jul 2022 10:48:53 +0000 (UTC) Received: by mail-oi1-f177.google.com with SMTP id w83so19520501oiw.1 for ; Wed, 06 Jul 2022 03:48:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8ewXVGM5pcJQ/1oCIdyUacMELFTqjftWEiEU6+TD2I4=; b=l8LhmeiCFiIQ3zw/H8LykNHRNThsdFhVLrfaxCPsB48WNv2mB+g4AuO3iO20jnmlwc R+oxZROuokUbHCc2BLePYPnMvrLu6EC8Q48tGfz3XSEfDjC35EKw4mQr2r5EDKNymaei kCWEacGY69jEgdwjLxRH5xpaJ6d07wp9jaMTajWFouVDSoB26eaiBE3wYtiFMy98QZvx baF4+q7mBEtEHJ047EerVpeyhR/ElY9w6wphx3k+XzEPuiub6DJ8XFofYZwekSGTucrk d2Ujrjwpa9ZzHmfouHgaZUtqLtow3add7Dpp5Zi1c+htlLkJQYzAziLp/WxyXfgeqq4/ 8o0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8ewXVGM5pcJQ/1oCIdyUacMELFTqjftWEiEU6+TD2I4=; b=8NJ0DSZOvhdBuDHDDbYq7epLtndccrr7ZvaSuT+ADsQKjscWD4O6RJgVlt+UXvFSBR HHhFqW1AtxffP/0/bNNPZMy7OQcbmOgKqVqWH1Bpxh8oZmbeMqTpCK9K6LJ3pZJpj+dI aE9VHRed1Q840X4uwqXrSnS6pezacequjjKzg73rFU1e+hJTUEbRr6iGXloqHBUk3PTy 12tisJ6m99DlBLgObu0n0KTC6+6mEUoOnCc+z/OYQ2TtwCmq/hWSX82aPADiVN56AAsv h2V3rAcjRAju+nMZIa6uTUUKhhfC/57skEQVTrpMiUipxDhmrOFbgIzqOTODj2U7vg2y BMIg== X-Gm-Message-State: AJIora9fVjxTyD9meCjoP78GssuxQHkaG0E9Jtv+JqzKExZyt1NDCZ2q BHHvafu1Hy253fdmNPogCTI= X-Google-Smtp-Source: AGRyM1txiXE8vAwrRVxegQt6dZ6/JJJEtUcPyH6KnE3awClSZtN5U9+ofB/jQVtGMDlK4PBTitY+dA== X-Received: by 2002:a05:6808:1815:b0:337:9464:85d with SMTP id bh21-20020a056808181500b003379464085dmr14778873oib.203.1657104532606; Wed, 06 Jul 2022 03:48:52 -0700 (PDT) Received: from opensuse.localnet (host-79-53-109-127.retail.telecomitalia.it. [79.53.109.127]) by smtp.gmail.com with ESMTPSA id q10-20020a056830232a00b0060b1f3924c3sm17411265otg.44.2022.07.06.03.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 03:48:51 -0700 (PDT) From: "Fabio M. De Francesco" To: Ira Weiny Cc: David Sterba , Chris Mason , Josef Bacik , Nick Terrell , linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Matthew Wilcox , Kees Cook , Sebastian Andrzej Siewior , "James E. J. Bottomley" , Helge Deller , John David Anglin , linux-parisc@vger.kernel.org, Filipe Manana Subject: Re: [PATCH v5 2/2] btrfs: Replace kmap() with kmap_local_page() in zstd.c Date: Wed, 06 Jul 2022 12:48:46 +0200 Message-ID: <1826872.tdWV9SEqCh@opensuse> In-Reply-To: <2250236.ElGaqSPkdT@opensuse> References: <20220704152322.20955-1-fmdefrancesco@gmail.com> <2250236.ElGaqSPkdT@opensuse> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657104533; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8ewXVGM5pcJQ/1oCIdyUacMELFTqjftWEiEU6+TD2I4=; b=n/3Kn5eQdktCCSnpnCTRqWtQT4sXj45mglPCa8xKRvbqxT+uwIQpwCOGNqdhf6/9hvdwAs FXiJHQZeNyXYIbbvuCMV8d5UFVDllUk+fzC/h0HB33fJaRjl0lmolasooLPPaPCq2e86tp xcF6U71SQvOJni24RLtNQfTQIsms19g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657104533; a=rsa-sha256; cv=none; b=WIE8g3JCsC3D3GWrfAOrXz7mRlmNOcLbQgXVp8RbZ9ZKzkjihKC+9qJdmXnu2oFd1VBkCu IkONew9bRJKDb2Gx5v8/9TN3/FPzF2VXejxO41m9FAy0LYXOJFM8Dt9VLpyI+iYrsM6ozs rR1GwGG62WOTDfmLOlkEdcJ1xCuomtQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=l8LhmeiC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of fmdefrancesco@gmail.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=fmdefrancesco@gmail.com X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=l8LhmeiC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of fmdefrancesco@gmail.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=fmdefrancesco@gmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7A7A812004E X-Stat-Signature: wzasfakfi1q87hqzx9ppye9rry9isj3w X-HE-Tag: 1657104533-46239 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On mercoled=C3=AC 6 luglio 2022 12:38:29 CEST Fabio M. De Francesco wrote: > On marted=C3=AC 5 luglio 2022 21:04:04 CEST Ira Weiny wrote: > > On Mon, Jul 04, 2022 at 05:23:22PM +0200, Fabio M. De Francesco wrote: > > > The use of kmap() is being deprecated in favor of kmap_local_page().= =20 > With > > > kmap_local_page(), the mapping is per thread, CPU local and not=20 > globally > > > visible. > > >=20 > > > Therefore, use kmap_local_page() / kunmap_local() in zstd.c because=20 in=20 > this > > > file the mappings are per thread and are not visible in other=20 contexts.=20 > In > > > the meanwhile use plain page_address() on pages allocated with the=20 > GFP_NOFS > > > flag instead of calling kmap*() on them (since they are always=20 > allocated > > > from ZONE_NORMAL). > > >=20 > > > Tested with xfstests on QEMU + KVM 32 bits VM with 4GB of RAM and > > > booting a kernel with HIGHMEM64G enabled. > > >=20 > > > Cc: Filipe Manana > > > Suggested-by: Ira Weiny > > > Signed-off-by: Fabio M. De Francesco > > > --- > > > fs/btrfs/zstd.c | 34 ++++++++++++++-------------------- > > > 1 file changed, 14 insertions(+), 20 deletions(-) > > >=20 > > > diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c > > > index 0fe31a6f6e68..78e0272e770e 100644 > > > --- a/fs/btrfs/zstd.c > > > +++ b/fs/btrfs/zstd.c > > > @@ -403,7 +403,7 @@ int zstd_compress_pages(struct list_head *ws,=20 > struct address_space *mapping, > > > =20 > > > /* map in the first page of input data */ > > > in_page =3D find_get_page(mapping, start >> PAGE_SHIFT); > > > - workspace->in_buf.src =3D kmap(in_page); > > > + workspace->in_buf.src =3D kmap_local_page(in_page); > > > workspace->in_buf.pos =3D 0; > > > workspace->in_buf.size =3D min_t(size_t, len, PAGE_SIZE); > > > =20 > > > @@ -415,7 +415,7 @@ int zstd_compress_pages(struct list_head *ws,=20 > struct address_space *mapping, > > > goto out; > > > } > > > pages[nr_pages++] =3D out_page; > > > - workspace->out_buf.dst =3D kmap(out_page); > > > + workspace->out_buf.dst =3D page_address(out_page); > > > workspace->out_buf.pos =3D 0; > > > workspace->out_buf.size =3D min_t(size_t, max_out, PAGE_SIZE); > > > =20 > > > @@ -450,9 +450,7 @@ int zstd_compress_pages(struct list_head *ws,=20 > struct address_space *mapping, > > > if (workspace->out_buf.pos =3D=3D workspace->out_buf.size)=20 > { > > > tot_out +=3D PAGE_SIZE; > > > max_out -=3D PAGE_SIZE; > > > - kunmap(out_page); > > > if (nr_pages =3D=3D nr_dest_pages) { > > > - out_page =3D NULL; > > > ret =3D -E2BIG; > > > goto out; > > > } > > > @@ -462,7 +460,7 @@ int zstd_compress_pages(struct list_head *ws,=20 > struct address_space *mapping, > > > goto out; > > > } > > > pages[nr_pages++] =3D out_page; > > > - workspace->out_buf.dst =3D kmap(out_page); > > > + workspace->out_buf.dst =3D=20 > page_address(out_page); > > > workspace->out_buf.pos =3D 0; > > > workspace->out_buf.size =3D min_t(size_t,=20 > max_out, > > > =09 > PAGE_SIZE); > > > @@ -477,15 +475,15 @@ int zstd_compress_pages(struct list_head *ws,=20 > struct address_space *mapping, > > > /* Check if we need more input */ > > > if (workspace->in_buf.pos =3D=3D workspace->in_buf.size) { > > > tot_in +=3D PAGE_SIZE; > > > - kunmap(in_page); > > > + kunmap_local(workspace->in_buf.src); > > > put_page(in_page); > > > - > > > start +=3D PAGE_SIZE; > > > len -=3D PAGE_SIZE; > > > in_page =3D find_get_page(mapping, start >>=20 > PAGE_SHIFT); > > > - workspace->in_buf.src =3D kmap(in_page); > > > + workspace->in_buf.src =3D=20 > kmap_local_page(in_page); > > > workspace->in_buf.pos =3D 0; > > > workspace->in_buf.size =3D min_t(size_t, len,=20 > PAGE_SIZE); > > > + workspace->out_buf.dst =3D=20 > page_address(out_page); > >=20 > > Why is this needed? >=20 > Sorry. This initialization is not needed at all. > Probably made a mistake with copy-pasting snippets of code. >=20 > I'm going to send ASAP the fifth version of this series. "fifth" -> "sixth". >=20 > > The rest looks good, >=20 > Thanks, >=20 > Fabio >=20 > > Ira > >=20 > > [snip] > >=20 >=20 >=20 >=20 >=20