From patchwork Tue Feb 20 06:44:12 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: 13563466 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 390C6C48BC3 for ; Tue, 20 Feb 2024 06:44:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEC466B0092; Tue, 20 Feb 2024 01:44:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B9B1B6B0093; Tue, 20 Feb 2024 01:44:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3C056B0095; Tue, 20 Feb 2024 01:44:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 90D576B0092 for ; Tue, 20 Feb 2024 01:44:42 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 64955160581 for ; Tue, 20 Feb 2024 06:44:42 +0000 (UTC) X-FDA: 81811244004.05.886E70E Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf15.hostedemail.com (Postfix) with ESMTP id 91BABA0011 for ; Tue, 20 Feb 2024 06:44:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BkdOxi0A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708411480; 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=VwTIFpBnJrjGyIT/20HYU3RPVaQg5c8zhvFCBIT6Ljs=; b=AiVQCofWblk+ywrqb+gfIWlSfnwfGQ3POCDnh2JFVbdOdP1nz+PebIudUeCvbqtHHW+Vf2 kszKpqoar7Oq0mJFbksq5mW5GmrkofvG2HSdHTYv9mX6QF8PGi5FbhWNX2yaAy7wfdMIoz U1S3hqLwaD24AXCehWJ256CQl5HJeD4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BkdOxi0A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708411480; a=rsa-sha256; cv=none; b=CuL6QN2ahfmqSWI3jtU50OxxW7MWk48dM5zFdecv7kfY2OqzM+XKukrnlxpG7O0YXn/A6u J7icmRz+Rpdl7Pf1/agGX6CIflWTNgnHm6YCPGijRRfwGsm5Ssu43HUCHvyAery9DiUZIq AVxZ1yMHO7WpZcFbuBw82EFgSUcQJuE= Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d91397bd22so42898945ad.0 for ; Mon, 19 Feb 2024 22:44:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708411479; x=1709016279; 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=VwTIFpBnJrjGyIT/20HYU3RPVaQg5c8zhvFCBIT6Ljs=; b=BkdOxi0Aj2l0yyxprtBIC8GZSwb7Pyds22Uw5gUnBApsuL+YclB2c4GcClnaE99jml 3CXXiO83tVlDjki1D1Ry7kZ+29DwQIlMlU2afjPM+2UtBELCgJ+xoQJPBhlGFa7CbXq0 H0zcITyTPs7vcbeiI/Yscyr8HowjmODP7RIJ4uhCd0BEMBeDztKMob7Af3TZsYmr0FEs VzD4W6GDF9UUE59cpTuegeZDTMgzCq8bAd10HJ8lPOoOri/ynUK/ZwEOHJt3nChUD1Fm Iyk2vU9WqRcyaFKlpiMko3g6mr8Q68+OFUd9X9johUZurqjUiArIxmN2MOoE4uNKeLKr rNlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708411479; x=1709016279; 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=VwTIFpBnJrjGyIT/20HYU3RPVaQg5c8zhvFCBIT6Ljs=; b=oPwosTjYU8wmZLxEXcPkUeIk5Y3GUjF6Kj4lxbPnGDRihMhTgc77Tgi1wiK5U0tBq0 KvweRhOGCjUiwkWFwBwO4s9Tj9QIYK0BOiobm9XYVX0NR7jPxfdjJClNMpEiFNgARBjo uCre1iEsrOYrzaA8r6IIrDsEhqpclLlkHzr/sM4L6L7DYZG/mxO5JzaNpUAEIHb4L9bL BwEEIiXhYHbiIqoQubZUE03EVFbWzhNq0jeDN4GajOVlRJ2z/Qky7Vc5FqMum3Nxcrhw XgH5/STFvQk2idrsaLsYFZ9Jcbh//SZth6xfTxXANI7nxdp6ZDA6blk47S5kbu1DBIfJ RS6g== X-Forwarded-Encrypted: i=1; AJvYcCUXlsrfSIlX9PgxKB97o1AaSQEkq6yKBEb3zy9tYvo1ywtWImyweHawt7KiAa8ouIV6NwkXx1zMtY0X5ohGlEFQkSI= X-Gm-Message-State: AOJu0YwebhBHQz2XfOzQyXBreaW1TelxaBa1tEXgiiqaTh24HPF45O9G C3U5eWosOFtpZEIcUxNOs057kmMyq64R5x/22wzFvF8Opb3lDUbO X-Google-Smtp-Source: AGHT+IGai50/e9Dq4GggyO4YXfBocAVgdbPmMRi2mn4PPi0R3OTzklhwKOf6W7+VfocVSf50DBd0sg== X-Received: by 2002:a17:902:dac8:b0:1db:cea0:9d62 with SMTP id q8-20020a170902dac800b001dbcea09d62mr7790208plx.9.1708411479355; Mon, 19 Feb 2024 22:44:39 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:a5bd:9c11:af2b:aecf]) by smtp.gmail.com with ESMTPSA id w16-20020a1709029a9000b001db60446abdsm5419090plp.262.2024.02.19.22.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 22:44:39 -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 v5 1/3] crypto: introduce: acomp_is_async to expose if comp drivers might sleep Date: Tue, 20 Feb 2024 19:44:12 +1300 Message-Id: <20240220064414.262582-2-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220064414.262582-1-21cnbao@gmail.com> References: <20240220064414.262582-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 91BABA0011 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xcwqge9qj596yrqiiwxght5zgj6exe6y X-HE-Tag: 1708411480-319834 X-HE-Meta: U2FsdGVkX18kupH/XgfIl4s9MeTEsDfpgDutrGkDuXBbNPAq3vB4tA1PV+ygxPlLG/eKqBU6bbhf65RmBoOlHTvktxdDJs8jXAxrVqOyMdAOZa2FOh1P5o5buYETtkjA5KebcsL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y1IfFw/IBujybtqcTWPFOivAj0KUY7cvB85JfIcLQB5Ez7NA3G0L5Q0bvjpWzQBcThb8DWoZeyN/RDKQ8bHKAdbbjp2Yo7YjRyqK3aUC1oQj2T2ShbPnt9sgKlh+OW7LfI3PdqrHfrkbUfyUoDsZw+t2iUqDMA/v+H0UT2wyHmcW+ii61G5mjx/i/h0/qu6tshSjYRnswZeWo0IiGX5antFqzArSuU2re+UCI8CZaA1hzagRIJNhEHs4x8qorN5VuO3C+AWFyhZC9GPVUkXygRKctNNPrp2Jh0mt5tCmEidtl/3rlIe13QKUQDONyfYlxggay4flu 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 --- 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);