From patchwork Fri Feb 16 04:08:13 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: 13559557 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 ACB5CC48260 for ; Fri, 16 Feb 2024 05:44:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1920D8D0006; Fri, 16 Feb 2024 00:44:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 142AE8D0001; Fri, 16 Feb 2024 00:44:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0093B8D0006; Fri, 16 Feb 2024 00:44:34 -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 E560D8D0001 for ; Fri, 16 Feb 2024 00:44:34 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2461F128CA3 for ; Fri, 16 Feb 2024 04:09:03 +0000 (UTC) X-FDA: 81796336608.29.A59F713 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf15.hostedemail.com (Postfix) with ESMTP id EB91CA0031 for ; Fri, 16 Feb 2024 04:08:59 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=i664MK+2; spf=pass (imf15.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.215.175 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=1708056540; 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=ip6H/hpmZhzyeEdQqkgVS2/3JYDDw9wfoPqTzf/YhGo=; b=wB4RI0ealuWX3HZiVG8Nz6iVicHz6idJ6H/TmoACtUEbECeU+F8bmmXCybUnvjig8HN+C0 RvFHrPvou5H0lB8e/Dn46an9y4pukxuK/GPCuqhlJKC2uCZQt1/TUvZKEBMHU2VfSyvg7k htQAsy3kEUYB8UwoyRxTiykt43I5mS0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708056540; a=rsa-sha256; cv=none; b=HIpY+ij7x6lGFVaMIQKu9vByheBvWdflbo6kUvCnZnLqELuux/Mr3i4gthC0tiRxJjDY3M Vark5y4VfAS2Xm8NasT1UmOXCLJUgSYKjE/LgK4lNx2DiOc53qTvGuFm7rlHbu0Q3LOPMs tCZMtjJxw8vydYZTHasiuqGsczZEv50= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=i664MK+2; spf=pass (imf15.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-5ce942efda5so293143a12.2 for ; Thu, 15 Feb 2024 20:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708056539; x=1708661339; 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=ip6H/hpmZhzyeEdQqkgVS2/3JYDDw9wfoPqTzf/YhGo=; b=i664MK+2H9mWqj8LnCs+6lREXOcsa29fd3kbVsYgU+WbxIUYU3H+rvy6RYbhlnU3pO BEplOA/7i6S37kXbhfz4hUpKEFp/FEAV1++1QZwQbSaxW/9p8w4K1imNDKedIpID5nSH lHm9MBqBv4IY458mwhuxSo6EXo071Crgs/42tWCJQkraI7vLNjum0pzbnQfi9ut2IhNy 8MbstOwpMloTEgjC64FYQqw8kIzxG0Qb/+hQQOe6hWg+1pAj2Ysu4DWfRalMSy300JhT BrrkwLk2q9WsLeQOuyNCsECUz2VjwyNwaWfuXU6nsykJNdhD7HPV+dOfO3EB05NjlvSy vBBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708056539; x=1708661339; 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=ip6H/hpmZhzyeEdQqkgVS2/3JYDDw9wfoPqTzf/YhGo=; b=b3i4kGYXek+bwdaqjEqcddmr4Cz4yCHzt/Zg/Pbb5n1hxvX7MnVbR5/cHMhE2IUCQu jldtop+VGYnYdJjSl0otsBPgYihyOhkHXHgn1o7tBEQHaH3/qvw71Wt3CD0Qhi/i9Ev+ cwZ2WrsQen5n/lAnSxYF5+xNcpVmhLYrtctSl4XgqSoSuTqHDWcoqHritEDXZeE0O9/b MhNRf1KzP6VNxqB1GoEyF4lb04ULzK5dqzMY1qHdV82Q2y5yffwuL0UsKUFcx/C7yvPV tu9cI8CX5DwX+R8lVFgjbaU2RVYp9OmNKgXH33oAkDHREoa2djQTdnlmbn2K/U+Q1EKW lvtA== X-Forwarded-Encrypted: i=1; AJvYcCWvLciyDZJD8+T4aGeKOkmI6I3eFzoy7WR76MEDEQ63VSc6bjG2/WdAVA6jXibAbWJ+kQ6N05K4i2VIfdEnGK6mEM8= X-Gm-Message-State: AOJu0YwAZZEcNhQCfNjodUyQk8Fu5SwqQbnRktwoWI8eVazgAN4AXhuK cQz9BoiQI5mCyz004iitMMyg0XfPQXfkbVj7FAfqarkpDMYDXWtM X-Google-Smtp-Source: AGHT+IGnxw942wN0X8APNw9Z9LImEaaq2+ARj4+iKb7RV8ZNkpfq2Y5zhnFisTYBv2GrtJMh2d8vNg== X-Received: by 2002:a05:6a20:9585:b0:19e:3709:f3f9 with SMTP id iu5-20020a056a20958500b0019e3709f3f9mr5626996pzb.2.1708056538819; Thu, 15 Feb 2024 20:08:58 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:f28b:3925:777f:45d4]) by smtp.gmail.com with ESMTPSA id pt12-20020a17090b3d0c00b00298ff26e4c8sm2321393pjb.26.2024.02.15.20.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 20:08:58 -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 v2 1/3] crypto: introduce acomp_is_sleepable to expose if a acomp has a scomp backend Date: Fri, 16 Feb 2024 17:08:13 +1300 Message-Id: <20240216040815.114202-2-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216040815.114202-1-21cnbao@gmail.com> References: <20240216040815.114202-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: EB91CA0031 X-Rspam-User: X-Stat-Signature: uxbpwhejunwark8deacxg8886dcqxid1 X-Rspamd-Server: rspam03 X-HE-Tag: 1708056539-379358 X-HE-Meta: U2FsdGVkX1/HPhPhmevpUr0YpAVyxzlzUzqymHTkkn1iE1/1gqHZSxlAe3nMmEzlnRt43NCEd/sQgyVdSloGsuhUlHblRsgC0enoqusw2WoPL39A0ZbXwPvt7mAF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kk8E70w/JLm0Awbl77fme62ozfXK2sFiGiQnkuQaTLgI+ebW9znat8x35MFFDc0sGxKjWXoOZErd96skJFYIbt32jZXtZyTZSsfTbMZtigF1/lasOvraRLgihaq+sO2hXh81rA6b7n+Y3sK7zgIzXs5Emw7Rkm8ytIKKODaKUpZgyqSSCQmmVt9fjqNctsyFE6YDSwp8ztjU2eLeFl//AKwkdAHIsQO9Fp8geyF/B9Fp4eZhKj44xBd9meBbBNBsaS1HcGjUEse6hkIAlXczEknKvy7LO4IvMTEV9u2RZPiDUbx333KxOoa/h2R5TB59U0wAkf7eG/C+ldIAub/wM7+hUa97PC6Z/GpRUfVOh8OneHfiJF2q8ChO6HiJIwfS/Luxq/TDjZj6atByw+7cQVGJK19LPJ7ODbf5urbiM8pzUVkj8iH3UQrp9GM1G36hPbsZKqNNIPe+WbIuNR0f 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 hardware has 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. Signed-off-by: Barry Song Tested-by: Chengming Zhou --- 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..fa15df394a4c 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_sleepable(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_sleepable); + 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..88ca33532313 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -204,6 +204,15 @@ struct acomp_req *acomp_request_alloc(struct crypto_acomp *tfm); */ void acomp_request_free(struct acomp_req *req); +/** + * acomp_is_sleepable() -- check if an acomp is sleepable + * + * @tfm: ACOMPRESS tfm handle allocated with crypto_alloc_acomp() + * + * Return: true if the acomp is sleepable, otherwise, false + */ +bool acomp_is_sleepable(struct crypto_acomp *tfm); + /** * acomp_request_set_callback() -- Sets an asynchronous callback *