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 4B615C19F32 for ; Thu, 27 Feb 2025 18:11:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE6536B007B; Thu, 27 Feb 2025 13:11:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C96CB6B0082; Thu, 27 Feb 2025 13:11:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B84DA6B0088; Thu, 27 Feb 2025 13:11:14 -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 995476B007B for ; Thu, 27 Feb 2025 13:11:14 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4182D1610D0 for ; Thu, 27 Feb 2025 18:11:14 +0000 (UTC) X-FDA: 83166516468.08.DE79E0A Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) by imf29.hostedemail.com (Postfix) with ESMTP id E0461120019 for ; Thu, 27 Feb 2025 18:11:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ZwyyxpOe; spf=pass (imf29.hostedemail.com: domain of yosry.ahmed@linux.dev designates 91.218.175.174 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740679872; 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=Vha+HdJ4Dr83Xx3BxpIJutRU0kj2A2mEZsUp/xMp81E=; b=tb3gqo2MTUnchrrD9zbtU8XoePn13zXfS3zVdK8fUjHuLn5kefsw1O/bNYTX50FVKHkiWA zKPcuGW09/HXyLHQayRrpPyhlDWVMlM+4PSSVhr7H4SqVPBFzozttNJYJuzaEogh1g46Kh 0mLI+XSSNeegeWoEHgVljIIcmPHlhZc= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ZwyyxpOe; spf=pass (imf29.hostedemail.com: domain of yosry.ahmed@linux.dev designates 91.218.175.174 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740679872; a=rsa-sha256; cv=none; b=Fnn85i0VqS04B06RWW35rGF5Wi7Uk15PJ3aD6FfzG7lLJa5MqeIlFlS35wrtG80ppLmliZ sI+pKiIoL6oUehbS9IrtuPb+uU2r0ePOJnSXR4nVCXKJ05srFmxPykm1WtIRu0meFnMyBm FsrJYcc0GYHrC6cT+Qh5Lp368mNbdWg= Date: Thu, 27 Feb 2025 18:11:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1740679868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Vha+HdJ4Dr83Xx3BxpIJutRU0kj2A2mEZsUp/xMp81E=; b=ZwyyxpOee2tTFOQbjqjwolk+7pC7JwCaXFN15Gq8QL5sngiZ7asHtHk5+753QYb93UaGzE R9/5SInf5z9Y/F20jqCIqJYXHQD9dQVxosNm0J6r3f3qiQv44aiia1CPMOTZUpqvaAEXdI CoW+tlNY6xmfDDh3VyYM/XmCgiDJ4q4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yosry Ahmed To: Herbert Xu Cc: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <153c340a52090f2ff82f8f066203186a932d3f99.1740651138.git.herbert@gondor.apana.org.au> X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 6nj5p7d4yhnsdcbw3yqubqd8czbipagj X-Rspamd-Queue-Id: E0461120019 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1740679871-523133 X-HE-Meta: U2FsdGVkX1+lSK2wf8j8pgvpj/X8GkAgPPqVX/Fx/u4xXpUl6vJctZT7OhC9M2FvSL5tDol3TIfm+egEpba/kfwtbF+ZD2U1lZ7HhRxf8/mP4b5ntvZEQibjvcG/O0TmgMnIpFmN7mi8Fp1YWtG1OoPxcpRpPmRe/3xP677gyb0meCTi+bsjrp5S0jh83JFyvikwdAUw0TAZu3EQhyBmSvJzv1cgyIQkdmtgMIa/D/iKDZWa1PYwoBc+09JR++t7Vas27OAMefav+toyy9VkqWPMG52y6yWWUoboUPzN2HsW3ezoYYa5NcJIrHneRK+oG0IkATvVMAEZI6E3pJ9Hfw8h+a2gy74CJEhSulgXvFh0eyNd+bOLtZ9gGgSCppVpNLcPoPSaKRAslqGneV7Ch+eqByxI2d+DEov4S6ubRTd6ElaYuoH8gW/a+PInzNLE1coai29ko87t7HeSPuYFDr/HU06+q0Jghjk/POZl1y1nfpS5ze5Uqd4v5ePZMxrO2LSRx+r30KLA70P5WzAmAP7UvoGDot4vRNIyse332+eJAG50MaG1TRY6fkBnVo3HLm8R3FMmERtAN8heCgzzK20LTOjQAFIM61fun4oHQRdVTamileXVDwoAalxoSfVX18ch16eOcEVaun29V90XqmfqV4SWBf05l2q2FXLG0/10hM8QPdszNQEFipo/sDpJw1og4JRsMRmd4/p1961Ph0rFOPFfQf2egIuw3pk7NUKkkzfa9tvaoqPPam79QlwBc98PS4ubk6yi4lPtQuzNdUFxtAx2ePUqh/o+gZTWUCwrOk1NCLTAwE6LNlqLaG7Vk5IlRnl8HoRDGt0CE0YTseIhhKURm8BX2py96ImcVBOl6FFrBeP6QAL2x2duLA4in9ZbngVBdI8Wr0day0yme6QySrfVnerXmXj8HwY02gxfpor2/UPq5QjMs8N3ls6PwfyHWL/j7pf3YCKlK0D Sq0MyP8/ L1vkBXpyhUsoo0X1KtypQzNXOyBLAhcB+AQxyzeNg6qQU6GrGvtHWor207BAdsYIzsuVE8RL6eAXOifmhG1zxHA5MirYHcvXdd1NGqIHWAi3XV+QnKYZYOv0YMagIr/JwSw+rtdXojmS9401ZcriJSrH8UixgZqC3CjmfXlxSu+s7NE9ZnJTwJ2nBXbc08ASgLrg5cBnwoqnfrYGf0tYkqQ/LDyDki1FDK6N2OgWhsFIsPEADJ+fTP/r3wNvMDotq7ER7hRBhX3vfxpjQO3/WqywYTA== 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 Thu, Feb 27, 2025 at 06:15:09PM +0800, Herbert Xu wrote: > Use the acomp virtual address interface. > > Signed-off-by: Herbert Xu I can't speak to the rest of the series, but I like what this patch is doing in zswap. Together with the recent zsmalloc changes, we should be able to drop the alternative memcpy path completely, without needing to use kmap_to_page() or removing the warning the highmem code. Thanks for doing this! > --- > mm/zswap.c | 23 ++++++++--------------- > 1 file changed, 8 insertions(+), 15 deletions(-) > > diff --git a/mm/zswap.c b/mm/zswap.c > index 6504174fbc6a..2b5a2398a9be 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -925,27 +925,20 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry, > struct zswap_pool *pool) > { > struct crypto_acomp_ctx *acomp_ctx; > - struct scatterlist input, output; > int comp_ret = 0, alloc_ret = 0; > unsigned int dlen = PAGE_SIZE; > unsigned long handle; > struct zpool *zpool; > + const u8 *src; > char *buf; > gfp_t gfp; > u8 *dst; > > acomp_ctx = acomp_ctx_get_cpu_lock(pool); > + src = kmap_local_page(page); > dst = acomp_ctx->buffer; > - sg_init_table(&input, 1); > - sg_set_page(&input, page, PAGE_SIZE, 0); > > - /* > - * We need PAGE_SIZE * 2 here since there maybe over-compression case, > - * and hardware-accelerators may won't check the dst buffer size, so > - * giving the dst buffer with enough length to avoid buffer overflow. > - */ > - sg_init_one(&output, dst, PAGE_SIZE * 2); > - acomp_request_set_params(acomp_ctx->req, &input, &output, PAGE_SIZE, dlen); > + acomp_request_set_virt(acomp_ctx->req, src, dst, PAGE_SIZE, dlen); > > /* > * it maybe looks a little bit silly that we send an asynchronous request, > @@ -960,6 +953,7 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry, > * acomp instance, so multiple threads can do (de)compression in parallel. > */ > comp_ret = crypto_wait_req(crypto_acomp_compress(acomp_ctx->req), &acomp_ctx->wait); > + kunmap_local(src); > dlen = acomp_ctx->req->dlen; > if (comp_ret) > goto unlock; > @@ -994,9 +988,9 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry, > static void zswap_decompress(struct zswap_entry *entry, struct folio *folio) > { > struct zpool *zpool = entry->pool->zpool; > - struct scatterlist input, output; > struct crypto_acomp_ctx *acomp_ctx; > u8 *src; > + u8 *dst; > > acomp_ctx = acomp_ctx_get_cpu_lock(entry->pool); > src = zpool_map_handle(zpool, entry->handle, ZPOOL_MM_RO); > @@ -1016,11 +1010,10 @@ static void zswap_decompress(struct zswap_entry *entry, struct folio *folio) > zpool_unmap_handle(zpool, entry->handle); > } > > - sg_init_one(&input, src, entry->length); > - sg_init_table(&output, 1); > - sg_set_folio(&output, folio, PAGE_SIZE, 0); > - acomp_request_set_params(acomp_ctx->req, &input, &output, entry->length, PAGE_SIZE); > + dst = kmap_local_folio(folio, 0); > + acomp_request_set_virt(acomp_ctx->req, src, dst, entry->length, PAGE_SIZE); > BUG_ON(crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait)); > + kunmap_local(dst); > BUG_ON(acomp_ctx->req->dlen != PAGE_SIZE); > > if (src != acomp_ctx->buffer) > -- > 2.39.5 >