Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp444005iog; Fri, 17 Jun 2022 06:36:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sVZgmc8OQwd76LcUtw1CjhyNCOB8R19wRnPJoeHDrDlKLjbvn4chf3oVkx2Qsa2Ho9BKOZ X-Received: by 2002:a17:90a:b290:b0:1ea:4358:27b3 with SMTP id c16-20020a17090ab29000b001ea435827b3mr10838533pjr.72.1655472979926; Fri, 17 Jun 2022 06:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655472979; cv=none; d=google.com; s=arc-20160816; b=T++n0QmWPAVoxoGVC2XPBQYoHhDsEaFSbwWygeYXfpJUP6HRt+kyMZeWMwgg5R3sz7 ipKy5tMGMYVocGsbavukm9jfHF33oxxNA5wVHuXGHO3faRa3USiJPecKPD5p4B04bow5 A3m3VdTtk/t/g+gk7pTdBuJqwgC34ceMBb5BjAKwD+isGx5ijlx98b3j+JpT70RWkwln Kpfe49fVwRZA/VOGa8vBfFm0Xx62a3ZtQnqqjTQzQhE2QbLBEmLFj3CTukEOUdy+mQ1z tLzlXev1coDr3ZLtkIN7Tj5Endy73dfV/AKVZj2GYggsNbWcGKmqT8Yx/R0Va0uWqmBP C7zg== 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=Pp5Qjjd+SwrFusfAliSkKxBkdUuUoNwrRMLtTRafRAY=; b=OfJPuGAjufuVHyanI9kb/Q4e/+Xr+V29EXv42zmvND/7dO0pae/9eKatxGHP/8Wqmt X/S0DVRO0c0GKTJmrbVAvh1jXfbd0N/Vfc2z3be7+089nKfTQhQ4xxXN7unhlBQAxIxg pJIDZWGNvyz7ZCLQxmYNAnPuVmYYdq1otN7fK6jGyQXluid78oFa8TLHhh8LJ+HDsK+9 omPZDVfYCUdfIOaUf+WYKxJoeQZsjCuQUPUOdti3L7Ndi2RoVz4DGGusStqnkJC4THZJ veFhHcsIekFDdyEeV5mymc1dcRJTm2hFV8mt3pOHCc2FjgZihH/KFIlq/5GLBDvY7+XG jeVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=LPKiV8jq; 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 q6-20020a056a00150600b005183434ec7csi6759054pfu.363.2022.06.17.06.36.06; Fri, 17 Jun 2022 06:36:19 -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=LPKiV8jq; 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 S235578AbiFQMzY (ORCPT + 99 others); Fri, 17 Jun 2022 08:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235059AbiFQMzX (ORCPT ); Fri, 17 Jun 2022 08:55:23 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F44947AEF; Fri, 17 Jun 2022 05:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655470470; bh=7BRS71ChBYD2L3k3PQnuQ5OPSIws9+M6hVpBWNCF9NA=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=LPKiV8jqgex+Kp1pCq00lax0YPnktqjyCYafAxCkTZODYpVr6y3cZdPHOUX70uI66 jOaYC2o1mDvMRU+RCxY6ROcj6mFBPThbiI4Y65ezB83HDwjpiU96bKgHcerB29sJki hHm1+aLaUj9t3Ot53gt7Y8rxcWKf8Ygy16ThvjJ4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MaJ81-1oERSi23d7-00WHXE; Fri, 17 Jun 2022 14:54:30 +0200 Message-ID: Date: Fri, 17 Jun 2022 20:54:22 +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 2/3] btrfs: Use kmap_local_page() on "out_page" in zlib_compress_pages() 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-3-fmdefrancesco@gmail.com> From: Qu Wenruo In-Reply-To: <20220617120538.18091-3-fmdefrancesco@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:n28pe/lUHFb3Mo/rGFJtqZSf/V+dwsTSqM3Hh3ZhnaOaUGH17K/ aFxLySOOCecER0tQObg4hedp13/wW5ay5yzfLZFx5/1sMpgHcTIY0CjIYHKg3Bfl9Evy7/V GCkWbHsrPr7rMj8J3tPTt/Atum0m61Pzimvji+LMuhzo1G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lrphDef7mNKn2feou5Uhdjdgjhbn8KKYPOzI7nHp4ZLA1r68QNS7W6kSBhxZS IZb6sBfUF0vrkLVf07O6BMwxoNuwzuFP6OUWi9NcnF/py5HOE5nCNECZJeui9sM0BmjuaoLPC xiLhId+rzJ9r2pLff7JkHNto4VQ3qfnetQKe4HK3upxm7CpUrGyEnbsyg== 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() for "out_page" in > zlib_compress_pages() because in this function the mappings are per thre= ad > 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 Looks good to me. Reviewed-by: Qu Wenruo The change is just to use @cpage_out to indicate if it's mapped (NULL =3D not mapped). Just a small nit inlined below. > --- > fs/btrfs/zlib.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) > > diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c > index 770c4c6bbaef..c7c69ce4a1a9 100644 > --- a/fs/btrfs/zlib.c > +++ b/fs/btrfs/zlib.c > @@ -97,8 +97,8 @@ int zlib_compress_pages(struct list_head *ws, struct a= ddress_space *mapping, > { > struct workspace *workspace =3D list_entry(ws, struct workspace, list= ); > int ret; > - char *data_in; > - char *cpage_out; > + char *data_in =3D NULL; I didn't see any diff touching @data_in, any idea why it's initialized to NULL? Thanks, Qu > + char *cpage_out =3D NULL; > int nr_pages =3D 0; > struct page *in_page =3D NULL; > struct page *out_page =3D NULL; > @@ -126,7 +126,7 @@ int zlib_compress_pages(struct list_head *ws, struct= address_space *mapping, > ret =3D -ENOMEM; > goto out; > } > - cpage_out =3D kmap(out_page); > + cpage_out =3D kmap_local_page(out_page); > pages[0] =3D out_page; > nr_pages =3D 1; > > @@ -196,7 +196,8 @@ int zlib_compress_pages(struct list_head *ws, struct= address_space *mapping, > * the stream end if required > */ > if (workspace->strm.avail_out =3D=3D 0) { > - kunmap(out_page); > + kunmap_local(cpage_out); > + cpage_out =3D NULL; > if (nr_pages =3D=3D nr_dest_pages) { > out_page =3D NULL; > ret =3D -E2BIG; > @@ -207,7 +208,7 @@ int zlib_compress_pages(struct list_head *ws, struct= address_space *mapping, > ret =3D -ENOMEM; > goto out; > } > - cpage_out =3D kmap(out_page); > + cpage_out =3D kmap_local_page(out_page); > pages[nr_pages] =3D out_page; > nr_pages++; > workspace->strm.avail_out =3D PAGE_SIZE; > @@ -234,7 +235,8 @@ int zlib_compress_pages(struct list_head *ws, struct= address_space *mapping, > goto out; > } else if (workspace->strm.avail_out =3D=3D 0) { > /* get another page for the stream end */ > - kunmap(out_page); > + kunmap_local(cpage_out); > + cpage_out =3D NULL; > if (nr_pages =3D=3D nr_dest_pages) { > out_page =3D NULL; > ret =3D -E2BIG; > @@ -245,7 +247,7 @@ int zlib_compress_pages(struct list_head *ws, struct= address_space *mapping, > ret =3D -ENOMEM; > goto out; > } > - cpage_out =3D kmap(out_page); > + cpage_out =3D kmap_local_page(out_page); > pages[nr_pages] =3D out_page; > nr_pages++; > workspace->strm.avail_out =3D PAGE_SIZE; > @@ -264,8 +266,8 @@ int zlib_compress_pages(struct list_head *ws, struct= address_space *mapping, > *total_in =3D workspace->strm.total_in; > out: > *out_pages =3D nr_pages; > - if (out_page) > - kunmap(out_page); > + if (cpage_out) > + kunmap_local(cpage_out); > > if (in_page) { > kunmap(in_page);