Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp363368iog; Fri, 17 Jun 2022 05:07:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tplOR1OLwuYEi7TADJce/SjdrM445Cs7AaKYh2tKy3iuG6aBGGykcnVnBEjkFqqCd5MPc6 X-Received: by 2002:a05:6a00:1da6:b0:51b:fad1:c610 with SMTP id z38-20020a056a001da600b0051bfad1c610mr9555779pfw.25.1655467674560; Fri, 17 Jun 2022 05:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655467674; cv=none; d=google.com; s=arc-20160816; b=EdYKOzRSoDiXbW0DBW1O24cLiN1wcb2jm73Sblpc6MUbZcOjVo/U17iArPTv5juOfE DZCf4FhnJShFwzzSzUZIPyUbW2Say7egCebgaFo1RAWe7kBlfeXxvxFLjH05qXGsCdJ6 fTFsp7EFlmL4Ak3vhA6PTgwe1CVrkZqX4BTiRmG0uT2cdYHZCnFMGMIkYznN0xjRRg3d WNV11KYgYG1CgyCr2U/phE8qVFsQave68AgXeciaYlAZa0KB/t1FIA9DtK1QPXXnxOlS 8Us3kzzIldrVWp54EPMw2lift59v4KuzmQUWEhaNoZFC2n2S1Be5+ETeWPWhSnLUJz73 HjlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KnN24k9bVkHEuK5wqwj88tJd2kUsuq85Wnf8cEQ0fjA=; b=srpkiltuACFijBbJTIt/ajWGaSp6nZCBxcBVVcHlH7yjr2zl3WWEe7U5j2SuqjyM2b vJyd5F0dNk9WCu0gZnKs1PNwxH+zJRFLbzXFHIR3zKSv9TeCqYWPnQOuc2HH2bnnh/Ct 1nDfK9DPvv1Rzt2cYKzAfxB0fwX/8naHEjhswUEkWBm3eLi1xSt4a0/cOhK3BD0QIRqg /6R6HnZFzwoqZg6ZMP1gtNhQezev6LF37cAn9tmy01U9l1R1rkAPJbkao2+nm8SpFF2w Y8yIW+aTrfVJEr5YxHoKL8aK4lWx9GXNp8jSyBstAxmcEkhMI6EPJx64tN+MHC9Qe4bl EYCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=k3jYGlLx; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u33-20020a634721000000b00401baa6d6a9si5437493pga.677.2022.06.17.05.07.39; Fri, 17 Jun 2022 05:07:54 -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=@gmail.com header.s=20210112 header.b=k3jYGlLx; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382194AbiFQMFy (ORCPT + 99 others); Fri, 17 Jun 2022 08:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379829AbiFQMFv (ORCPT ); Fri, 17 Jun 2022 08:05:51 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546F16B7CD; Fri, 17 Jun 2022 05:05:50 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id kq6so8333448ejb.11; Fri, 17 Jun 2022 05:05:50 -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=KnN24k9bVkHEuK5wqwj88tJd2kUsuq85Wnf8cEQ0fjA=; b=k3jYGlLxfV7mO9FY1IxOxNtTFHO5QdM7tcjuPJjU8Y7FrlN6yDdBAngPXpORjDAfpw 6jinETykgTOxqSLSF/bVFLQe3xnb7szXyPl0M1F1qKHXIvmQptuUt8ZaG10vtVa4aOJU +kMcFD7ATDd5R2uFnopGJomK8j8f0+fY+ngWo0gbTKqnHmB9+cST0yyunwfThxs+0RFD a+Aj65wCHFw3T4hZdHCSldfzJhnbZ8g/5F+f1IVHfwMsiWH9gjo+6gxnDl5/rTBPTbnv yevwX2iskpjdHBE/9hiYFw4TrTL+mJCTKCCYzXBa5BkOtV6eU3ksmYCBrYkdbbZpRLd1 MmWA== 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=KnN24k9bVkHEuK5wqwj88tJd2kUsuq85Wnf8cEQ0fjA=; b=zJwCaqSoDYhxUvfEByf1Y313b6EXvsNimXldC3pQNKqmgz4xUKXYtuV0FA7HvXV2Eh jViR6fsQTJNtJx2QG2IggNQSigoXadBJTHveRAgndy2VWU9kUzNWbMdAUZxhL4oOE6kv VN2U0mkTmXnw2CraK3HntufdZJGro6GGgZ/jy5RfVXvnN5BEyaohMz/XvGFq98fOJkC+ gDxKAsM22dq3BlBbfFBXeIHS79nef2RIhH/JJcmk/C6mGPPvWkWOQm2r1GJI/jyjOOBO 0xH3qPiloQSwEkCTcDYwAUYz2vDU86lDz8Ce8K53sx/ThHEnjqOh2sB3cmoPT7w7/gk4 tKPQ== X-Gm-Message-State: AJIora/eI4TSGUSCxQDsdK3uCd0QnTLQkIrAZki5wC74RXgznBLS6REi WnapV+02QnZDzfzByNA+l6MMiSYCP5g= X-Received: by 2002:a17:907:8195:b0:710:b40:95d2 with SMTP id iy21-20020a170907819500b007100b4095d2mr9017211ejc.604.1655467548861; Fri, 17 Jun 2022 05:05:48 -0700 (PDT) Received: from localhost.localdomain (host-87-6-98-182.retail.telecomitalia.it. [87.6.98.182]) by smtp.gmail.com with ESMTPSA id kw2-20020a170907770200b007121361d54asm2135179ejc.25.2022.06.17.05.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 05:05:47 -0700 (PDT) From: "Fabio M. De Francesco" To: 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 Cc: "Fabio M. De Francesco" Subject: [RFC PATCH v2 1/3] btrfs: Convert zlib_decompress_bio() to use kmap_local_page() Date: Fri, 17 Jun 2022 14:05:36 +0200 Message-Id: <20220617120538.18091-2-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220617120538.18091-1-fmdefrancesco@gmail.com> References: <20220617120538.18091-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 The use of kmap() is being deprecated in favor of kmap_local_page(). With 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 --- 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 = cb->compressed_pages; - data_in = kmap(pages_in[page_in_index]); + data_in = kmap_local_page(pages_in[page_in_index]); workspace->strm.next_in = data_in; workspace->strm.avail_in = min_t(size_t, srclen, PAGE_SIZE); workspace->strm.total_in = 0; @@ -309,7 +309,7 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb) if (Z_OK != 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, struct compressed_bio *cb) if (workspace->strm.avail_in == 0) { unsigned long tmp; - kunmap(pages_in[page_in_index]); + kunmap_local(data_in); page_in_index++; if (page_in_index >= total_pages_in) { data_in = NULL; break; } - data_in = kmap(pages_in[page_in_index]); + data_in = kmap_local_page(pages_in[page_in_index]); workspace->strm.next_in = data_in; tmp = srclen - workspace->strm.total_in; workspace->strm.avail_in = 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; -- 2.36.1