From patchwork Thu Nov 21 22:25:20 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: 13882403 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 D4F24E64039 for ; Thu, 21 Nov 2024 22:26:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CB206B008C; Thu, 21 Nov 2024 17:26:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 57BA16B0092; Thu, 21 Nov 2024 17:26:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 443816B0093; Thu, 21 Nov 2024 17:26:29 -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 224D76B008C for ; Thu, 21 Nov 2024 17:26:29 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9DB6EA08C0 for ; Thu, 21 Nov 2024 22:26:28 +0000 (UTC) X-FDA: 82811536122.18.1AEA320 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf30.hostedemail.com (Postfix) with ESMTP id 2755180016 for ; Thu, 21 Nov 2024 22:24:45 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KetEBzxw; spf=pass (imf30.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732227782; 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=bnUtikKG6kYaTFvoCtF8la8TvUYmRutVMcxq2kAfDzs=; b=Pr5UI8NuMaguIQJEeNV+59i1Rjida2vQqmv5ckYT/wrTJOJ02+3v1gZMCg88rzxzV7rcTz 0jaoFsWvmLdRl6SG1M7Q9LjNHHmukyJy/xIArr1Z/Y+oxLQhBmIeTDDsEjrVhnClaXjtVd WlsqCeypoTQkFVLfAQ6CdtTUA2agAoI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KetEBzxw; spf=pass (imf30.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732227782; a=rsa-sha256; cv=none; b=5dYMnhnSsW/+ofET674bj4v2tHcrjgVJ+GZ+2snFcBZ6i5fBkkiaT9yRqL+cXxcfENByar 9vkRcUb2IehInlS6jMVIGtCMgqcf4KANiLex9T7304CB8oEwZmzmnbrMpM/sMuVDhCL32G BgutIb3LJXCOsxZHJapfJgTL6PAW0Zg= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-21271dc4084so14527865ad.2 for ; Thu, 21 Nov 2024 14:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732227985; x=1732832785; 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=bnUtikKG6kYaTFvoCtF8la8TvUYmRutVMcxq2kAfDzs=; b=KetEBzxwrqvW8Unludl+rHmbnuXdi+f2rTACFlydmxz65KxkQUzsj+OsEuEYSdYVla Cz94XAQKNtGlJYjxpgauUQeUf7Rkfu7jF5hLmrz757nLbfPaTtc6+lnhRqQTOAgDL6T0 hAyMOI3ZxSsT8qrHnDHSOIRSCQtK3GjcGTjeR799m5RgBitwG4Gnhem3Y+8BIqq3a6/N VIXAY5QTcCWrtRjVovnXdDs6JnXJ+DE7FhsxmT/PmGD/f7k4K+YoA1Lug+J6abS6WO5i 31+TGz7syAOSSA4Xq6ZwLZR2KZcY/NnhRdAo7TLsPMz9pZSx0Zaz7G5X70qO+xXgGsqP zQuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732227985; x=1732832785; 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=bnUtikKG6kYaTFvoCtF8la8TvUYmRutVMcxq2kAfDzs=; b=ptv42pNAu4piDKmhVDWmiBjiQez2Say/bAr9VU6wfmlzJXn6N9MYnCZOZ6kHxHxDFU 2jvY+QHRTvig9FS3vOGQdaLUZs1lMfL9+97rW0AUcZ3Acz/85IVhFfSdL36Z/MowVAaY 7t5/+eyQwau6qTZNgYa2ZWQ/zCWagh3l9p2Zypi5ArllzXLvGV3X2NlE7THkT+fkD2WB F3NB19pbJAvXKf5Lua+xOiQXlR+1M2leCuFggstwbvkoEy24px9QpmLfmOb3hDAptvyC 8HmwOICJS2irv4mKJknDx+yLxVbrd4YjlS6pWI6Ww/lPp4FuNcLPFh6micw/XHuuaMt3 z9hg== X-Forwarded-Encrypted: i=1; AJvYcCXxv7QBtTVKjpqPZQgXTlqgirsZwjUnHq3XMQr11JjLcA3SXT8lvu+sdbDxU70HHrLCS8AgPrGoWA==@kvack.org X-Gm-Message-State: AOJu0YypZaA2JGRcMdod2gUpWHK2p+2vspEiCilRPTH2ljLSWcg6hJOJ AMKaovhyU9IvyBPMLhJ1WC6a5D5cbsjqs1S6x0kg/Q8SSO7g7BtOu08pLQ== X-Gm-Gg: ASbGnctTq4GSaviZbo9lW9bu8HK1OCzBRmbcDG2mMgH5dSmjqAs+/ORqIK0IWK6oxUW w8HBu5rldsuyAQ9y4h9hK4eWNsAnMrEGP+U7Q/AHnWXpAtU3XPz8Dpe+qmCTWhWbEscVEZHuBdK tgSKQUojB/tIer92zxSNBBn8PIZ1PHuwrCOyzvxlPKyGUiRLZTEeFvysPB7AW0lfJXvxbm26TJJ hM2DGYI4+o1KAlDnsM8b54XUMmJzZjQmxMVJSfgroYfQPu9AMF8186Pj7FsoK6uiGhQ37NB X-Google-Smtp-Source: AGHT+IFYXTSN4Arskmw5br0QxBuvikrOLITGUKeWiVS90/P9GJacujBndu+rNI50ulwvEXnP/KRJnA== X-Received: by 2002:a17:902:f646:b0:20c:b9ca:c12d with SMTP id d9443c01a7336-2129f6807d4mr7603135ad.38.1732227985525; Thu, 21 Nov 2024 14:26:25 -0800 (PST) Received: from Barrys-MBP.hub ([2407:7000:8942:5500:9d64:b0ba:faf2:680e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2129dba22f4sm3334745ad.100.2024.11.21.14.26.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Nov 2024 14:26:25 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: axboe@kernel.dk, bala.seshasayee@linux.intel.com, chrisl@kernel.org, david@redhat.com, hannes@cmpxchg.org, kanchana.p.sridhar@intel.com, kasong@tencent.com, linux-block@vger.kernel.org, minchan@kernel.org, nphamcs@gmail.com, ryan.roberts@arm.com, senozhatsky@chromium.org, surenb@google.com, terrelln@fb.com, usamaarif642@gmail.com, v-songbaohua@oppo.com, wajdi.k.feghali@intel.com, willy@infradead.org, ying.huang@intel.com, yosryahmed@google.com, yuzhao@google.com, zhengtangquan@oppo.com, zhouchengming@bytedance.com Subject: [PATCH RFC v3 3/4] zram: backend_zstd: Adjust estimated_src_size to accommodate multi-page compression Date: Fri, 22 Nov 2024 11:25:20 +1300 Message-Id: <20241121222521.83458-4-21cnbao@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241121222521.83458-1-21cnbao@gmail.com> References: <20241121222521.83458-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2755180016 X-Stat-Signature: uaf7pjkqqnyx9w1wkzsk694ewbqdj18f X-Rspam-User: X-HE-Tag: 1732227885-439709 X-HE-Meta: U2FsdGVkX1+4W3etEgOY7qCVubKVeCFpcQGeJhYyiiVnmZrv2MYPo7JM6y7g3M0lOKb+jchGeEoKiTdTTMksxiRK6WVgVW18/VPqHlEQBHwYnIImCJTCcrh8WVyF2i0AVnDaZC7k6iha5aPKmm+Gqmf9kwXkrF4DqyaGW1QyYgxiRR3cmF3/iatQuncSW/lOZ6zlSlgGfy5MxDJORPgco6Wic0I8IKL49EkUvp1cRyEVVSCs8Rq4RsV3rFTiqL8dHVJNjlYJ0PArgUIxrObpGpTlI+lKIW6rFY86AXMbse/7bBK4JrbUSECSJU+DEKdREjoiMY+qe6nJGkiSV+AN23UNTXl+GLDn99Sj7VeeTunHuSIFzsz2Y2GVIkg8eOORpcnYzPThGcRInE6O5ULmCVuwpHrC6fk4Sx5fucw6BCwvMnqHJCWkqtiETCcTqIRJa7+yOkn4sAg4p7aDpgbujFj3krsvzaX331nM+XiIGxcZ9y2Gi0NU1X9/U5IbcSMYlbyc62mgUJlZI5IZaWus7vC5yFoRHAgauS4q9kzrQI+okjwiP+4g1o+nMxGEAYAW5/ZJ66LFqe6aaYAZAEsyalmjI/o/fOOeVaX6E+CXydw7uGOBGa4yw7tysy6hp4+fvhiZha3bPKXX+AE6pU+dk7Jc23EdiEvwIIC7YAHtD43BztLm6fpT25Sa3SjYUWvJOCXEX3PGH6BVQVVEo17kcUnlpcEDSrkS5SGEshQmYlZZx4U87jxnuRZ0chMWaXF/5WdpK8dmdjPiqYDuvygQtbLIYuGPbRjnktKcY3AqWsG7wKAVRyk+vX5bJt0Bl57DjuaL/XuL5Bn0hvGyeQC6Uz3br/iI0FpsnqSuF+KU2DwQZw2zQHBoj4KiDMfaU5C5mCOWt+PMk+PLpptCycpJGowdv0L/lxALv2Ov+Q4sI5hQbGNwLLqEaCJe3V5hn4c1EUSrww696vQWGmGR4kK +fW+J0Vq x4yJWzVdGFZGWQTEBTRwT4oMotWIyOBP+gH/u05KwCMSgNASV8Ruy1HEbYNG7UX0G4VF7BLWxLE0apF9oviQ4bRGtwwl4XSRcGT+s3D0onFPxgk6RIZ++herFFk6vdY1/llkbcgOrrhxdOWURISRPw33pbeh+WE2WoaaJ0y7zPyvpOP/6RYmt5mxlZhSIMU266AyJAqafyilSC1aDez9wWxOCOwJo99UW5gO0avhZAwDY0ussFGiwbaqEtbXZMujP95ogQP8qeOkskTKvvUyDtz040+CFHinshUHIxll8uY5Y28NYrHmOWmNeXbttwVC905P2/XqBOpehLN8x3Yay8PdD3eY3YkO6odmJw2dCq3NovIg3bNNKenlCaRR+HQ44ouUfB8DVXXaJBqzfqOrak+8q2j7Ng/+CLpjFWTQbQVhq0svNcmLviWsdZCejZrd3JUbMdba2jZ1yqm4U5zile+GilA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000770, 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 If we continue using PAGE_SIZE as the estimated_src_size, we won't benefit from the reduced CPU usage and improved compression ratio brought by larger block compression. Signed-off-by: Barry Song --- drivers/block/zram/backend_zstd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/zram/backend_zstd.c b/drivers/block/zram/backend_zstd.c index 1184c0036f44..e126615eeff2 100644 --- a/drivers/block/zram/backend_zstd.c +++ b/drivers/block/zram/backend_zstd.c @@ -70,12 +70,12 @@ static int zstd_setup_params(struct zcomp_params *params) if (params->level == ZCOMP_PARAM_NO_LEVEL) params->level = zstd_default_clevel(); - zp->cprm = zstd_get_params(params->level, PAGE_SIZE); + zp->cprm = zstd_get_params(params->level, ZCOMP_MULTI_PAGES_SIZE); zp->custom_mem.customAlloc = zstd_custom_alloc; zp->custom_mem.customFree = zstd_custom_free; - prm = zstd_get_cparams(params->level, PAGE_SIZE, + prm = zstd_get_cparams(params->level, ZCOMP_MULTI_PAGES_SIZE, params->dict_sz); zp->cdict = zstd_create_cdict_byreference(params->dict, @@ -137,7 +137,7 @@ static int zstd_create(struct zcomp_params *params, struct zcomp_ctx *ctx) ctx->context = zctx; if (params->dict_sz == 0) { - prm = zstd_get_params(params->level, PAGE_SIZE); + prm = zstd_get_params(params->level, ZCOMP_MULTI_PAGES_SIZE); sz = zstd_cctx_workspace_bound(&prm.cParams); zctx->cctx_mem = vzalloc(sz); if (!zctx->cctx_mem)