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 DDC7FC282EC for ; Sat, 8 Mar 2025 05:41:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9FCE6B0082; Sat, 8 Mar 2025 00:41:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A287B6B0083; Sat, 8 Mar 2025 00:41:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A4256B0089; Sat, 8 Mar 2025 00:41:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 68C936B0082 for ; Sat, 8 Mar 2025 00:41:46 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8E55756EFD for ; Sat, 8 Mar 2025 05:41:47 +0000 (UTC) X-FDA: 83197287054.26.CCEABFE Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) by imf17.hostedemail.com (Postfix) with ESMTP id A121340002 for ; Sat, 8 Mar 2025 05:41:45 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="N/tWpyr2"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.222.49 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741412505; 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=EJmfZfA0tNqTdg8bAfZWDeUCZMhc8ZXDtBpkPMyhAvk=; b=z8ru0XgfyzmarYy1P8ew215c8u4jAYbAr2Y1K2cCudCff9zpElSXDagpltOlcDH8kHbV3x c7Td/tD91MvNCaFdOt/n+VyUCetnl387+7qfXadGxQpkgWiYGVwHCyY+fTBtcAEKkAq/J0 xliWIS1jNCVp3S98+ycZySnNVNhZ3/c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741412505; a=rsa-sha256; cv=none; b=DSw8kd8VZgcszgR6S8oNIvjt3/S2KByObEoaYNZ6ex5UTBwOVYAC0PLuGayyJ88FUcgFVO HLQ7vbjT0O+iuR78uDeUoMFeCDIhN2ngqUqCEurljB6vneeNc8kn0J8Qcyg13DpeDYKePe UHKnApSrORjzzfskSJ/hckFQ4b8RfZA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="N/tWpyr2"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.222.49 as permitted sender) smtp.mailfrom=21cnbao@gmail.com Received: by mail-ua1-f49.google.com with SMTP id a1e0cc1a2514c-86d2fba8647so2321151241.0 for ; Fri, 07 Mar 2025 21:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741412504; x=1742017304; 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=EJmfZfA0tNqTdg8bAfZWDeUCZMhc8ZXDtBpkPMyhAvk=; b=N/tWpyr2WFTNCOVfKp8B0s1poSnIsTblFyb5fyNYpcaCaddqNCG4Od37Bg2ABS+7/f OI1KksIGIIXNxxyArA68YKOoW91+UK3V9Xm+fSIox9JCpIvttypXbYiqA2htnblvyfIa yyBtKtJAOm+yBT/DlhmfSpYtNmOHgrRGOIFkK1nfW7BfLwVDfwoxg8QT3RCzbbooQt2r j7eBjHeuJhTkE/FvJjNxad3Qde+ds8BFISYcjXVWliovKdGqafbt1w9oMUwURVVKWL5f iV5X6erLUJ05932XsPN3bed1qe5I5AAbU6nD+TEGPS21Pe+PT1a3K+bxln8m9DTNgpm4 vFQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741412504; x=1742017304; 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=EJmfZfA0tNqTdg8bAfZWDeUCZMhc8ZXDtBpkPMyhAvk=; b=PqGUx4uGUSdcLrRy1GFHdLgv5P3u28Cias1jhNRZbOhvEH1JKtsAqBY43aQ0e5pDAB P+R8rXV4vjZ58Gpk+u3TfaE8VuIUP5MttRCWBQ7lgNNbsYfA6w7QVI6Xhe9z2gv+vPQE NGNbFBDRCLe+9Sy2u/5iliWyFuGGbbjn17OFW6J4FdKhD0jg8q0c2ur+yQZdHZhe+jtZ XtikEn75N3KMTlvdiB2qeqRdrGHw2+3055gnrWHsxbgyRx1Vh9nhi2tKRKeE1H1kyP27 0ouiaQXrbOYX4ArrrFMmy7eAAd29JvNsd7eEMgbu0zMVMsQ3/o7IewRCEmvWLBIzLgz9 oE/w== X-Forwarded-Encrypted: i=1; AJvYcCV/wvvKgIhW3u8LGQK2hqNPmxh0S/uuj759IzpWCoLPn3GZC3tNxzYTYxIdig9odrg+sR7Oo2u+nQ==@kvack.org X-Gm-Message-State: AOJu0YzxjMLkWvg+iPwYGGV3uJLB+gU4GlDNWI2lPs3MqZQJGAEALzZi IybngFGKcGlqq+zf1FlysTnBsJz2pjhmpoO4mJVDgP2nRuL9fTh5v9VmeHnjQrDaX/S1N+TQrb+ QviYFvTyf2tI+9m79KAayDuKEaqk= X-Gm-Gg: ASbGnctr642oG1N/wYhgyUm0MHOpwv9mig00KHFLuoeRS7p7c+rtZrsf8B4hUMlu0HN BSO9+j7btO5bFaldn1iliRCCTM8AgkhCsNOuZzchMkItch+MikV3l4q2M1yvKSzjImix9G4m19A PN4rBxhHXZ3AHLKdFCIR7wMkKLjZiQfyQuqscK X-Google-Smtp-Source: AGHT+IHHggIPKrL5d8yR6LTugXbBrgtYx9QYjOVM0FXkszko5m8Bp+SYzJZbZ7yqbzdNsHG/XrgFTdExUecoVmk9yWY= X-Received: by 2002:a05:6102:809c:b0:4bb:9b46:3f6f with SMTP id ada2fe7eead31-4c30a538979mr4607096137.1.1741412504595; Fri, 07 Mar 2025 21:41:44 -0800 (PST) MIME-Version: 1.0 References: <20250307120141.1566673-1-qun-wei.lin@mediatek.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Sat, 8 Mar 2025 18:41:33 +1300 X-Gm-Features: AQ5f1JoraQfrjgklIeJVnsPlZLYjnVJdWtNTlR00z_Bw9q9Ie66lMyjY9JB8lAo Message-ID: Subject: Re: [PATCH 0/2] Improve Zram by separating compression context from kswapd To: Nhat Pham Cc: Qun-Wei Lin , Jens Axboe , Minchan Kim , Sergey Senozhatsky , Vishal Verma , Dan Williams , Dave Jiang , Ira Weiny , Andrew Morton , Matthias Brugger , AngeloGioacchino Del Regno , Chris Li , Ryan Roberts , "Huang, Ying" , Kairui Song , Dan Schatzberg , Al Viro , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, nvdimm@lists.linux.dev, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Casper Li , Chinwen Chang , Andrew Yang , James Hsu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: p9s4d75bk7um48sabxpf9qdbwsmwsetd X-Rspamd-Server: rspam05 X-Rspam-User: X-Rspamd-Queue-Id: A121340002 X-HE-Tag: 1741412505-491638 X-HE-Meta: U2FsdGVkX1+V1GRS/ikibMhxKaCaCBs3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2uEjwkOzkiDGmFqUFhGgajrai3OXXXgk0y4EHtn+UNIKTKW+LbWDrJaOwk9Pp4Hoc3WENyxqZny59FhK35oM4cwSArLkgob7l+CBqkwqXaVlxagWO75CuUP9J8YPeceOHDJTP9UJ4LYYn+dINLOk/FxUdoQK4kPpZjACCXjRa5GC9Wo6DRd54tJYNCzxMRnXzyCnBAfV8v2SqpNqabXd4AfsyMAQ5Kak5TGqU2qkqIlES2dSY9LTAY1YuUWXUfVIUeJsbT5NIyWFOV2QXh3poZGmOygqWe59L8WE51Y/Ro2Ofl4PVHXR1qAJAgnUD4sQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000034, 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 Sat, Mar 8, 2025 at 12:03=E2=80=AFPM Nhat Pham wrote= : > > On Fri, Mar 7, 2025 at 4:02=E2=80=AFAM Qun-Wei Lin wrote: > > > > This patch series introduces a new mechanism called kcompressd to > > improve the efficiency of memory reclaiming in the operating system. Th= e > > main goal is to separate the tasks of page scanning and page compressio= n > > into distinct processes or threads, thereby reducing the load on the > > kswapd thread and enhancing overall system performance under high memor= y > > pressure conditions. > > Please excuse my ignorance, but from your cover letter I still don't > quite get what is the problem here? And how would decouple compression > and scanning help? My understanding is as follows: When kswapd attempts to reclaim M anonymous folios and N file folios, the process involves the following steps: * t1: Time to scan and unmap anonymous folios * t2: Time to compress anonymous folios * t3: Time to reclaim file folios Currently, these steps are executed sequentially, meaning the total time required to reclaim M + N folios is t1 + t2 + t3. However, Qun-Wei's patch enables t1 + t3 and t2 to run in parallel, reducing the total time to max(t1 + t3, t2). This likely improves the reclamation speed, potentially reducing allocation stalls. I don=E2=80=99t have concrete data on this. Does Qun-Wei have detailed performance data? > > > > > Problem: > > In the current system, the kswapd thread is responsible for both > > scanning the LRU pages and compressing pages into the ZRAM. This > > combined responsibility can lead to significant performance bottleneck= s, > > What bottleneck are we talking about? Is one stage slower than the other? > > > especially under high memory pressure. The kswapd thread becomes a > > single point of contention, causing delays in memory reclaiming and > > overall system performance degradation. > > > > Target: > > The target of this invention is to improve the efficiency of memory > > reclaiming. By separating the tasks of page scanning and page > > compression into distinct processes or threads, the system can handle > > memory pressure more effectively. > > I'm not a zram maintainer, so I'm definitely not trying to stop this > patch. But whatever problem zram is facing will likely occur with > zswap too, so I'd like to learn more :) Right, this is likely something that could be addressed more generally for zswap and zram. Thanks Barry