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 80029C021B8 for ; Sat, 1 Mar 2025 06:37:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BAA06B007B; Sat, 1 Mar 2025 01:37:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76B91280001; Sat, 1 Mar 2025 01:37:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 659726B0083; Sat, 1 Mar 2025 01:37:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 47D826B007B for ; Sat, 1 Mar 2025 01:37:13 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BA87D121AB1 for ; Sat, 1 Mar 2025 06:37:12 +0000 (UTC) X-FDA: 83172025104.12.5E1D029 Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) by imf14.hostedemail.com (Postfix) with ESMTP id A11F9100004 for ; Sat, 1 Mar 2025 06:37:08 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=hmeau.com header.s=formenos header.b=Yv4zlEw3; dmarc=pass (policy=quarantine) header.from=apana.org.au; spf=pass (imf14.hostedemail.com: domain of herbert@gondor.apana.org.au designates 144.6.53.87 as permitted sender) smtp.mailfrom=herbert@gondor.apana.org.au ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740811031; 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=S4bx2Z1yms0ZFfWUbn4bypEMiaaAt/OjXQd+TmsxwKs=; b=S84tDxmlCrDlrKirXyPniIRWjwkmcB22YZPITd0JlLvLs+A7TT4lzCKtzKJRoi21kwUIYz M1QCsFZGNXHPE62zSqEpGOaT+HsGfp7okGfh3uFBhPbqkO4d9xre9q1rMxdC0pH9wTw2PE WaMNOcj6Sx12/aL3mBhKw3VQ71ISjuI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=hmeau.com header.s=formenos header.b=Yv4zlEw3; dmarc=pass (policy=quarantine) header.from=apana.org.au; spf=pass (imf14.hostedemail.com: domain of herbert@gondor.apana.org.au designates 144.6.53.87 as permitted sender) smtp.mailfrom=herbert@gondor.apana.org.au ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740811031; a=rsa-sha256; cv=none; b=eO6+HePWDZw/C0BfsOlsZJgZkQu+EK6BSleSyYpVJfYtX+7943kDm0BlehVsflaRL6yQcJ Wkh0bWDFNFk7VTPaTKtCIuOudkUryps1JLlBtAs2v3nM8vt0ChwNCO7Q/VYeyyVlxvfmxB 9tDCoMz3iLWqL62po2sI+NjEzSCQOWo= 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=S4bx2Z1yms0ZFfWUbn4bypEMiaaAt/OjXQd+TmsxwKs=; b=Yv4zlEw3p+0nHyfgHbg6tDWgQl /uFwUc2uP0x/NdVQl2Ryg5QHt2SXYtDsT9iUMvJIDaoxwKDWlam7WFvb1moACpSi3j5O+2YuYBDYX ZqqUI7bvx18qWhRnOkTvC6QMbsBmRmnxB6IFpaND0HgZmfnWfuvEUK7qcqxx+WLMKqZPN+DZIjltB TCAIPLXqnQNwH5CnDsX6WJohd9aQouOIeAcncQnC75iHTU6utkvX23Xdoij6930o06WJRCAN+tNg3 uiWcgBplDz34unedwBhNud8cUUNtOl/gTJpXUAtJ3I+VYAfihkz0zgaLTF0Lldf0RpoEZu3hUBt4n cYmF1VQQ==; Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.96 #2 (Debian)) id 1toGSw-002mAi-0P; Sat, 01 Mar 2025 14:36:51 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Sat, 01 Mar 2025 14:36:50 +0800 Date: Sat, 1 Mar 2025 14:36:50 +0800 From: Herbert Xu To: Yosry Ahmed Cc: Eric Biggers , Linux Crypto Mailing List , linux-mm@kvack.org Subject: Re: [RFC PATCH 7/7] mm: zswap: Use acomp virtual address interface Message-ID: References: <153c340a52090f2ff82f8f066203186a932d3f99.1740651138.git.herbert@gondor.apana.org.au> <20250227183847.GB1613@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A11F9100004 X-Rspam-User: X-Stat-Signature: 71k7t81ejjw85ggwce1e7j77d14twjt8 X-HE-Tag: 1740811028-31623 X-HE-Meta: U2FsdGVkX18oAE7bILW+87+YnQiqWrzZUNCU8Zk1xjkblFbuuq2QyE3AslTSHp0WaEqn9+tTMMUKvTmBz4uI/Qc7jn+RDmdEllFTJ8QEo5nNjJ9shCnjsTs6qS7ojtNuhYFAhxuChm/n6dwnvIlghika0a9Piiqg9+TFSAFyZ/1AMVRzyVU12Iuf6g7ED6cJLpi/BxpdzrRBxyK+2I0SI3Ok+dIM7H6LRW7iLR9aaLFyjHrCRwFX1sxCIIZGE2a29GvoGZSECeLTxwDQCFOmtvkMF7DC8q6h18jU+LmWrQ71rSUZpeRkLvcaPMBdUIilHqChophyD7pgXFELhQ0d+IrxY4e3omB141eQOZwD7HUpXUfoB3G7v3kV5b9jvoCUUk1xUPsuNULhe9sm19J5J0+Soxq/tFxSRFVWzdB6iWtkSdAQMjNF6+qsPvpBbxrQ6Emogf63T1uYsKo9MTg+PnFmofuH371x8zle1ORFiztmBxUaokRZ6SXFS2U/VBUWHlIWtK1ig3HzXKwpTX2W/YWmgG8UcXen2tdoeBsa/B3GytiOT0OjUtU7xboTHF3mIzpdgmJl0TbxuDj+4MLx/eEyIserkfygCXHQv+Dq78FfFWb9XQf3SOpWztDjDLTWFBQT+P/bS1zw8Z5kbQGd/pp7MT37uwrXL9EQORIpD7CGdc8E31+6f1X+W3zscWvxJv/ZZxR/1TPlydvYD86DngMKc9I3zPLJ+8bBt9CPsULYIZRrTEnQX7i/jao9zbGyma2O4X5hIytopmAUxyrrBgNZf5Ie6/QWTeV6O2jtklTtYgC4yqsOY+JyXHUJ65VIr/P15EgN6wj2XgkCQ3AmQQ0FDmCq2r8Fl8MkyazbB/z/DNHYrrfQzA+7SpmuDT4RkIqVybt7OlPxY1D2pbojhyBPW+I6af3wqtpAmoC7Bdbo7CLaU2dCH90H4JqQrN1KOe7GdWp92ziKZKFLEwK zRRSSODN M9m6cTsgS/91YYXEBk2ou1XLmBo+7a5ewiioPI8OJsYuRUDbyhR8/4WHHG+3NRymH/rhKueVu2j162tXTyWehhm98tAp6Pg1E+5rNKPhgkJGUwHpNMnkCHjA6o6U9eDwz9fTkc3dFT0lTWamBmDrztZoLqzbwyoNRHgeaSi9T7pNW+njQMbzwmx4FWLTszabvdEPDTUYB412R66feHA+3ZKB5VlXlkDKyCulTfwzwfn0MShcPhRkNmtLO/QMU1/4x2NCmfNPEzkd2Rkg= 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 Fri, Feb 28, 2025 at 03:56:42PM +0000, Yosry Ahmed wrote: > > Why is the acomp_ctx->is_sleepable check no longer needed? Because the Crypto API knows which driver uses DMA so there is no need to check that here. All the API needs is for you to tell it whether the memory can undergo DMA. > Also, the zpool_can_sleep_mapped() cases will go away soon-ish, so I was > kinda hoping that the !virt_addr_valid() case goes away too and is > handled internally in the crypto library. Right now the problem is that > virt_to_page() is used to get the underlying page, which doesn't work > for kmap addresses. Actually this check looks buggy. The issue is that there is no way in general to tell whether a given pointer can be used for DMA or not. You have to go to the source (e.g., is it SLAB, vmalloc, or something else) to make that determination. So there is no simple check that the Crypto API can do to determine this. We have to rely on you to tell us whether it's OK to do DMA. Otherwise the assumption must be that it is not safe to do DMA and a copy is always required. Now of course this is all irrelevant if you use software crypto that does not involve DMA. So regardless of whether you can do DMA or not, if you're going through the software path it will just use that memory as is without any extra copies. The difference only comes into play if your request is routed to hardware offload. In fact it looks like this check and fallback path is wrong to begin with. It's perfectly OK to do DMA to high memory, assuming that the device can handle it. And if not the device would need to take care of it anyway since an SG list can always live in highmem. I thought this was a lot more complicated and you had some weird arbtirary pointer from an unknown source. But if it's just highmem I can get rid of the memcpy for you right now. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt