From mboxrd@z Thu Jan 1 00:00:00 1970 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 A592BC021B5 for ; Sun, 23 Feb 2025 03:39:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05A326B007B; Sat, 22 Feb 2025 22:39:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0097E6B0082; Sat, 22 Feb 2025 22:39:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E135C6B0083; Sat, 22 Feb 2025 22:39:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C4CE16B007B for ; Sat, 22 Feb 2025 22:39:04 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4431B121F93 for ; Sun, 23 Feb 2025 03:39:04 +0000 (UTC) X-FDA: 83149803408.18.03A3F5C Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) by imf01.hostedemail.com (Postfix) with ESMTP id 079AA4000D for ; Sun, 23 Feb 2025 03:39:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=hmeau.com header.s=formenos header.b="o43E/SPJ"; spf=pass (imf01.hostedemail.com: domain of herbert@gondor.apana.org.au designates 144.6.53.87 as permitted sender) smtp.mailfrom=herbert@gondor.apana.org.au; dmarc=pass (policy=quarantine) header.from=apana.org.au ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740281942; a=rsa-sha256; cv=none; b=zn/n9CIZs3zbyvs1nDZNG7VLjl0sLo7X7jCTdPXAVYBoWG6kEd0unOK0MC2zfQX/oilBm7 AaYKZuTmIVduW1ylByD7ErzWJ8XG9bg2qtlnOGOGvo1N1V/UTpXzVhwD5Zg8owQtdAsXs8 lOdbPLQzANA8bdEUzUWzCm9SM1hcn+0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=hmeau.com header.s=formenos header.b="o43E/SPJ"; spf=pass (imf01.hostedemail.com: domain of herbert@gondor.apana.org.au designates 144.6.53.87 as permitted sender) smtp.mailfrom=herbert@gondor.apana.org.au; dmarc=pass (policy=quarantine) header.from=apana.org.au ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740281942; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=inMAqLykdkLVqUlvbXLCaPY7up9uFvAXIhqrJX83y7s=; b=me03cIAq6DG5ort7THQoIWpZ/UHNOvmnx5DrPZCcFOL1iqafcCTTWUB3n5p3Lr9DgP+gdj 8W+z16T1/fLRh/Ep2khoS8VbrVibY7wM1c4MyjeprcLkxOsyR1u67UHULaZ1kEXmwww/qh gXzDEInPP96iACd4V4pS5/sO3pp1NlQ= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hmeau.com; s=formenos; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=inMAqLykdkLVqUlvbXLCaPY7up9uFvAXIhqrJX83y7s=; b=o43E/SPJL6tIZouDL5DLBOuz4f 0fiqNxq4PiXn3GV1FB3nHWE/goITIN55iceOiF/Eu3yHhDaL8woQZZSoaMegw1H2Y6thyucjxi7cl XXeoddwNHOUqoNpbcLumoQSfcK201BKzLpSYcd5ktJJDmJtrUF/+6Lu6bwYG/XFUX5+dtJoeiI6tz 9FVkXRNIgVtoMibBdyIEwOQ3ctl9SJCKjVjBpukkjf5cBCSU3DU8OrARH9/s027F9IBY8Twer01/A L6hf/elwtQvT6NdfwKYk9IR6cRlttPmSJFrWrOhx4vQumTU9tnmiMv/ZUQ3UYf23pZnGyT/qw9dhv 2H0geh8A==; Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.96 #2 (Debian)) id 1tm2pU-000xZl-04; Sun, 23 Feb 2025 11:38:57 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Sun, 23 Feb 2025 11:38:56 +0800 Date: Sun, 23 Feb 2025 11:38:56 +0800 From: Herbert Xu To: Sergey Senozhatsky Cc: Barry Song <21cnbao@gmail.com>, Yosry Ahmed , Minchan Kim , "Sridhar, Kanchana P" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "hannes@cmpxchg.org" , "nphamcs@gmail.com" , "chengming.zhou@linux.dev" , "usamaarif642@gmail.com" , "ryan.roberts@arm.com" , "akpm@linux-foundation.org" , "linux-crypto@vger.kernel.org" , "davem@davemloft.net" , "clabbe@baylibre.com" , "ardb@kernel.org" , "ebiggers@google.com" , "surenb@google.com" , "Accardi, Kristen C" , "Feghali, Wajdi K" , "Gopal, Vinodh" Subject: Re: [PATCH v5 02/12] crypto: acomp - Define new interfaces for compress/decompress batching. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 079AA4000D X-Stat-Signature: 6adeent41mamcydk9xqfdm88tbsk44kf X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1740281941-818650 X-HE-Meta: U2FsdGVkX18pY0eGlPWdvZ6oBr89/BEH2UZDG72MxEGlC4DER5ey/8a9JvDOm4C0mD2aEYB9eqAv2Zk+5Z3/f3ABmHU8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OcMM/dKpv0tNiijNLaiMMo88DaZeskvgF3PIZSahp7QZiAIp7JOL4Dr/o7HWlBFjDHVLX97ftJeWCFSjj9npXcLsieqAmrpFnbPdu1ohOFeWml+Zizs328XAIePsSCaeAjb/o6gvABtGSwm+w== 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: On Sun, Feb 23, 2025 at 12:12:47PM +0900, Sergey Senozhatsky wrote: > > > > It also seems that there is no common way of reporting dst_but overflow. > > > Some algos return -ENOSPC immediately, some don't return anything at all, > > > and deflate does it's own thing - there are these places where they see > > > they are out of out space but they Z_OK it > > > > > > if (s->pending != 0) { > > > flush_pending(strm); > > > if (strm->avail_out == 0) { > > > /* Since avail_out is 0, deflate will be called again with > > > * more output space, but possibly with both pending and > > > * avail_in equal to zero. There won't be anything to do, > > > * but this is not an error situation so make sure we > > > * return OK instead of BUF_ERROR at next call of deflate: > > > */ > > > s->last_flush = -1; > > > return Z_OK; > > > } > > > } > > > > Z_OK is actually an error, see crypto/deflate.c: > > I saw Z_STREAM_END, but deflate states "this is not an error" and > there are more places like this. That would be a serious bug in deflate. Where did you see it return Z_STREAM_END in case of an overrun or error? > So it will ENOSPC all errors, not sure how good that is. We also > have lz4/lz4hc that return the number of bytes "(((char *)op) - dest)" > if successful and 0 otherwise. So any error is 0. dst_buf overrun > is also 0, impossible to tell the difference, again not sure if we > can just ENOSPC. I'm talking about the Crypto API calling convention. Individual compression libraries obviously have vastly different calling conventions. In the Crypto API, lz4 will return -EINVAL: int out_len = LZ4_compress_default(src, dst, slen, *dlen, ctx); if (!out_len) return -EINVAL; Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt