[RFC,1/2] crypto: introduce acomp_is_async to expose if a acomp has a scomp backend
Message ID | 20240103025759.523120-1-21cnbao@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4802320dyb; Tue, 2 Jan 2024 18:58:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2CnH6xxruZZFTQ+W0XVY4wO5m+EVN5SUL7/ZtbeAmHRFqO6Y70+lfc1rwev7b9EPrFT6l X-Received: by 2002:a05:6358:784:b0:174:e3e2:4150 with SMTP id n4-20020a056358078400b00174e3e24150mr17034488rwj.0.1704250719568; Tue, 02 Jan 2024 18:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704250719; cv=none; d=google.com; s=arc-20160816; b=h0MXYx9F+1mt00uLOFjVjlClSXl9PaSSlqXgZF0ixZ3Zr6ZZ6AY5jhOxI0H3bisbT4 X3FnMomzqNZzZXUIFQl4tZXjzzhoU6Jn2yPXh86DOLbO7Mfxi9hsC7lsVFLn2uY7M4Vb ypuvXQQ//ZjW3021EG6BVRkIzrFZ2JdrVf6UEBT1gK8DklNy2JxLAh7A8aLZOPLu2Hgh tYx+D0crgh7qrQIjL9jMVeBqSiMsjJkv4iI83wFxOf9a2UQCL/Rczjh5ozQIueovhIgm MFHKWPSqj4W9VzCAHc5S7WnU5p8VfAuq+LQfE5MRj0N+Us0m0L3BfM02toVHIQFy24zf pxyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NIIzA7fbS8s/FhcBsRrFPB1nSchgGWmbbp2yPMvhK/E=; fh=N8BdziGEL67X1CS79Ag9CohCm5DjRRS659nt3Ezwj+A=; b=CH5R1nNfM5SwBAbHjqQgE5nyo2bzejY/2QSqG45NXZtkaZxnKiih6hjVm1ojZxyqqP Z/pfL9B3rrRI3Ckic7REJLQ84H1nW3ZZpx1mhMex6NJXauZAxeL2vvRif2zTHM7SmulG Or+ZTdQhIHyxDOXzUy34jJFvlJTPO7gVb+avEFs9sr4+gakUBas1rrARwI/XFU+JFdpk b+9Ju6teNG8UGff0KZXToxI5p1lZp15LGbbUgYT1UXPMpEW2a3GCPWpy7/kXZzWZJkWG M2kR7QqE3ElJpjhQ5Excu4o+kFJ9kgSrpCty95H/GD8wVBbKk0VaLvBshocJkbMFjWT/ I/+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8jxNEjL; spf=pass (google.com: domain of linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t6-20020a17090ae50600b0028ce966d638si440465pjy.174.2024.01.02.18.58.39 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 18:58:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z8jxNEjL; spf=pass (google.com: domain of linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15103-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4E1D1281C73 for <ouuuleilei@gmail.com>; Wed, 3 Jan 2024 02:58:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47199168BA; Wed, 3 Jan 2024 02:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z8jxNEjL" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59ECA3D6A; Wed, 3 Jan 2024 02:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-2046b2cd2d3so6655698fac.0; 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=vger.kernel.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=Z8jxNEjLZb3IUGGLhfOnGxAi/J6EAdWcyPV2U8lkmWauTyM9C4fkcD5Ol3B7Ez4Pai Dhe3G9EYRPFARHzP0aG6RZANTMMQQMTzqwu96u9of3BdDgVGcmFA80euxjuiTw2zDGwE Of9XANPiJyiCJ2R2yWWKbsfIFO9LpFSSh1ijtxTm06uBpBWtvoU0AYNRrMXsSdTsJm9y EdY+zKLEXkVl9XVZDjt5oQUJYVH7vfb2WiGsHId/SNJQ61Jiub1feldW2FsqYWk5R19+ AwyUbxT5tTxBaK/xMgXGWY648pFI0/OPBjk0vHE5i+25u0cDYE1AXujyN3xLxhti0e+Y gYvw== 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=qQyQWLdieq5VyZKGk0iZwntnLf7oICKmbzt2LYGY8MswHEE5oq6RstYoPEoJIxl3P0 O00X/5PTRLy/w3BPyReUPnCnSHJgwNCEJS8s273iqqdpbN944uUT0D/0Vt+q/S5+x3tn 4glYNTkBatcutZ1CdpJnwurorhQiMo+z5OazXGj/sPre/tBlmdmk/5KFe8wDphER9VgK iueY+253UQpVZMsmcCv+pe9bg4ha7hbnDecxlDpVC4Td13+kML/be2jfzj6wAk4eQNMe UM49OMGS4JFGls77MugGbZvFcXMMP/tfxiyp7T2Fm6hA0I48f4IYuKogaxmkUH+YGB/q RjNQ== X-Gm-Message-State: AOJu0Yws1La4jDqdnAxzY7WaQMqK0ngVSyzx+08X/TJ6k8Oz2MTL9OzC ShpbFuzctViXWwUE8VWZgUg= 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 <v-songbaohua@oppo.com> 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: <ZY1EnEefZsRTGYnP@gondor.apana.org.au> References: <ZY1EnEefZsRTGYnP@gondor.apana.org.au> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787036402473674916 X-GMAIL-MSGID: 1787036402473674916 |
Series |
[RFC,1/2] crypto: introduce acomp_is_async to expose if a acomp has a scomp backend
|
|
Commit Message
Barry Song
Jan. 3, 2024, 2:57 a.m. UTC
From: Barry Song <v-songbaohua@oppo.com> 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 <v-songbaohua@oppo.com> --- crypto/acompress.c | 8 ++++++++ include/crypto/acompress.h | 9 +++++++++ 2 files changed, 17 insertions(+)
Comments
>> >> for CPU-based alg, we have completed the compr/decompr within >> crypto_acomp_decompress() >> synchronously. they won't return EINPROGRESS, EBUSY. >> >> The problem is that crypto_acomp won't expose this information to its >> users. if it does, >> we can use this info, we will totally avoid the code of copying >> zsmalloc's data to a tmp >> buffer for the most majority users of zswap. >> >> But I am not sure if we can find a way to convince Herbert(+To) :-) > What would you like to expose? The async status of the underlying > algorithm? Right. followed by a rfc patchset, please help take a look. > > We could certainly do that. But I wonder if it might actually be > better for you to allocate a second sync-only algorithm for such > cases. I'd like to see some real numbers. some hardware might want to use an accelerator to help offload CPU's work. their drivers are working in async mode, for example, hisilicon and intel. I don't have the exact number we can save by removing the redundant memcpy, nor do i have a proper hardware to test and get the number. As Chengming is actually working in zswap, i wonder if you can test my patches and post some data? > > Cheers, > -- > Email: Herbert Xu <herbert@gondor.apana.org.au> Thanks Barry
On Thu, Jan 25, 2024 at 5:41 PM Herbert Xu <herbert@gondor.apana.org.au> wrote: > > On Wed, Jan 03, 2024 at 03:57:59PM +1300, Barry Song wrote: > > > > > We could certainly do that. But I wonder if it might actually be > > > better for you to allocate a second sync-only algorithm for such > > > cases. I'd like to see some real numbers. > > > > some hardware might want to use an accelerator to help offload CPU's > > work. their drivers are working in async mode, for example, hisilicon > > and intel. > > > > I don't have the exact number we can save by removing the redundant > > memcpy, nor do i have a proper hardware to test and get the number. > > As Chengming is actually working in zswap, i wonder if you can test > > my patches and post some data? > > I don't have the hardware to test this. Since you're proposing > the change, please test it to ensure that we're not adding cruft > to the API that's actually detrimental to performance. Understood. sorry for the grammatical errors, i was actually asking for chengming's help for testing as he had hardware and was actively working on optimizing zswap. and he has already tested and sent the performance data which I quoted in the formal patchset. > > Thanks, > -- > Email: Herbert Xu <herbert@gondor.apana.org.au> > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt Thanks Barry
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