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 A4C3AC369D9 for ; Wed, 30 Apr 2025 21:51:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A9866B00A6; Wed, 30 Apr 2025 17:51:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95A456B00A9; Wed, 30 Apr 2025 17:51:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 849106B00AA; Wed, 30 Apr 2025 17:51:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 60BDD6B00A6 for ; Wed, 30 Apr 2025 17:51:10 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9529EC0F5D for ; Wed, 30 Apr 2025 21:51:10 +0000 (UTC) X-FDA: 83392056300.22.5541D8E Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf21.hostedemail.com (Postfix) with ESMTP id E72E01C000C for ; Wed, 30 Apr 2025 21:51:08 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=RndfgxAr; dmarc=none; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746049869; a=rsa-sha256; cv=none; b=fnK2VvCB5WqHG3kH+aj0ne+nTTazkwmfEeDJH0W7iYc3NHSJHCFGUsIWoA/PQK+thiWTy7 vtp/idPl1y1ryY9YpyXrjnuvmW26AsJ5/LR8J/r+Ea/xLtJFptRoWCzYPs9PxyayIpgdDB U9KoARL0m91/fcgjCUVM2bnKU9rP5TI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746049869; 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=OZIFhyha4G5i8WRLJMw6/zI37vSJCnSLVsLqNxDj5gU=; b=XJM6rpW5korOU0B/txrvoDxfHkgJL/cWiP7xpcqm95wefN/6vBlvW6/Ey9MTncPq3Oc9+b OFjpeZJfhVnKx2bQHnvO9++6XCk1hFJA9ymwNxKPE1SwdesKttHy6vVL2bJBGx7hnMthRm qULnp2x7Ua/gJct/guPxS6TdP0YKUOY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=RndfgxAr; dmarc=none; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 54423A4B7E8; Wed, 30 Apr 2025 21:45:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07C5EC4CEE7; Wed, 30 Apr 2025 21:51:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1746049867; bh=5u/M4235ZhIaoydVPyaBH4cYCvqZf2avpMDKQWTlaWo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RndfgxAr+7rzrSzhRqUo3Hdh8cOk1RR+5tdnl4wEyYYGeBTuUq2adD0CtwrTvKC8+ dCPYZldY4E2o0iBRPOHrpSYjq8fGDoceEbNX1cS2VvMPrZM1ARHA6ddt6i14worw86 Ftug5mszCLdfxUuQBPRg3hOiMYU/LpCr0zRhkqrk= Date: Wed, 30 Apr 2025 14:51:06 -0700 From: Andrew Morton To: Qun-Wei Lin Cc: Mike Rapoport , Matthias Brugger , AngeloGioacchino Del Regno , Nhat Pham , Sergey Senozhatsky , Minchan Kim , , , , , Casper Li , Chinwen Chang , Andrew Yang , James Hsu , Barry Song <21cnbao@gmail.com> Subject: Re: [PATCH] mm: Add Kcompressd for accelerated memory compression Message-Id: <20250430145106.8ce79a05d35cec72aa02baa6@linux-foundation.org> In-Reply-To: <20250430082651.3152444-1-qun-wei.lin@mediatek.com> References: <20250430082651.3152444-1-qun-wei.lin@mediatek.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E72E01C000C X-Stat-Signature: jbnkc7qe3ny9d7iz73u8unzcqwcx7cf3 X-Rspam-User: X-HE-Tag: 1746049868-31962 X-HE-Meta: U2FsdGVkX18JVdo1COxet2+blEIV2+QD4dvRMIdGMOWrwJgaiOGfjkI4hJPx3AxviyZsra3QatzCKvwYjmVH2ww6PO6V0/9HG8gOGpg0hV2+SWJ5JLrKw+USiLroMRSxceMGg44mdg0Nkxjgp4+gJeDevOUf+Usz/VRuUrBrlH97Bvq2BbSNoSHaXLZnShbrcaY9jpRAXuZumJ83lp40vSKO4n/C39OLtcgrlpwCLtFs0lqN/EDhl1FTih8L+v2fzMvgBs1n9IKvutguu9YWscsCA4/Jsv/gDZllIp3pzv5Sz5E/kx15FGEvk7uUVXhKkzmScqeOWH8w7kgQFHPfVkXJe9Ptpusg+vnhrXIGz44QIpmap8Xh1C6qirxI3Vsl/zdKyKopsCOnP5wJDxllH0+ZOBxlF+5qP/KJlSvX4gNhQhArJw63HXSK5k0QFxS4XKgrvQjX3/LaVGtzqOp2kPamo3VSkT0JOMtZhcMHuvgYL+gpugQlksOzWY+M6hj0inGz5x0jCt+upd5d3/vAqItL5bpuWWS3vmg46ViPvC3WKM1uNTFHugKqzD4tcd7ULwGnJwnIDmMXJCrofXK4grNuLch6gfpF1CzQ9o0NGxV7FyI6MwzkDIsQIcX8dSgu4zshe+FBYGaG2qGTRl/l43FyGf3578wtwwIackT2bJh13MPHhDeeks3DSPsjSznYuz6jo2HvxAjZ6HhDrsWxF9Vu1Ynfps4e1APMd4qTQ0do5HEesdinHGIVVnCDzdO8V7gXlKgh92jX6aORG1crbpFsejJ6plSJLzJgku5x1cvzk8IfVcqe84XRXqZJjAsg86VpFmFr8FJ7xldJHtZaR+GUzinNf+njR4OSGPmMmb5QgMWbbHqsLLEy6g8bgotArpojd27hMVSLpiJ4MKXUtefAU8kTFmrcSPOYeruVex78uTDjFdtGKYewqAuDfamuqMst4XPphBcPuoE3yFP 5wX1P6Vu P+F2h4J/uNbN5fMMQH6SBGoHTAXxLmZAia11XEJWBP/xAzN4hRN0tQAaU3ofpvu6w1++ZXIWDzlgVFvRf16NQU1/Au4+YHQVmU7WPs7a8j0cGj/7J1mKeki3OaSjkBLw92A5s6I2llUxolYvUfcL1XxRDWL1yTMoLqjFtoiT0LhIDZmyKWBWH97B/IFYGlqfnc2ugwl2HWwZT2Hs+4c4B0krPFJ9mZ32PUEDErxijhpUCpiho0t56XdhK3e6gInv/iFvy8R/udiYYIfvv9VNNxsEBnfy7j8cghLa2InD3gw8fFY44GddUTfqRKUJXgFiLmwJ16bNhP1djKnd6ndlR8OhY4w== 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: On Wed, 30 Apr 2025 16:26:41 +0800 Qun-Wei Lin wrote: > This patch series introduces a new mechanism called kcompressd to > improve the efficiency of memory reclaiming in the operating system. > > Problem: > In the current system, the kswapd thread is responsible for both scanning > the LRU pages and handling memory compression tasks (such as those > involving ZSWAP/ZRAM, if enabled). This combined responsibility can lead > to significant performance bottlenecks, especially under high memory > pressure. The kswapd thread becomes a single point of contention, causing > delays in memory reclaiming and overall system performance degradation. > > Solution: > Introduced kcompressd to handle asynchronous compression during memory > reclaim, improving efficiency by offloading compression tasks from > kswapd. This allows kswapd to focus on its primary task of page reclaim > without being burdened by the additional overhead of compression. > > In our handheld devices, we found that applying this mechanism under high > memory pressure scenarios can increase the rate of pgsteal_anon per second > by over 260% compared to the situation with only kswapd. Additionally, we > observed a reduction of over 50% in page allocation stall occurrences, > further demonstrating the effectiveness of kcompressd in alleviating memory > pressure and improving system responsiveness. It's a significant change and I'm thinking that broader performance testing across a broader range of machines is needed before we can confidently upstream such a change. Also, it's presumably a small net loss on single-CPU machines (do these exist any more?). Is it hard to disable this feature on such machines? > > +static bool swap_sched_async_compress(struct folio *folio) > +{ > + struct swap_info_struct *sis = swp_swap_info(folio->swap); > + int nid = numa_node_id(); > + pg_data_t *pgdat = NODE_DATA(nid); > + > + if (unlikely(!pgdat->kcompressd)) > + return false; > + > + if (!current_is_kswapd()) > + return false; > + > + if (!folio_test_anon(folio)) > + return false; Are you sure the above three tests are really needed?