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 91C4BCCA473 for ; Wed, 6 Jul 2022 10:38:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C14FE6B0071; Wed, 6 Jul 2022 06:38:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC56F6B0073; Wed, 6 Jul 2022 06:38:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8C8B6B0074; Wed, 6 Jul 2022 06:38:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9958B6B0071 for ; Wed, 6 Jul 2022 06:38:36 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 60CE081248 for ; Wed, 6 Jul 2022 10:38:36 +0000 (UTC) X-FDA: 79656326232.30.AC0C8C9 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by imf07.hostedemail.com (Postfix) with ESMTP id B650D40016 for ; Wed, 6 Jul 2022 10:38:35 +0000 (UTC) Received: by mail-wm1-f41.google.com with SMTP id l40-20020a05600c1d2800b003a18adff308so9067499wms.5 for ; Wed, 06 Jul 2022 03:38:35 -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=YU7/aTVmwMw1xiBrffIxn8qMUTw+gm+umroriH5I92o=; b=ghSozxp8QV21TAro3RolO4UMKa+ccDr5PJ59lVX3tlVeCT7KTpO1FEbFAWdQL9A9Q/ Vulcqud9QeYF5LlhpGGu5zFNVp7E0Pw1H5AKFUDG2J0sEw8BNJTPrOLa23xwxFGdYjKf If5VMtxoBF9DKYqHHkC2gisg2D1nGqpEv3ZjaQf+aDUmlgQG8PyPmHQ+p87NZ5pL+DU2 tsWjcMEmSKV+k8rV0ibunpSkVo4CpOltRtd0xY3hltVRq/6bETrZpMViQfqwdm2LZJvt ozlHQfX4HjQlurVfc5cKdfTFBC0fE5p4WvIIqSK2UZfiEAdpOcjGjgmTgMXFZg9Ud90k DzNg== 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=YU7/aTVmwMw1xiBrffIxn8qMUTw+gm+umroriH5I92o=; b=JVv0ONEFCxtNvBOEhFO3h6nhRjS3c/Gjgg8+zq8Xm7uMiwiJA/0d1uIMI8E6Qa3Nta MD6ofAPylrc1FrQDRsg1BKe6g/31y1se6JugYcJ87C91DpiHPAsuMWqp7oYYkbLMDDrL D5w9C0wchRay8B/D4l/b7xMLvz3rWADujQ4U9uF58ThgQvem23iY6JAdNfRs+c8r436G vbFGH9WbrVOhalQ46oqdwbx3M0jdrXSB/jxgOAOmnEmFtFCGW+w6kV66rzH9i00hdd1P GIaOMlfOWcZoeoFdeY5wlQ8/UPfFQ3wz4iETLhwLyXyR3jJRkoe8G4rtx/eum4mJB3iw 1w0g== X-Gm-Message-State: AJIora/ZhNc26w/eyIoHQruamRkFKWax/BreFtHpzlbm+YmFutNIoY+f 7nt+ksNeMExT4fCssUEaDwI= X-Google-Smtp-Source: AGRyM1t7dpxKdmG7n71wWdoedPFPmkmnYg17fxZqQSno2zFUho02OLAK4wpsuebRyha/rsbvmeEh0Q== X-Received: by 2002:a7b:c4cb:0:b0:3a2:b45a:e344 with SMTP id g11-20020a7bc4cb000000b003a2b45ae344mr12785004wmk.157.1657103914353; Wed, 06 Jul 2022 03:38:34 -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 g1-20020adffc81000000b00213ba3384aesm36323831wrr.35.2022.07.06.03.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 03:38:32 -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:38:29 +0200 Message-ID: <2250236.ElGaqSPkdT@opensuse> In-Reply-To: References: <20220704152322.20955-1-fmdefrancesco@gmail.com> <20220704152322.20955-3-fmdefrancesco@gmail.com> 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=1657103915; 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=YU7/aTVmwMw1xiBrffIxn8qMUTw+gm+umroriH5I92o=; b=0CsI093FmxuWFbHCB310on1Ri4BvM8SfPuoFlcx9PxltxMtImdJSmlO7Y+i08ZOoeZ9YQs kBUyd9EndkRz5YPAKtGhb1T8R5IrCMZUJr1w3bdnN+K5QpzVDolcoC77dx8C6sLYeHSANW vAvp5XspQuTPlLUAI4uu3d+R5Z1kgyI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657103915; a=rsa-sha256; cv=none; b=k11ieGyDBzBCwrOQOZYwAV1XPyjxTqMI1LhZDGrkYqZu9BmCgltwa4MHOyd5ahuA5TCFPc wSMMERP8S3s4nHeWNMRfUhLqDbzaC3BlZKIkVBLtsQI5wVdoHujwJDIj2MogeJGOYK7f++ witrtAtmslIPs+TF967Mncv/iLZwv6A= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ghSozxp8; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of fmdefrancesco@gmail.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=fmdefrancesco@gmail.com X-Stat-Signature: nomqismbfid4cpjgks63yy4qf1n46kah X-Rspamd-Queue-Id: B650D40016 X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ghSozxp8; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of fmdefrancesco@gmail.com designates 209.85.128.41 as permitted sender) smtp.mailfrom=fmdefrancesco@gmail.com X-Rspamd-Server: rspam10 X-HE-Tag: 1657103915-901577 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 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 in= =20 this > > file the mappings are per thread and are not visible in other 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? Sorry. This initialization is not needed at all. Probably made a mistake with copy-pasting snippets of code. I'm going to send ASAP the fifth version of this series. > The rest looks good, Thanks, =46abio > Ira >=20 > [snip] >=20