From patchwork Wed Jan 3 02:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13509630 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 26DB6C47073 for ; Wed, 3 Jan 2024 02:58:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73BD16B02FF; Tue, 2 Jan 2024 21:58:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C3F26B0300; Tue, 2 Jan 2024 21:58:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5183D6B0301; Tue, 2 Jan 2024 21:58:20 -0500 (EST) 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 3A4646B02FF for ; Tue, 2 Jan 2024 21:58:20 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 05C1A401E1 for ; Wed, 3 Jan 2024 02:58:20 +0000 (UTC) X-FDA: 81636491160.20.2692943 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) by imf27.hostedemail.com (Postfix) with ESMTP id 6950740006 for ; Wed, 3 Jan 2024 02:58:17 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CyAl9L1x; spf=pass (imf27.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.160.54 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704250697; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NIIzA7fbS8s/FhcBsRrFPB1nSchgGWmbbp2yPMvhK/E=; b=EjxpLiUBFIUaXUPTLL1a/wxmoQqnbvyHFHebhnWfDzANLNDbTfpJCxnn9y7Jh7zbaztbU4 6o6e/RCHDH1uAXV/tMIiKcGXQgEW9d/vlJPnFh4qc4wtZ8ECNylbzLMvuTw7Dk2VDGGGC7 rg2/Vx3on8GyhFP+JOHG5wHywFJshj0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704250697; a=rsa-sha256; cv=none; b=zyHLNrPZe3vQGu0vWl+76EKeNO0Nga/msd4YN09AnVoS0c4t7RPPSEaDY++LNNmCLu6B5E sMtxrzIqwe8ShBIy4sB3Kb5awRfYtDTHIvURcNhFlkWhXQRmcSftO5iWkbJvQ25aFmWaB0 eKIAwy9QbDU4axkYp0RrxYLqDLESbR8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CyAl9L1x; spf=pass (imf27.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.160.54 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-204fdd685fdso3625469fac.2 for ; Tue, 02 Jan 2024 18:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704250696; x=1704855496; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NIIzA7fbS8s/FhcBsRrFPB1nSchgGWmbbp2yPMvhK/E=; b=CyAl9L1xTHsTwLAHQswIQwhwZ7NjIc+I+irt5be5wd+bsraCsIbZP8FkAVcTX4HFTo m3a6aNAiMPnfwEp8jAQFSspkWk1+kT0rLXWqdbCnEqhsBOLwMvDSwVupOWtnRtKu5R+b 72Dr/ymEMH8eCH8Hooo+QtpMTxUNFCPltS9Buu8w1PJzlRUSE8KSa5ZACjFko1RAKbef M/6hIKcLlhTJ8Gz1jI7r7VHEtmHFPNSGgSdC0x03qsvDK2F7LBfl5I+Z5n/YXdHoNAH5 nAlt6bFNFP1N2ZstHgCcz6QanILOHBFNmzz+QfUJle3QlTa8SUZDXDg3c+UOcxtGUiAm s7CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704250696; x=1704855496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NIIzA7fbS8s/FhcBsRrFPB1nSchgGWmbbp2yPMvhK/E=; b=JWVYypkxBziue2imkkPMxyKWAjibLPmBbAD+HJgPsdm3T8ZvVmuOLyYq0d4gK70TVS Tu3gnUwsKuKcVIvdr4NGY9HRG2bttMxIn7ZDpdC2nyvLvP1RAoiOKlyFf9snSB7MELSG 8pU+qR6KQ+tU2kWUlX3NDUM94jQCFX3gTXS8rsvliw/MdcGaCk737w4a4o0C6TteuaF6 K99yIvruCFgQCNl1jSGWKuz3pjXhCGtXtm3IA0TRzWRLFn+H8zweEG358eT1PScNvq9y oa3nH+x6L6d6sYcLdEEJ6Gh42vdVQWG5lCoqUj2oYpCeEIfaHlz4mIu5fZ3RZuUJlZLQ WoHA== X-Gm-Message-State: AOJu0YzBEo5M8KIjOQ1Dx3TtHieDNgXbM9F82MKqptQczfvIARbdalNT cE355eXn3Ly9nH2iefgRPnk= X-Google-Smtp-Source: AGHT+IH4gkLqk3A49fXuIeNbtthqeFpcn7JnphMh82PHSJ+6uaZVY858IfbtgwvP6EPPGlBkrzHNJw== X-Received: by 2002:a05:6870:ad0f:b0:204:9c06:fa91 with SMTP id nt15-20020a056870ad0f00b002049c06fa91mr19005485oab.110.1704250696495; Tue, 02 Jan 2024 18:58:16 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:a7d6:f37a:9130:cd96]) by smtp.gmail.com with ESMTPSA id d6-20020a63fd06000000b005cd8ada89e5sm21168572pgh.70.2024.01.02.18.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 18:58:16 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: herbert@gondor.apana.org.au, davem@davemloft.net, akpm@linux-foundation.org, chriscli@google.com, chrisl@kernel.org, ddstreet@ieee.org, hannes@cmpxchg.org, linux-mm@kvack.org, nphamcs@gmail.com, sjenning@redhat.com, vitaly.wool@konsulko.com, yosryahmed@google.com, zhouchengming@bytedance.com Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Barry Song Subject: [PATCH RFC 1/2] crypto: introduce acomp_is_async to expose if a acomp has a scomp backend Date: Wed, 3 Jan 2024 15:57:57 +1300 Message-Id: <20240103025759.523120-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 6950740006 X-Rspam-User: X-Stat-Signature: 5goao3yao7pjkuepzukc47878f95jwex X-Rspamd-Server: rspam03 X-HE-Tag: 1704250697-883105 X-HE-Meta: U2FsdGVkX18anBgiCwYv61YWgwlchlpF5vfC+hrHC4d7e8cMbbr0JPQz7PNb4AFtWJAvvCW9vFiW4VnjvyXCBKDwJkWqX6pvvE0Tg3s1l8QAJoV6uJuiHPZ38bktplJjU6fH4+pr2Qr/yq/MSo28ZMekQUtz1yEkQDSUHLNrQpuRAozK1s0rCYEjSUBII+NScmc0lXo126tCvCNSTB3+0oki0CDcC1X6QkSL6Mg1IulLj+A2VpiAzx1+8uwtFDgO3IMj0Gm/N303IlsP495YtOuTgaGadu86vq/cm4vjixN/ZbBKbQ65aN2BiktDwgjl8TkTnIu8aB5OVn3b+pVnUIw2R4X4XJHu8E/ut4xdVfszbCh/1JYTaFCmhFhqaAws5zYdLEr4B7JUQFkKNR6SDcYI/plhZTm72l2DjMxi9oT6u4QiA3akFn9L8YRWLohmAwBJ7hyvnBDburmSIP7mvRFi2a5OZzsftYCQuzrry3wbdCHBpnlDPU9G+7PbLy7+nJz0IoWEZK+rbbCJcHimB80j443BFKnYiv3TI4x1Iop07UqVry4Sw/+UJSn8FIKkn4ZLOusKhTJ4JcjVea+DSlzRnZm0F4fXCTJ45qHTu5EgaSM1GD4Bv12UBq3nuMs/8iUzyXhGzO4fou/Y5Mc/EyCDCfQ5s+Ok9nMf5iOV1OKLxB+1FbSsrrlGA8t1yqZ2tvfNllgNmHaNxTnt2clks9iUo64TASp3Q87ssz2G37Z+X4+jmzZ/zZW62/LnrJngW0rg4Gf6zDiq45wEEbQv53RaAmH6zIA8iyKbZim0xUc0JCulXufR8mMTElO2cMqJr7K7mi+tPM0ojciuHVWMzXtwKRasi3xcIZDvcyuZjGTgEylZAaBtBBVTJ2EeWLqURITjnFpRz0cFMYfzPI9hHF++eEi/nSQUK1CvBZ7KYe+4EwAuwRCVD+JfSktZL8btCEzinudmFsyhqZzewep rW0449t+ GeFfSL8LSYbJKR19JmsCvcccNDnFid+E/Ig0uVRuJTxnQ2z96xyM3uE2ehvXkAq3+6AsIHteYqz1qmwq3dDL5l7sO/T4NKTSNDz6zeVQyvNCkdig/2ZqjrIJX3AqnvcprwjXHMomJmIxLHR+bmgGQ6P0QBWrk3BZYTCJ7 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: List-Subscribe: List-Unsubscribe: From: Barry Song Almost all CPU-based compressors/decompressors are actually synchronous though they support acomp APIs. While some chips have hardware-based accelerators to offload CPU's work such as hisilicon and intel/qat/, their drivers are working in async mode. Letting acomp's users know exactly if the acomp is really async will help users know if the compression and decompression procedure can sleep and make their decisions accordingly. Signed-off-by: Barry Song --- crypto/acompress.c | 8 ++++++++ include/crypto/acompress.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/crypto/acompress.c b/crypto/acompress.c index 1c682810a484..99118e879a4a 100644 --- a/crypto/acompress.c +++ b/crypto/acompress.c @@ -152,6 +152,14 @@ struct crypto_acomp *crypto_alloc_acomp_node(const char *alg_name, u32 type, } EXPORT_SYMBOL_GPL(crypto_alloc_acomp_node); +bool acomp_is_async(struct crypto_acomp *acomp) +{ + struct crypto_tfm *tfm = crypto_acomp_tfm(acomp); + + return tfm->__crt_alg->cra_type == &crypto_acomp_type; +} +EXPORT_SYMBOL_GPL(acomp_is_async); + struct acomp_req *acomp_request_alloc(struct crypto_acomp *acomp) { struct crypto_tfm *tfm = crypto_acomp_tfm(acomp); diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h index 574cffc90730..5831080479e9 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -195,6 +195,15 @@ static inline int crypto_has_acomp(const char *alg_name, u32 type, u32 mask) */ struct acomp_req *acomp_request_alloc(struct crypto_acomp *tfm); +/** + * acomp_is_async() -- check if an acomp is asynchronous(can sleep) + * + * @tfm: ACOMPRESS tfm handle allocated with crypto_alloc_acomp() + * + * Return: true if the acomp is asynchronous, otherwise, false + */ +bool acomp_is_async(struct crypto_acomp *tfm); + /** * acomp_request_free() -- zeroize and free asynchronous (de)compression * request as well as the output buffer if allocated From patchwork Wed Jan 3 02:57:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13509631 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 D308CC46CD2 for ; Wed, 3 Jan 2024 02:58:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CFA46B0306; Tue, 2 Jan 2024 21:58:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 257AC6B0307; Tue, 2 Jan 2024 21:58:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AC616B0308; Tue, 2 Jan 2024 21:58:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E64926B0306 for ; Tue, 2 Jan 2024 21:58:25 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BA4A7C069C for ; Wed, 3 Jan 2024 02:58:25 +0000 (UTC) X-FDA: 81636491370.29.9261F3F Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf20.hostedemail.com (Postfix) with ESMTP id 221741C0004 for ; Wed, 3 Jan 2024 02:58:23 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="KT/7M14s"; spf=pass (imf20.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704250704; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ro8Y0j0Jt26z5Mz6Dk1T+PNwiPxDyxcm45d9joAfXn8=; b=Mq7bKPQRnI4kDKsYgWKqoKdfyd2gZRg2yOSSrQ1xIttdlP4hgKclRohO20zRCyJlmZOYAQ LE3ytmImXw4n44iOhfoaJMmXD22+QCyE1hMYeQ16Di7fpuEfhRg4BouBJnSo2f4N7KPO3K fjpCI5qLamvfuR0exs70eOT1YSh1eeg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704250704; a=rsa-sha256; cv=none; b=LcaugFcJYFiRrxcW5zTJSzLHBD1sunGVCkXwuC27w/WcUGslZ1Pn9U8rtjrCpKR611dqBb MQv5S1TolcxkuOmWXlTWCM823nRi9gXioOFV/a108rFYg2ZNvxQwjb7WaJ9sebMXSniT7t iY6xA1E0c/z/1MZ8eCo6mbNhsD1ljoA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="KT/7M14s"; spf=pass (imf20.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5c66b093b86so42049a12.0 for ; Tue, 02 Jan 2024 18:58:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704250703; x=1704855503; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ro8Y0j0Jt26z5Mz6Dk1T+PNwiPxDyxcm45d9joAfXn8=; b=KT/7M14sLEhaUni/SMq0bHH/QbEy19UHGlqoDdT8v8QFK6cD8r52Jo579Sa17+dlv2 rjE/DDb6OkdJ0ye+qtsWUnf/JF4Fyn1QsTSfZBUnEEdQbmWWDAAQAAjS/+9eVoZJribK wQcafnySPEKCjyqmAw9Qg+vVlqeGKtRN6PWmxwQZTxBej3M5iwcPFSFCnWG4h2SaYIP+ 6SQfvjMtZUYEG8u30lGm7j/1RA9+g4hkMBCsE3b6Ry7MiCQFzyMQCIb6kEI+e0OE7Hog 4OJ3FLM7YdZj2stZ1BuLRhOAnv0uAL9ibTYhAqaJTVJDoq/1RqR+y6WKDavQ+/Ap2Hdq Ou7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704250703; x=1704855503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ro8Y0j0Jt26z5Mz6Dk1T+PNwiPxDyxcm45d9joAfXn8=; b=OLMJjp4la2VnmItoX6aosOk3Td45g5dDxWalHjWWgmwdUqOybGgrMzDnSvMbdPC6y9 nWPi9kqk+z2vWSCuhbYuocgA9t5AqXMI3QORVclF2PjIlB0bgeLUU0x5Xeszj1Qsn/j4 eRUWssljAOklXcsW3Yuy6Rqr+NmfaC57ebKjDDAt+EuKILmFB59Ga9gkABQzHamWuWXm YEWymVQlKCRgBpDiWOLWri81ktZpBU4/VPuJpgIQ9M96Ou11dymdXKn9vQHBw/MFs8A5 fpD/j4/J0L66462ZEoLdpW69If+zz44fqTA9oARZocsygbGYvSqTJkXCZSbGfHU17u61 CWhw== X-Gm-Message-State: AOJu0Yyr2uNgq8XHfnnPruk0GW5oeizyoWdrYtyt26YOaWR+STuXj9hj NEmWewfkho8BXRqppmgJozk= X-Google-Smtp-Source: AGHT+IHg0kL0VkhfiKjZqGlDkvzVw6ytZtdeJvrtTSssilg7C2zxj//va2NtexTtk2eArS6S4PPYUQ== X-Received: by 2002:a05:6a20:2443:b0:196:c543:abaf with SMTP id t3-20020a056a20244300b00196c543abafmr513723pzc.38.1704250702826; Tue, 02 Jan 2024 18:58:22 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:a7d6:f37a:9130:cd96]) by smtp.gmail.com with ESMTPSA id d6-20020a63fd06000000b005cd8ada89e5sm21168572pgh.70.2024.01.02.18.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 18:58:22 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: herbert@gondor.apana.org.au, davem@davemloft.net, akpm@linux-foundation.org, chriscli@google.com, chrisl@kernel.org, ddstreet@ieee.org, hannes@cmpxchg.org, linux-mm@kvack.org, nphamcs@gmail.com, sjenning@redhat.com, vitaly.wool@konsulko.com, yosryahmed@google.com, zhouchengming@bytedance.com Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Barry Song Subject: [PATCH RFC 2/2] mm/zswap: remove the memcpy if acomp is not asynchronous Date: Wed, 3 Jan 2024 15:57:58 +1300 Message-Id: <20240103025759.523120-2-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240103025759.523120-1-21cnbao@gmail.com> References: <20240103025759.523120-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 221741C0004 X-Rspam-User: X-Stat-Signature: 6dq9ojuw1xr1kfuweqket4mkr48yj3um X-Rspamd-Server: rspam03 X-HE-Tag: 1704250703-214039 X-HE-Meta: U2FsdGVkX1+SexM5br9XpfrMaG0ov6ZwAX876EuuamKRNOxI3Lx20G8t+/kMCPafAExJiqTS7sJQNlRvv8mo5w2yEBF5j8kv2fUGYL8KUh9eau2LW3Vp7Nt2KXjjm3eYKb6N9VEXDGCFvRJqKmSt6TREF0O+EI9LVHOZ6tDFE/Ck/1EvLsZq40CKp6RgTGfU/XcKXlnDnwrWHZvkdeATdka1CMndRCz19K4iVbikbDSdOP9ui+uy4mBfbPPbSOf330zFC59cJYFplTOgAnlDTNWzajkTe0wGQ9MhUPqHBz/F9hA+kByFoazTyXTRbDZ+kLbPOswUxuK+aOi0w0RBPg1A8l8GEWt0vQOiEPKwnk30FGJ31H6QGKWfhG3dnHgG8GOUT5/wxVy6chwlk7/VftY8doa2eSOc2tM6S3JYgOq1K8A1M8iX4RFj5pSfE/AXbx4HNkB6aVQNWjxhgML/qVqH/Dbxu5KSA7fEHCDsi5V9ECvDQl5kiQhdL+ZLBVIqfhf8UH7h4mBDFKwsNytuwJ85gbMRpnggRKww75OxdiZoSgudrly2a87R+f6LJu4hIZNPsv7GFDjds6IkcTkcaOQ2z6CvyKusGZ4ieJiDKI/qkibOIIxXux8ir2GEdVG6g/mFjgN6+HC6Q9uliskBNLpXMqmGNE+vzy2+NfalINute9aicoTsY6sTUkC7iSl5bVsFzp0p0hgr5+lBLjdfJIUP81UfmJaqMBrMIz+C1yHES1h0Jglpm6tiiNshvAsI/TIlDxb9x9CaHg2+GqMDz+rBROnB1/W+FtMsFfRzwbP1bMWazJxSm6Ueq+tCCblG14g1cRE3SeNIHxLRNOeIEpfnhp9c19s3jh78iVuHA9fPdJjXEotYq8RPe74wIrmiPUK1w1bWeYfsMLwPYMh8FSF6unZv72yPQRQ+7sngywMDvqgprJsN8CqK3Yykjf8T0XWxZWNY8rQ02Cb57eB KkWQbKOy 7bbMC+NGIBodqak/BaNIna75U3tMQu3bVLnka3L9txLL3OUyeziu8rEwxeWNuTFbqbm6U4tnzBINKy4o86Hf6SqPTAdLQwEeIKrj6G8jXvQ+5Esn9ljc/MSiPYg== 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: List-Subscribe: List-Unsubscribe: From: Barry Song Most compressors are actually CPU-based, they won't sleep during decompression. we should be able to remove the redundant memcpy for them. Signed-off-by: Barry Song --- mm/zswap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index ca25b676048e..36898614ebcc 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -168,6 +168,7 @@ struct crypto_acomp_ctx { struct crypto_wait wait; u8 *buffer; struct mutex mutex; + bool is_async; /* if acomp can sleep */ }; /* @@ -716,6 +717,7 @@ static int zswap_cpu_comp_prepare(unsigned int cpu, struct hlist_node *node) goto acomp_fail; } acomp_ctx->acomp = acomp; + acomp_ctx->is_async = acomp_is_async(acomp); req = acomp_request_alloc(acomp_ctx->acomp); if (!req) { @@ -1370,7 +1372,7 @@ static void __zswap_load(struct zswap_entry *entry, struct page *page) mutex_lock(&acomp_ctx->mutex); src = zpool_map_handle(zpool, entry->handle, ZPOOL_MM_RO); - if (!zpool_can_sleep_mapped(zpool)) { + if (acomp_ctx->is_async && !zpool_can_sleep_mapped(zpool)) { memcpy(acomp_ctx->buffer, src, entry->length); src = acomp_ctx->buffer; zpool_unmap_handle(zpool, entry->handle); @@ -1384,7 +1386,7 @@ static void __zswap_load(struct zswap_entry *entry, struct page *page) BUG_ON(acomp_ctx->req->dlen != PAGE_SIZE); mutex_unlock(&acomp_ctx->mutex); - if (zpool_can_sleep_mapped(zpool)) + if (!acomp_ctx->is_async || zpool_can_sleep_mapped(zpool)) zpool_unmap_handle(zpool, entry->handle); }