From patchwork Wed Dec 13 04:17:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13490332 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 39C06C4332F for ; Wed, 13 Dec 2023 04:18:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C15E66B0442; Tue, 12 Dec 2023 23:18:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC6106B0445; Tue, 12 Dec 2023 23:18:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A90256B0446; Tue, 12 Dec 2023 23:18:30 -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 9AC236B0442 for ; Tue, 12 Dec 2023 23:18:30 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 691A0140B68 for ; Wed, 13 Dec 2023 04:18:30 +0000 (UTC) X-FDA: 81560488380.22.B44FB44 Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) by imf29.hostedemail.com (Postfix) with ESMTP id 8A013120013 for ; Wed, 13 Dec 2023 04:18:28 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf29.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.176 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702441108; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ISzr+oekeSfzbnuB/pdKP7H6OO3hIZGytqj6U6LgedM=; b=Cr5Ifo9IvwH4uXvYgBcWifkH11UqZGW3WKUwBP8I7OimP/KWnCNop7xgUw3MablKEDyLWI xNCH+l5yuub2HTHtou6UDSLVLPTO4lG3XUY6OK4XDgN2+rD16Uuxle2L6J536MEXy09BpW pMS4otaIPB96HenGQKjn0qdNRmf28jk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf29.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.176 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702441108; a=rsa-sha256; cv=none; b=6dB+25omV3kw61qywYzJ5ssf/B5136EwgJ0oztfTLoV2IXslIHsq+IMqJ6IiwQlasytcEv +k5Hn5KCMG9IdqvqCipdDGusd2HJKDSPUidVZvJVrI8O7lX0Ic8jRhF2ZcUQ8m5zWCSY9P BsVQa+Z2Y26bPges8/42F4sv1sAqQlQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Wed, 13 Dec 2023 04:17:59 +0000 Subject: [PATCH 2/5] mm/zswap: change dstmem size to one page MIME-Version: 1.0 Message-Id: <20231213-zswap-dstmem-v1-2-896763369d04@bytedance.com> References: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> In-Reply-To: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> To: Andrew Morton , Nhat Pham , Chris Li , Johannes Weiner , Seth Jennings , Dan Streetman , Vitaly Wool , Yosry Ahmed Cc: Nhat Pham , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chengming Zhou X-Developer-Signature: v=1; a=ed25519-sha256; t=1702441093; l=1331; i=zhouchengming@bytedance.com; s=20231204; h=from:subject:message-id; bh=SLwC/l/d7alrAZPMCA93CoRFuL9N61Dk4roVdlkjgAA=; b=FqWQBihVstOvjrBfPRgfiP9wgadr1XURWEFeQL4WfiDUcr3D21m8m/22XnhX+6BfBtu8xruQ4 Mq4yNgcfV1aAyr2EQ0oZOFiKr5LalUHvp2MuUSb5WHaHk5Paq/AcXW5 X-Developer-Key: i=zhouchengming@bytedance.com; a=ed25519; pk=xFTmRtMG3vELGJBUiml7OYNdM393WOMv0iWWeQEVVdA= X-Migadu-Flow: FLOW_OUT X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspamd-Queue-Id: 8A013120013 X-Rspamd-Server: rspam05 X-Stat-Signature: 6at1bd1ujir9xttcmt4jyzy4dyi3gqtz X-Rspam: Yes X-HE-Tag: 1702441108-606478 X-HE-Meta: U2FsdGVkX1/GElEOeAn9SsSQd/0sEj8LyuPhC44Cim0jW6Tc6v/jeQWUYoOx2sfP3OXAHxiQUHnW38th8xUnX752bKmQlf8auos+zS5FWiGqOrgl27j+gy0d3dwO0FHIJ2w4t+sZpBTjLcMZwl+nAcmUMZmid0h+sVGbfX9BpavbAaSU4B+1Uyzi3sdTwUXbLCoIS18uCtLlzwT13u9p+/0liY8DWrm3keDDtIwk8n6ED5mAIlD7wlolwBchO8x0Xf19V2JWlfkj/auhJKdIhldelbZI9Q1MSjvyHYlWlEvN0L14oHPR9wA/IDzFKJuzCtIzQcqyfC10H4b56sTUZnjoR6lNX6V4KgVSWPtF9mt9ZIZoM5CoZwR0MnvDyxcz2INvZ4cd4FvAhT0Z7lTjR6FhM13vwdzLce+DaHlKK/rVy99sGcRwS0en8dd21yJSRHVmV1piYnEe3JXqQFDVKHUxFsoOnMMo+LmWeJi5OFSYZT3xP1d1Lq6UQxO9TcpxuR7fNPt9QUGOAiMu0wjK0FXwapI7xkhiEIWkuc719Oe7u6Ws5SWrdfauWJ85/eXzmYX07Bbcp4QhmqlIDY7ko4vd6qz+XZrZ+QggzT+nud1uxvrB3uI2qkeFLm0g/63TDGXtUXEpIV2SVCmOvcgtA6BokKV0svCqaSOoOgWqAme0QcQaQ+YWHTsABKTURaAVHvgNdPRFtE2Al/jYmKrX9uz8Se+kdTxk7Fb3Q/7RZ8M1CQzkypS9HiWuBdFikBbQNWBB4xn7MNwUHwYiqEeAUTIpCJVSofqno/nCJgjLqjXestrZxFtqo3R+ry5+rhL72w/GGdgVqiYviFbp0Q82VAa+Z/s5n4qBnm+h8Of8xLBzGxX4dSlGWAheA20apX+aa3AaEXPlJ5S8ajHEtGyhTzR1f14iw3ugxdTCIRsK4IzoehiwHdW7kY1/81rTbYzhU3WW2Of+cQsuCKNTAIb AkRfRMlI vSREG57NEODLqYJW3+urqnH3e9+HpxTIKXxuCJnZwzuBnjAtF4JkfY87sVxuLR3LYgw0W4FrYa5imKQPXJOs7/SnB+LQvq6J/AVaG/C5K8MhMXAm89gEGHf04OSc8oVfGagnDrnrXKAfuLQACidnQMUSSydVLNPXOYzMHF6fK87ogQAABrhXSTOr61SslGkyS2UvPPgLlcId/K8pqT3jWpOpe23UAHNFZ+Lhaqxk/VtqBpa87bj1SdXD7dPGrLTG0pz3M7QLGYhyuiUm3ZQonh6jW4pXkvdF835Cgh2k0MxdwtR7PxVpu0zKRnHJkHEgTS/A824s9qMkhYEU= 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: Change the dstmem size from 2 * PAGE_SIZE to only one page since we only need at most one page when compress, and the "dlen" is also PAGE_SIZE in acomp_request_set_params(). If the output size > PAGE_SIZE we don't wanna store the output in zswap anyway. So change it to one page, and delete the stale comment. Signed-off-by: Chengming Zhou Reviewed-by: Yosry Ahmed Reviewed-by: Nhat Pham --- mm/zswap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index edb8b45ed5a1..fa186945010d 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -707,7 +707,7 @@ static int zswap_dstmem_prepare(unsigned int cpu) struct mutex *mutex; u8 *dst; - dst = kmalloc_node(PAGE_SIZE * 2, GFP_KERNEL, cpu_to_node(cpu)); + dst = kmalloc_node(PAGE_SIZE, GFP_KERNEL, cpu_to_node(cpu)); if (!dst) return -ENOMEM; @@ -1662,8 +1662,7 @@ bool zswap_store(struct folio *folio) sg_init_table(&input, 1); sg_set_page(&input, page, PAGE_SIZE, 0); - /* zswap_dstmem is of size (PAGE_SIZE * 2). Reflect same in sg_list */ - sg_init_one(&output, dst, PAGE_SIZE * 2); + sg_init_one(&output, dst, PAGE_SIZE); acomp_request_set_params(acomp_ctx->req, &input, &output, PAGE_SIZE, dlen); /* * it maybe looks a little bit silly that we send an asynchronous request,