From patchwork Thu Feb 22 08:11:34 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: 13566843 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 BDD65C48BF8 for ; Thu, 22 Feb 2024 08:12:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 502A76B006E; Thu, 22 Feb 2024 03:12:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48A056B0080; Thu, 22 Feb 2024 03:12:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 352736B0081; Thu, 22 Feb 2024 03:12:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2489D6B0080 for ; Thu, 22 Feb 2024 03:12:04 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B83A9A0CF8 for ; Thu, 22 Feb 2024 08:12:03 +0000 (UTC) X-FDA: 81818721726.07.426C215 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf04.hostedemail.com (Postfix) with ESMTP id D40E840015 for ; Thu, 22 Feb 2024 08:12:01 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TrVY9nm6; spf=pass (imf04.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708589521; a=rsa-sha256; cv=none; b=7NyOEnJ02+3cikm1yShSbxrDtIT0sqCeRatzT3i1oeddGtifQChSDyvZCVFPELcY0puEe1 2unfk5hAbLdqezGSgcW301oYFHlu92jKQ+l9rPL1w4LW3C6rN8/a47wgT0oUBVLh+sQIki 58KXXI1eK7kKjwyolGdT0AF3qpSDAbU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TrVY9nm6; spf=pass (imf04.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.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=1708589521; 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=ejiG5wp8wHYtqv4OVHF7H3n1cMrEsgDccZLLuZArdnY=; b=FH6Q+FjeHJzZsBsHs1eeP0VV6Qfyuw3tHUWTJ0cD6a5cRUePirAl5kHcHmDC50a08YgcC1 UUNwWjRx4oLYUNffjwrU6q9d/JLnZY9LW83pb1PBThC2R2JwCEZcdb+Pf9aEhyzmGIOEzA dU8JDG0RsW8nH2zezeToHo9ASZk9nKM= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6e08dd0fa0bso553167b3a.1 for ; Thu, 22 Feb 2024 00:12:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708589520; x=1709194320; 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=ejiG5wp8wHYtqv4OVHF7H3n1cMrEsgDccZLLuZArdnY=; b=TrVY9nm6aMXtx4fdSjNjE/FAD+7icL1YbWJnD2d90FIJa6RvLKQhm8Otduplwccli8 92nTM/59MvddWt0LjiLP9+Ue4zvTsziMJ/VelftBkyH0apcskpELdfxzCdNAkH0Bxahf SEVIKhwiAstTdr3QTvvt30KopNCNwMGQY6RyRB+7HfY4H5GgFyEchF+BnfbMdZrdSywp zyH9+SQo5g3TG2cbQ0A056iHcIB9JD9pnqHbiJhiaqAPb0Yeqvt4+ail0Jnrd8QscTyd FBZNr6ynAyPmxPsinYbHE8zX+gathiLnayJqW34CgXval2IrpuoeEDEssuM+c8ZVELpS W7KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708589520; x=1709194320; 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=ejiG5wp8wHYtqv4OVHF7H3n1cMrEsgDccZLLuZArdnY=; b=SWPucf51801nQd07Hq7mhpgbgMwfZQMqotdL6qTqplCaw5wXWQyPi9ApDDG4t9Ostt QQzpD31kpdvO+jVL677YVj6y8UK65Syn5K5KfrnpVtXAOB+DxAMXx8ZRZSIS2YoqHwLi Ih+HZxyLlP7QLIOeeYxkzO4MBHC91XSEPClliXo2cOnS1Gu8Sue7uou2Y9AY6OYTy1Ui BEq6mvzIUtwwLGZmDcTnyllz44gqePsJakeIsfi66lkpmbV0LK/2AcMwP5k/95UFkEiV ktMqFG4D4tX6Iw35ogxpDQdTOEjzyAE97/0GxN33ub+7YqU+jK1PQDqqV3ynQQkaprI1 q6VQ== X-Forwarded-Encrypted: i=1; AJvYcCXUZm+uTdufbkfLZ2LnedUcyT7/D39fcpRbr08LXql/3TYNOcxm7giXLL6rje7tc6SAOjGdkCouWkNLSCwpCxjjQiM= X-Gm-Message-State: AOJu0Yxpor8cKl4NibUu7fZMVXAyJNI4zL66ILzieo8Ncee5YRpzN5x8 Lzc3RhoRMR3XsQENEjTcdyGcSO7DK/mvnm26mLfEg10UEB8/ztEf X-Google-Smtp-Source: AGHT+IG4Sfvb1A6057v5bmOBRwDro0a1UI6orgA95fIP6RLJByG94Z7EUV9wpMjkFx/vclOd59g6pw== X-Received: by 2002:a05:6a00:1d03:b0:6e4:c3e1:8fb8 with SMTP id a3-20020a056a001d0300b006e4c3e18fb8mr3075598pfx.8.1708589520591; Thu, 22 Feb 2024 00:12:00 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:3b18:a2e2:f00b:c965]) by smtp.gmail.com with ESMTPSA id du17-20020a056a002b5100b006e46672df97sm6989554pfb.75.2024.02.22.00.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:12:00 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, davem@davemloft.net, hannes@cmpxchg.org, herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, linux-mm@kvack.org, nphamcs@gmail.com, yosryahmed@google.com, zhouchengming@bytedance.com Cc: chriscli@google.com, chrisl@kernel.org, ddstreet@ieee.org, linux-kernel@vger.kernel.org, sjenning@redhat.com, vitaly.wool@konsulko.com, Barry Song Subject: [PATCH v6 1/2] crypto: introduce: acomp_is_async to expose if comp drivers might sleep Date: Thu, 22 Feb 2024 21:11:34 +1300 Message-Id: <20240222081135.173040-2-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240222081135.173040-1-21cnbao@gmail.com> References: <20240222081135.173040-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D40E840015 X-Stat-Signature: oeq88rfxfzy4fik96348gqz7ht9ac7e9 X-Rspam-User: X-HE-Tag: 1708589521-287437 X-HE-Meta: U2FsdGVkX1950UlRwyTLnknUC9pLZlzBJ7RyTz9bvkvt4VjN/EvJz0zTFjhx8H1cRrFNHHIw299EAqQRwOX9a+JaySVaKsb0IQ6XFlFUUSPUHzT4N4+OcVnvvjKq8JqXnAvk9Hi21e55rF1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/0n48eHTa+WagVqSd9UZypAHAP2LHBzMaz8Jj1BvLjGA3tEdgIUf1FZAgZ+nimWAYZOiH1XlNgrrWr776haRJfTqMTrYmNADZxIRmys/g6bDrTQS6sOL+IhGG1TSfw2mf8qGncZaf0SEKdsxBwpA3W5wpLVsXeuZd7Ra6NrH1RfKDOZ3PFlWZACCj7M1HZwdM/XQ4te/C3zOUhkua+MqkxcZAqxVbojNcAIfmEeYj0kpm2ClLx5kgHN5AiuH2B1PIUGKL8jcRByswXLrw8e+OMbWXA1HFszWu0ctAbhQJC+SZmRJ7zJc+HrzbnS9Uo4rCxPe1LzNj17ub3QpkyfaSJ2gPF9yQ5DVwD063p9mGvZDQnJvADo8HOijHIs8mmIbR4aYZgXaJbu8/czDDY/e9z 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 acomp's users might want to know if acomp is really async to optimize themselves. One typical user which can benefit from exposed async stat is zswap. In zswap, zsmalloc is the most commonly used allocator for (and perhaps the only one). For zsmalloc, we cannot sleep while we map the compressed memory, so we copy it to a temporary buffer. By knowing the alg won't sleep can help zswap to avoid the need for a buffer. This shows noticeable improvement in load/store latency of zswap. Signed-off-by: Barry Song Acked-by: Herbert Xu Acked-by: Chris Li --- include/crypto/acompress.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h index 574cffc90730..80e243611fe2 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -160,6 +160,12 @@ static inline void acomp_request_set_tfm(struct acomp_req *req, req->base.tfm = crypto_acomp_tfm(tfm); } +static inline bool acomp_is_async(struct crypto_acomp *tfm) +{ + return crypto_comp_alg_common(tfm)->base.cra_flags & + CRYPTO_ALG_ASYNC; +} + static inline struct crypto_acomp *crypto_acomp_reqtfm(struct acomp_req *req) { return __crypto_acomp_tfm(req->base.tfm);