Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp406349iog; Fri, 17 Jun 2022 05:56:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u4k/fqLk/5vKutBdbIS51XOgE1WhRqcJEEIp16U1mtLY3x0kBMjeBbOAbKahp3Wmc97/JR X-Received: by 2002:a05:6402:120b:b0:42f:aa44:4d85 with SMTP id c11-20020a056402120b00b0042faa444d85mr12434645edw.338.1655470617598; Fri, 17 Jun 2022 05:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655470617; cv=none; d=google.com; s=arc-20160816; b=XZtMmI6kkLwWX8E2QT8cDdXF1inSYDE1RlcXECd+SBci8VWLBtLNN2XxdMLMH5xRxh UCCBp6q/vT90723r6+UhzY5TQq7iXbHPTnMWENaIifGb9IUTUTha6tt64e8e9cawFThD ZQm3ixZGKxkIwEUIGCh15PR/Psdz1Owvb2FfxUGMVvJjMgIFHK30PnyqjPIxq2rtSLvr Sg1aaRkWhPJpyVS9EbXSLFHnnSjoSaZSijseF+vmk9BmxdfxtBftwW79aM5rZzqBtk1D 5NWr/Bcsii1Q0PHBfb4BUQPKX7RhomREo9iL20cYP13n/5LoIWinbqpd1KZPYmBFiLGc i2zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=gd3f0eeaJk8NrdeWHM249JrsOLN735RUjQ1TBhcnB5s=; b=Rhu4bbE4glZLxpO9SSZ6uq5Bh3WkgTR7nN2FwKeH+8FKW2doFYH4K0uBb29vrbzHKN eIC9tNSueq6ocrgYh/NuQkw6tE9xGdRW4ar91vQ+TJ1D+0WA44gmAwN7Y4eucHNmxYwf rhnLsG+mqUahasAMBC+x387eLY6MN1ECkEmnlmBXwKWkcF+Vx47CdeZMVLdMfvYQY0qu iVs/frXERpYluIggYFyd2mAC5QgejtXFakSbEdfXAxN1/22rrkecjfyTWFzyAYqyLeN8 cKqFFo2yaDddHdtZoj7DERxI5NEWiuGbqQORgDG3sP/mD6wzZ1h+e5Z2Qct1yf+BSjai OpAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=BuAdKOOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs32-20020a1709072d2000b0070950fa092fsi4988070ejc.290.2022.06.17.05.56.30; Fri, 17 Jun 2022 05:56:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=BuAdKOOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236721AbiFQMvd (ORCPT + 99 others); Fri, 17 Jun 2022 08:51:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236636AbiFQMva (ORCPT ); Fri, 17 Jun 2022 08:51:30 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB96538780; Fri, 17 Jun 2022 05:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655470272; bh=5htkplcF4F9jY0hICWYsBVaqM9r4Ph8IdK4+8iBQrkc=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=BuAdKOOPAUvGIhcMHeDrfa7p9qO5ZdWidICK71LGRCOE7p/0O2CrvqCeSPIBy7FMm kghLz6Gmk1QMxcotmyi9gk7KunY9AhUFnk71J5f+lKQVBInBL1Y+Jj+WdqoGm7rotA 4XjmcILBW/mFHFRPwSoHZ3Pv9MDGd9Z9eRxRbe2M= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1N8XPn-1ngTfl07v7-014QWl; Fri, 17 Jun 2022 14:51:12 +0200 Message-ID: Date: Fri, 17 Jun 2022 20:51:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [RFC PATCH v2 1/3] btrfs: Convert zlib_decompress_bio() to use kmap_local_page() Content-Language: en-US To: "Fabio M. De Francesco" , Chris Mason , Josef Bacik , David Sterba , Nick Terrell , Chris Down , Filipe Manana , Qu Wenruo , Nikolay Borisov , Gabriel Niebler , Ira Weiny , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220617120538.18091-1-fmdefrancesco@gmail.com> <20220617120538.18091-2-fmdefrancesco@gmail.com> From: Qu Wenruo In-Reply-To: <20220617120538.18091-2-fmdefrancesco@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:SLOy9b2EodUCeXP6dSzjSCbswIltA/we9/OUbDG4cllVXWtQSNm t5H5aDxD8m+HCHKWYkPwtkLOj0R3bsW+MDm/1JyxS4NtftvugN8Ob+ld9pfg26ScfPlR3Aj U5YwndNpYmqBUqSofqkHzelAJBB2Tllqd2ICz8B4VDKWGL8I7hMsf4Ibd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oGluwLImSksIKFcFpPrNtXq0Kw0JIvhfO0alxRI75PEPL HNXLXCDloUrzsqX4pzR3wh82dRPr9QD2jO8I0WWmnM2Ue4WbLHi4LV5xcq+NgW+VUr76woBR6 vSZrdZ5D38o1D1OjCNGPhGKdFibWSpLHhzxi0QnegIRJmc/GgTK1WZPLQ== X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/6/17 20:05, Fabio M. De Francesco wrote: > The use of kmap() is being deprecated in favor of kmap_local_page(). Wit= h > kmap_local_page(), the mapping is per thread, CPU local and not globally > visible. > > Therefore, use kmap_local_page() / kunmap_local() in zlib_decompress_bio= () > because in this function the mappings are per thread and are not visible > in other contexts. > > Tested with xfstests on QEMU + KVM 32 bits VM with 4GB of RAM and > HIGHMEM64G enabled. This patch passes 26/26 tests of group "compress". > > Suggested-by: Ira Weiny > Signed-off-by: Fabio M. De Francesco Reviewed-by: Qu Wenruo Thanks, Qu > --- > fs/btrfs/zlib.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c > index 767a0c6c9694..770c4c6bbaef 100644 > --- a/fs/btrfs/zlib.c > +++ b/fs/btrfs/zlib.c > @@ -287,7 +287,7 @@ int zlib_decompress_bio(struct list_head *ws, struct= compressed_bio *cb) > unsigned long buf_start; > struct page **pages_in =3D cb->compressed_pages; > > - data_in =3D kmap(pages_in[page_in_index]); > + data_in =3D kmap_local_page(pages_in[page_in_index]); > workspace->strm.next_in =3D data_in; > workspace->strm.avail_in =3D min_t(size_t, srclen, PAGE_SIZE); > workspace->strm.total_in =3D 0; > @@ -309,7 +309,7 @@ int zlib_decompress_bio(struct list_head *ws, struct= compressed_bio *cb) > > if (Z_OK !=3D zlib_inflateInit2(&workspace->strm, wbits)) { > pr_warn("BTRFS: inflateInit failed\n"); > - kunmap(pages_in[page_in_index]); > + kunmap_local(data_in); > return -EIO; > } > while (workspace->strm.total_in < srclen) { > @@ -336,13 +336,13 @@ int zlib_decompress_bio(struct list_head *ws, stru= ct compressed_bio *cb) > > if (workspace->strm.avail_in =3D=3D 0) { > unsigned long tmp; > - kunmap(pages_in[page_in_index]); > + kunmap_local(data_in); > page_in_index++; > if (page_in_index >=3D total_pages_in) { > data_in =3D NULL; > break; > } > - data_in =3D kmap(pages_in[page_in_index]); > + data_in =3D kmap_local_page(pages_in[page_in_index]); > workspace->strm.next_in =3D data_in; > tmp =3D srclen - workspace->strm.total_in; > workspace->strm.avail_in =3D min(tmp, PAGE_SIZE); > @@ -355,7 +355,7 @@ int zlib_decompress_bio(struct list_head *ws, struct= compressed_bio *cb) > done: > zlib_inflateEnd(&workspace->strm); > if (data_in) > - kunmap(pages_in[page_in_index]); > + kunmap_local(data_in); > if (!ret) > zero_fill_bio(cb->orig_bio); > return ret;