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 381C0CEACEC for ; Tue, 1 Oct 2024 16:58:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4F9B6B00E1; Tue, 1 Oct 2024 12:58:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF63E2800C7; Tue, 1 Oct 2024 12:58:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99FC5280068; Tue, 1 Oct 2024 12:58:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7A91E6B00E1 for ; Tue, 1 Oct 2024 12:58:00 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2DEACA17C6 for ; Tue, 1 Oct 2024 16:58:00 +0000 (UTC) X-FDA: 82625640720.28.3791B1E Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf06.hostedemail.com (Postfix) with ESMTP id 69A8D180011 for ; Tue, 1 Oct 2024 16:57:57 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Z/9CMtSl"; spf=pass (imf06.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.219.53 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=1727801750; 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=45yUF+50GT22EogIC3/iwraZsREEDBmHPCJtFCR8mXQ=; b=3SgwApFhL+/xMNgt4+UguOSE1toTOlDKp8FEiqhFEK4IX5WlXyAFKLWCWZuhwGDkSV9h+k Drr16xhOcgIfA6C6TT2RLEU6a2Fwkjv+ywoEWIxaogiJl31Av0FRmPGEM/jQtJQxj8rwvN Clf67Reem0lZgCEMU4R8WT4z5Q6E6RU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727801750; a=rsa-sha256; cv=none; b=imzPK/4zmvX15IruN1caX0oYKI2Xh6sKtURCtnLIyp1EPtKC9Gmmuvk1T5HcefBlwgFGG5 GdA4JTvxb5VOaosMkobLXksCtY23DNrYp5vNWOUxbTRWbU4sJr8RDVMBeUVypMtfA3ZLzs CEGlzQQ4uQjw3IEBvqJ0KYvkuQmsjrQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Z/9CMtSl"; spf=pass (imf06.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6cb3d2ce75eso129696d6.0 for ; Tue, 01 Oct 2024 09:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727801876; x=1728406676; 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=45yUF+50GT22EogIC3/iwraZsREEDBmHPCJtFCR8mXQ=; b=Z/9CMtSlb7Ov0PLkBzObvXeRw3yakhbipxTjZFTgeezXbk9Unsb1yfbfomPQ0RTiuk 4Mpkb6gKMNOxnB1m3fnjF3gUgG9xKGe57XJte8W94YHA00YBXsPk58x32lVCIUschwWX gaqUDng0JUXCcL7iGoMjH8Yc+DRb9BbpElawiMs5ggl8TqyI3mEuC7QvzGjMSQo9pl9M hWJMuYBLboB86WIL+4He96zRFbv1+3ao7T8ILhHA8iAofI6LgnoRG8k0YDV9OIPWrS6+ 0AT1DCB1zRnB3kvCR+ICyvyr3MMuEizgrVxQzuqnT9JLihsw28kLw0mxPRw1nQu4Wv+H Nsbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727801876; x=1728406676; 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=45yUF+50GT22EogIC3/iwraZsREEDBmHPCJtFCR8mXQ=; b=Xy6szaMCalk3BawJjQAXauRPlalkE/q+oH5xUQ82ZogqWnxzEajbEi9t8q9ie0km+I /5plnVyct5q2u6vwWg6MSkaZPQdLnPo4Ex3Ts2NtI4zBzWHABXVb/5c8YpLhDeh5Msji 8oVfCDeYX14PFoxY3NGR7xG7wu8es8ftmoVmUmz0Zfm/0r6eBLuR0zf1a553u+N5WQmv v9ApaGaVgWcnEOyYZ/LksxMFYiV0Pyj3B2nYkVtvSM7eFSgMOEZp5vEDRQHHWQAzVXBQ cpObd4GHBhQ5J9TOBQ89jO7yn9IgsGSyQ7tL2fk6q86nMjeTUymB6gaEc4IsQs3WbWxZ t8/Q== X-Forwarded-Encrypted: i=1; AJvYcCU+Duv43uRg8Ny4RnZIzN7dyd/43Po4fCr8G2RPq4+PDxWZD2i58Ggp1J5Phdg+rPZSjmXKHXPSNA==@kvack.org X-Gm-Message-State: AOJu0Yz0RkFRtuC8H7z5eG8Su7ki9pOjDgqO0bovl8A8+wPmQhdYFqJ1 o7oYIdfS/VzAHP9rQmocmztaHqJgOT4Vb+GQZKprNM9JK3EJBLK5K7PQz8uuK9V13+BoshIOdqC mu2YAOGLGVgj9SWoiYOvSP35VKI0= X-Google-Smtp-Source: AGHT+IFzyHnVYSdoUF3wjsiyUK4NHNf84vM7NGP6HBryVwfge5Tnlci4e2ymj47N1NhyxTHjAKZbwO8GtEaUvRTDoys= X-Received: by 2002:a05:6214:4697:b0:6cb:584f:ec22 with SMTP id 6a1803df08f44-6cb816de99emr3853506d6.21.1727801876442; Tue, 01 Oct 2024 09:57:56 -0700 (PDT) MIME-Version: 1.0 References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> <20241001053222.6944-7-kanchana.p.sridhar@intel.com> In-Reply-To: <20241001053222.6944-7-kanchana.p.sridhar@intel.com> From: Nhat Pham Date: Tue, 1 Oct 2024 09:57:45 -0700 Message-ID: Subject: Re: [PATCH v10 6/7] mm: zswap: Support large folios in zswap_store(). To: Kanchana P Sridhar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org, nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 69A8D180011 X-Stat-Signature: w8zdqgc7xpkkszggh3jbnunsgct93djo X-HE-Tag: 1727801877-240446 X-HE-Meta: U2FsdGVkX1/Vfvusj3XRb2tn1yLvgccsmpPWbEQZNZj72fXqkE/BFUh6rm9JrFx1DNML4xuz6EIETUlT9or/pV+gYRyIGuBWmgcDoktVqblAaQD1SJLuLzIi5rl0bjkqsDuhhvWPImhyahw84LfGtg1due6djLrdlD/lJEemI6j/h0Nz3lrBWEgRtHUVsqrTGZCqVGf/vUWFD/VmvSAf5wdvyuwjawZGTWVJP48THl9Uo7PHsoxb9IgH6Frm/6hjAgdPq58Wx2xaPIFHy7/YSgQqpr5cU35fU2EdAvD1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Jz2A621vHas2ccUIPqyGz0J2dfDOM+CcyLZ4bKRQWb3xs1GYKP58wqojbj9aRk1xWv47AmC4if9x7ldtgL4JxGsoGI+fUs7f9ACm9qUQaOthJ54wLynV+y+TI5Sjn/LEV366eUOKyQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.035237, 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 Mon, Sep 30, 2024 at 10:37=E2=80=AFPM Kanchana P Sridhar wrote: > > zswap_store() will store large folios by compressing them page by page. > > This patch provides a sequential implementation of storing a large folio > in zswap_store() by iterating through each page in the folio to compress > and store it in the zswap zpool. > > zswap_store() calls the newly added zswap_store_page() function for each > page in the folio. zswap_store_page() handles compressing and storing eac= h > page. > > We check the global and per-cgroup limits once at the beginning of > zswap_store(), and only check that the limit is not reached yet. This is > racy and inaccurate, but it should be sufficient for now. We also obtain > initial references to the relevant objcg and pool to guarantee that > subsequent references can be acquired by zswap_store_page(). A new functi= on > zswap_pool_get() is added to facilitate this. > > If these one-time checks pass, we compress the pages of the folio, while > maintaining a running count of compressed bytes for all the folio's pages= . > If all pages are successfully compressed and stored, we do the cgroup > zswap charging with the total compressed bytes, and batch update the > zswap_stored_pages atomic/zswpout event stats with folio_nr_pages() once, > before returning from zswap_store(). > > If an error is encountered during the store of any page in the folio, > all pages in that folio currently stored in zswap will be invalidated. > Thus, a folio is either entirely stored in zswap, or entirely not stored > in zswap. > > The most important value provided by this patch is it enables swapping ou= t > large folios to zswap without splitting them. Furthermore, it batches som= e > operations while doing so (cgroup charging, stats updates). > > This patch also forms the basis for building compress batching of pages i= n > a large folio in zswap_store() by compressing up to say, 8 pages of the > folio in parallel in hardware using the Intel In-Memory Analytics > Accelerator (Intel IAA). > > This change reuses and adapts the functionality in Ryan Roberts' RFC > patch [1]: > > "[RFC,v1] mm: zswap: Store large folios without splitting" > > [1] https://lore.kernel.org/linux-mm/20231019110543.3284654-1-ryan.robe= rts@arm.com/T/#u > > Co-developed-by: Ryan Roberts > Signed-off-by: > Signed-off-by: Kanchana P Sridhar Reviewed-by: Nhat Pham