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 71C47C0219B for ; Tue, 11 Feb 2025 17:53:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9CA066B007B; Tue, 11 Feb 2025 12:53:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 97A026B0082; Tue, 11 Feb 2025 12:53:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81A816B0085; Tue, 11 Feb 2025 12:53:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 630C36B007B for ; Tue, 11 Feb 2025 12:53:28 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2AAF3120786 for ; Tue, 11 Feb 2025 17:52:46 +0000 (UTC) X-FDA: 83108409132.02.64ADE24 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by imf15.hostedemail.com (Postfix) with ESMTP id 320A9A000D for ; Tue, 11 Feb 2025 17:52:44 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OzYKLxBN; spf=pass (imf15.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=nphamcs@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=1739296364; 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:dkim-signature; bh=alxnJNPbq/1DdW4EjlxryX0UCz6LPOMWVCLdewe/w6A=; b=1O283z1AsXE4GYQH0CuuuLF/n6n7CpoeVrtHFT4fDFxW18crK+jgfbLitjqG5WlJQwEN/i 11XJN2jZ0uFP2ead07yxP2swNoxlQvf55NVRZN5pPtgX8k1bvvJNEg+lrC8eIuguPTxhpA Euy2zZGNL2Xe8Fy5oWO+lV+hpR9kvus= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OzYKLxBN; spf=pass (imf15.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739296364; a=rsa-sha256; cv=none; b=r3UhmRlYCYXVUYuMV2D6s8zaYVQSb4jD2u5ivS2WvW62xl5UQ09rKCtqTRwprqU4yNHela QKkt0EGY1HDcViwR2kGUvth8Yh7hCCbSgM2rOxI6+GdShQkL9vFWbnK6nV79mfnhUqslIx iTIynVLIy5jHKvR/pe1tntQMVT/5EKM= Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6e46269d2c2so27908376d6.3 for ; Tue, 11 Feb 2025 09:52:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739296363; x=1739901163; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=alxnJNPbq/1DdW4EjlxryX0UCz6LPOMWVCLdewe/w6A=; b=OzYKLxBNvH7kh1Rt3DZpoRh30qll0dZtamwjQxpAZgfTbN4zWUXcSoUmdgDBZbVbtQ JTd7ohgP49GaGtdcMdynI5HrSsRvmOWEjUoZu3WZgwoa4Ju79smXL/6+RTZGQK7I2rQA bRmNywfBKxFBpIg+QhD8Ok0g844b58C6aDVSW5+nWqQ2kACc0p66WIZzlHyieSQ9yB4i 7d8tHaUYVuHr4kOm6ofFZcpseY6M/8xBtlbiBriJ1XlhR9xo3KdqBgbnV8hV5ADG7Gju fuw1Bg/48zgd3IWeLyyQsRS+funu2+wazWpinorLvL/d/lr2u52oExN7LNOQoCNCku8k nMwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739296363; x=1739901163; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=alxnJNPbq/1DdW4EjlxryX0UCz6LPOMWVCLdewe/w6A=; b=HDdYNhc3DocSCkQB5P5hg4ZFx+2AG1/IO2fxWdL0JUYBkk44DyWO9GFuhxLkk1CLPG UPc/1u8spfPHaZbqiPKvxcUYsUbAOezrKMBULl9g2xDb10bSJc2IAbYEKvWHWipCBGcr 7TSVBI9WWlflm7SmsT0ptSApiRF9QDcXApd1VUZgyjIWlFor0R3KXIZiSCba5lgEuwxB RM1iSIMzxRsUnEspRd0UOb9wGHOTG3gWZjxA+yOd/RgV4G7I5Z/Gaepi/JojyS8vp3xG NAZBcpf3hy1ik1hhVbNveqxH1mDGLusOyQZrvg1PXZCQBmJU3c3gBZGlLJnb2gFIOlPH s0pg== X-Forwarded-Encrypted: i=1; AJvYcCVEpxaYC8JYQm/7yURnRpqQxfAqu9vleyMF7Kam91Emfb/ElNB+N9OekPEHACKu2sAH2N0jjXip+g==@kvack.org X-Gm-Message-State: AOJu0YzbsqhYyNcixNcKULdwgzsNipAw1ha4Cwx6V1J4/uvbGZrutqom 95I8l0oAxgqiE74c0+siPXkL4m2kPvHUdUrh4NuleIeUCdYBmRN5H3oG2qn58/bmFWnDgAXQwW3 m6GpyNU4r0TFQhUhDMFVQn1h2lME= X-Gm-Gg: ASbGncs+Fpz1ZHTmgu85PPWbrnSPMQmSoUijXU113QbHvtwKCa19UM1B+TTNkjIUBuF urIIKefb8lSGTIK9BCLH7SC+82yOacCzoyxNS2SP5KjJLog88k7cBZRM1dE+jntMHNMfMGUVaGJ mfer0cxiTgQExTip4pCNILZq4+TYiG X-Google-Smtp-Source: AGHT+IE3VPNOnU63mQthg4Oyhovmexbq09LRCaEDUIKUz/i4EAR1nU8AN5MdiuFBRNFyRDfkrKCEN5igQcBrWu/GWxo= X-Received: by 2002:a05:6214:1c49:b0:6d8:846b:cd8d with SMTP id 6a1803df08f44-6e46edac168mr3233286d6.30.1739296363271; Tue, 11 Feb 2025 09:52:43 -0800 (PST) MIME-Version: 1.0 References: <20250206072102.29045-1-kanchana.p.sridhar@intel.com> <20250211170513.GB1227@sol.localdomain> In-Reply-To: <20250211170513.GB1227@sol.localdomain> From: Nhat Pham Date: Tue, 11 Feb 2025 09:52:32 -0800 X-Gm-Features: AWEUYZlcOdbZA9SqNCGkgKNQARGdRy_FNFi_eHNg0PXmpnE9bsAdcYk9s4FLLwY Message-ID: Subject: Re: [PATCH v6 00/16] zswap IAA compress batching To: Eric Biggers Cc: Kanchana P Sridhar , linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosry.ahmed@linux.dev, chengming.zhou@linux.dev, usamaarif642@gmail.com, ryan.roberts@arm.com, 21cnbao@gmail.com, akpm@linux-foundation.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, clabbe@baylibre.com, ardb@kernel.org, surenb@google.com, kristen.c.accardi@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 320A9A000D X-Stat-Signature: geuwfsgwoeui6bchury4rfjxsqoc7de8 X-Rspam-User: X-HE-Tag: 1739296364-533853 X-HE-Meta: U2FsdGVkX18BaIHeZIfPLPkiABKXmJRY9R2QTxh8PT8Vo7c9hgFo0TqAu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1uwmoEkCQGZglImk/ZHuYc5RqaYyHIR5pPJpjXnS+h3VluU5MyhKooVigJUKsW+njHmT55yExFTS3LBMjjHcneRK/SUg7k2Ud2m1T2ynVAkBQxvqAU1wBdZC3eDgUoxqGE5vWLCTgcJeVkkHcBFQwDDgU0StpRVVlW+0RwQYeLFJr1Hn8eimNy3LI2BXvbv69kvl8fS8I0QvQWUqOajmkNOabi5C2wT+Kig== X-Bogosity: Ham, tests=bogofilter, spamicity=0.377034, 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 Tue, Feb 11, 2025 at 9:05=E2=80=AFAM Eric Biggers = wrote: > > On Wed, Feb 05, 2025 at 11:20:46PM -0800, Kanchana P Sridhar wrote: > > So, zswap is passed a large folio to swap out, and it divides it into 4K = pages > and compresses each independently. The performance improvement in this p= atchset > comes entirely from compressing the folio's pages in parallel, synchronou= sly, > using IAA. > > Before even considering IAA and going through all the pain of supporting > batching with an off-CPU offload, wouldn't it make a lot more sense to tr= y just > compressing each folio in software as a single unit? Compared to the exi= sting > approach of compressing the folio in 4K chunks, that should be much faste= r and > produce a much better compression ratio. Compression algorithms are very= much > designed for larger amounts of data, so that they can find more matches. > > It looks like the mm subsystem used to always break up folios when swappi= ng them > out, but that is now been fixed. It looks like zswap just hasn't been up= dated > to do otherwise yet? > > FWIW, here are some speed and compression ratio results I collected in a > compression benchmark module that tests feeding vmlinux (uncompressed_siz= e: > 26624 KiB) though zstd in 4 KiB page or 2 MiB folio-sized chunks: > > zstd level 3, 4K chunks: 86 ms; compressed_size 9429 KiB > zstd level 3, 2M chunks: 57 ms; compressed_size 8251 KiB > zstd level 1, 4K chunks: 65 ms; compressed_size 9806 KiB > zstd level 1, 2M chunks: 34 ms; compressed_size 8878 KiB > > The current zswap parameterization is "zstd level 3, 4K chunks". I would > recommend "zstd level 1, 2M chunks", which would be 2.5 times as fast and= give a > 6% better compression ratio. > > What is preventing zswap from compressing whole folios? Thanks for the input, Eric! That was one of the directions we have been exploring for zswap and zram. Here's what's going on: The first issue is zsmalloc, which is the backend memory allocator for zswap, currently does not support larger-than-4K object size. Barry Song is working on this: https://lore.kernel.org/linux-mm/20241121222521.83458-1-21cnbao@gmail.com/ Performance-wise, compressing whole folios also means that at swap-in time, you have to decompress and load the entire folio/chunk. This can create extra memory pressure (for example, you have to either allocate a huge page or multiple small pages for the folio/chunk), which is particularly bad when the system is already in trouble :) I believe that is one of the blockers for the above patch series as well.