Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6033577rdb; Thu, 14 Dec 2023 06:46:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHl1s/rSR38t12MZgcgom5TzdqE5q93vcv4P2FO7NVzinjrjy0nYNyALyCz4LPVuDOnvBq5 X-Received: by 2002:a17:902:f803:b0:1d3:5d6e:79d3 with SMTP id ix3-20020a170902f80300b001d35d6e79d3mr1947203plb.115.1702565182934; Thu, 14 Dec 2023 06:46:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702565182; cv=none; d=google.com; s=arc-20160816; b=oWXSNTpjXvMu5K3CGONRlHIRPMWSAwiNgNYK+njr9Ug5SEi6WC/Hd8W3VgJrIJmWpW MDkqrlS6aZTUbYtM1p0YPHpu3vDjjAf+zEoBvvg56T5VRUGfboPdUrF7DCWZzJafRWw1 kKhWd/g+9wxH1hwCpr30C7pdLjklzSN8BhXDo2GRPw33v/jFtebvETrwbSLW+RqCcV9V 0y4snj37/BG8NX47glUhO0UQu/IVuu6Sfh3jH57AUJgz8uC0UO74nrQhUWTPNIi8MnSX QupBLaTptAx7DI1VBP3PYP5VnLypOe7ua+UcQsj6b9U3DKOEmo2IM8y8ppprfTWl4VBD OYdA== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=tF4v5FAsSpR40LsU66vSHRRQwz/YE34tpX6gezwc28s=; fh=eH0M0qAYd7VGluGVVC/tV4CNethGoIwXWs4p7/ljShk=; b=Y8IQSywpRmAU0uOUTaUCfk9dwVQgle/8PYI8qp6XcjcwdoTnVT8Hzt3vUKL8T3SxtW +mMpvV3Rq7nFp82YMvCDkNB/e7FHs6N1pYe0R8RBdU0oY6y6Fk7Uaj476H6h76YOnzkH Nol0FoPPF9NetCDSSXNbhb1c8PLHcMRmc89SmpBK/JfZzoeakTgNxpI1I+2wcrCCr+wb tJJfSdoK40nAhC4Xry0qKFa1fRhwIV3Bmfi69Fv5bvk5XKBukoX17uxcRkJv6q8IKGTf +Dxi00SgCHbxbVfes9mQUdDkYOVPB3Tb2tnxJS68lyFDbXob1WewE/+nYUqft6e0mM9S Di6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jSGj3mnS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bj8-20020a170902850800b001d350276683si2911236plb.251.2023.12.14.06.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 06:46:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jSGj3mnS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5BA4280D754E; Thu, 14 Dec 2023 06:46:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573398AbjLNOpx (ORCPT + 99 others); Thu, 14 Dec 2023 09:45:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230148AbjLNOpv (ORCPT ); Thu, 14 Dec 2023 09:45:51 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E9D136 for ; Thu, 14 Dec 2023 06:45:36 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6cea5548eb2so7522563b3a.0 for ; Thu, 14 Dec 2023 06:45:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1702565135; x=1703169935; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=tF4v5FAsSpR40LsU66vSHRRQwz/YE34tpX6gezwc28s=; b=jSGj3mnSLnq4/KXy+SKOBW15VZ+4iN2O4vuAHDQPtiLWaRLXmfosK5kGmwNDSQ3YJA yiPygQR4xAYWfLsYU49RM6E8W71eybgrt1BiAMcdhM1ui1IT2ggNhuiVlE8gVDZllj9M TJhSSxIdh8NlL/y6fnDRaIuWhni3n3jQVhgFySKvHaFRSZtjv+OrLbaUx4WWM2hdrc2w +QSPj1lhuM3TG90g0pMxaaMS6/K8x67Ni8MNeDxd88nAELeX4nxHKO45mPO7jxn+6sMV K3RyBA4fe+iC9wseXAe3JdFD+3Rmc45zpfbsE13H4G3p2yMUTGPAOqpF081Y0brPiRiD wYag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702565135; x=1703169935; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tF4v5FAsSpR40LsU66vSHRRQwz/YE34tpX6gezwc28s=; b=nMp3J+z0m0OTOykp6+0Xa0AS1aCgro7wWkiFga6J4qYn+Psv0rVXU1HKzqKpx6/DUX O0pdBbtlEIQFLZ2FWZG/r6yfnVOM+djkmVe7k0Uq4RNjtrAMwYQ3/Ha+J6+zxcFgTS69 braIOj9/QnOjqbpSipjiKgwagP5Ivg7p7pq4Io4LHh3lEds8xBjWO3/lIrB6g2ZA6pew Y/hJPdcSU0ZBDAKTIFrlGGvt8xyXnZLkVJ5fOY8GJja1FIx03jr5SOD749pt09NZ/UYF /VGCZtcqanit6GbtCMMHIy/7HuS44iqa3zN728hph+JCYAEEsfOR30oYx8Gpt7QEbISZ O+5A== X-Gm-Message-State: AOJu0YxlNeUDYwa/8avJsGCaWYfdEhjNQlOI4/IQJ8Vv7Z4j3r97bJSN +2JP/qvhLQ6dh55yrBD7pdFchQ== X-Received: by 2002:a05:6a00:27a1:b0:6ce:6f97:3715 with SMTP id bd33-20020a056a0027a100b006ce6f973715mr10959891pfb.64.1702565135434; Thu, 14 Dec 2023 06:45:35 -0800 (PST) Received: from ?IPV6:2409:8a28:e64:34f0:4525:57e4:217e:6e2c? ([2409:8a28:e64:34f0:4525:57e4:217e:6e2c]) by smtp.gmail.com with ESMTPSA id p25-20020a056a0026d900b006ce3b01cba2sm11022404pfw.108.2023.12.14.06.45.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Dec 2023 06:45:35 -0800 (PST) Message-ID: Date: Thu, 14 Dec 2023 22:45:22 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/5] mm/zswap: refactor out __zswap_load() Content-Language: en-US To: Yosry Ahmed Cc: Andrew Morton , Nhat Pham , Chris Li , Johannes Weiner , Seth Jennings , Dan Streetman , Vitaly Wool , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> <20231213-zswap-dstmem-v1-3-896763369d04@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Dec 2023 06:46:09 -0800 (PST) On 2023/12/14 08:52, Yosry Ahmed wrote: > On Tue, Dec 12, 2023 at 8:18 PM Chengming Zhou > wrote: >> >> The zswap_load() and zswap_writeback_entry() have the same part that >> decompress the data from zswap_entry to page, so refactor out the >> common part as __zswap_load(entry, page). >> >> Signed-off-by: Chengming Zhou >> Reviewed-by: Nhat Pham > > On a second look, there a few nits here. > > First I think it makes more sense to move this refactoring ahead of > reusing destmem. Right now, we add the destmem reuse to zswap_load() > only, then we do the refactor and zswap_writeback_entry() gets it > automatically, so there is a slight change coming to > zswap_writeback_entry() hidden in the refactoring patch. > > Let's refactor out __zswap_load() first, then reuse destmem in it. > Ok, will put it first. >> --- >> mm/zswap.c | 107 ++++++++++++++++++++++--------------------------------------- >> 1 file changed, 38 insertions(+), 69 deletions(-) >> >> diff --git a/mm/zswap.c b/mm/zswap.c >> index fa186945010d..2f095c919a5c 100644 >> --- a/mm/zswap.c >> +++ b/mm/zswap.c >> @@ -1392,6 +1392,41 @@ static int zswap_enabled_param_set(const char *val, >> return ret; >> } >> >> +static void __zswap_load(struct zswap_entry *entry, struct page *page) >> +{ >> + struct scatterlist input, output; >> + unsigned int dlen = PAGE_SIZE; >> + struct crypto_acomp_ctx *acomp_ctx; >> + struct zpool *zpool; >> + u8 *src; >> + int ret; >> + >> + acomp_ctx = raw_cpu_ptr(entry->pool->acomp_ctx); >> + mutex_lock(acomp_ctx->mutex); >> + >> + zpool = zswap_find_zpool(entry); >> + src = zpool_map_handle(zpool, entry->handle, ZPOOL_MM_RO); >> + if (!zpool_can_sleep_mapped(zpool)) { >> + memcpy(acomp_ctx->dstmem, src, entry->length); >> + src = acomp_ctx->dstmem; >> + zpool_unmap_handle(zpool, entry->handle); >> + } >> + >> + sg_init_one(&input, src, entry->length); >> + sg_init_table(&output, 1); >> + sg_set_page(&output, page, PAGE_SIZE, 0); >> + acomp_request_set_params(acomp_ctx->req, &input, &output, entry->length, dlen); > > We should pass PAGE_SIZE here directly, BUG_ON(acomp_ctx->req->dlen) > below, and remove the dlen variable. > >> + ret = crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait); > > We should just BUG_ON() here directly an remove the ret variable. Ok, thanks!