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 DD4E1C7115B for ; Fri, 20 Jun 2025 20:22:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AFBF6B0098; Fri, 20 Jun 2025 16:22:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75F2C6B0099; Fri, 20 Jun 2025 16:22:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 675146B009A; Fri, 20 Jun 2025 16:22:03 -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 5459A6B0098 for ; Fri, 20 Jun 2025 16:22:03 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AC8FC121589 for ; Fri, 20 Jun 2025 20:22:02 +0000 (UTC) X-FDA: 83576900484.12.E56F835 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf26.hostedemail.com (Postfix) with ESMTP id 045EC14000A for ; Fri, 20 Jun 2025 20:22:00 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=V0lDXwoa; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750450921; 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=ABKGmIgYVpeJbIXhtMHi40JgI2NvayJB322c5jxtZ1Y=; b=fjG0r5BOTxUXrsbgnXHoiy/sWcH8XUeSopqFYN6ec3siwpDoOwm8swl+LhNfJrmrxzUgih 3DpbHauK2svjBnCRaKnBM+WmM0Al62X5S5Y5n8qQ5+5Yn17UvuTVDOvELmisVODtMOaPnR Ra91DDJuEMFllQt1hrkkXXylFe2IuB0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=V0lDXwoa; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750450921; a=rsa-sha256; cv=none; b=f+kl+RUparhayvmpW6xVcfTqXBbXgWiuOO91+VRJyVjGfdsqSMj6EbdEZIg4JGeQ+BgRbI 6johiSGvmIjg/h8hyqaoOVwmuoFGqiU79fnCUOBiaCcxPBAVEVPngDTc6RaWZE+yqYW7jr EGTLgWxUgNWxBQm3bJRYURUMre2P5cI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id A80AFA543E9; Fri, 20 Jun 2025 20:21:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C62AC4CEE3; Fri, 20 Jun 2025 20:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750450918; bh=DSJoF1mmIlt0f+sq2JpaTh+bEPUAbP03ftsUdi/PiDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V0lDXwoaLY7y3wa9IueyszW7SzAJtLyNASt+zI7oSHK4CT1+NZjjnxu1DWtqempnq dsghHnhRtAgQThuHTOUqXic5oYjdEaI7EplWKGHPxO8djv9QqSMK36QYbZU0dMdYcC ial/nqvMsOLe87iJw2xDVi0DkSJLXDQwLrPispU/Zu/V2lBu4CxXWZB2MSubJnechE xxuCcuNEBcYKOYUNj5eiF3r43moAfLWD5zrm+5I95/NpjDpCMMKuJL1VIjxwgsaUNe 0CiH3ibZ2VUNQY9kqaWFOHFR/G42pg0EfJwb02121h1Pn+1ae3Uvf5CcRf2kxc6wXU m+WFPO7mMp9JA== From: SeongJae Park To: Bijan Tabatabai Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, david@redhat.com, ziy@nvidia.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, ying.huang@linux.alibaba.com, apopple@nvidia.com, bijantabatab@micron.com, venkataravis@micron.com, emirakhur@micron.com, ajayjoshi@micron.com, vtavarespetr@micron.com Subject: Re: [RFC PATCH v2 0/2] mm/damon/paddr: Allow interleaving in migrate_{hot,cold} actions Date: Fri, 20 Jun 2025 13:21:55 -0700 Message-Id: <20250620202155.98021-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250620180458.5041-1-bijan311@gmail.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam11 X-Rspam-User: X-Rspamd-Queue-Id: 045EC14000A X-Stat-Signature: pp3eq8wd5dt1pucnd9fkr71hkxbzeeye X-HE-Tag: 1750450920-677050 X-HE-Meta: U2FsdGVkX1/4ReT3+ZCruhMTo7qirjMqWrrckm67rKWQCKYRJ2xLSYw6l0pxckfVNQUIRBop/0Edg7EHwa6RtBoV1Iul4JZChWXT/SIuApcjZuT8w0JJbmJ21bUfWFro0vJk8jF4pYOX8XisPbQ2P2N+QrObbCljPu+G0PTKfPU/lphlTL3p1CpcU5dWWrnTXY8k5+qymV6BMnspNSptpD+HjhCjJCuxoYQ7eqOfdsV+nJCYBVcsdujngHTNEznr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GrWQLmb9gWm0yjYFSC0Oxs36Ob4toP5ZW9J+e4U6s6w== 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: Hi Bijan, On Fri, 20 Jun 2025 13:04:56 -0500 Bijan Tabatabai wrote: [...] > This patch set adds the mechanism for dynamically changing how application > data is interleaved across nodes while leaving the policy of what the > interleave weights should be to userspace. It does this by modifying the > migrate_{hot,cold} DAMOS actions to allow passing in a list of migration > targets to their target_nid parameter. When this is done, the > migrate_{hot,cold} actions will migrate pages between the specified nodes > using the global interleave weights found at > /sys/kernel/mm/mempolicy/weighted_interleave/node. This functionality > can be used to dynamically adjust how pages are interleaved by changing the > global weights. When only a single migration target is passed to > target_nid, the migrate_{hot,cold} actions will act the same as before. This means users are required to manipulate two interfaces. DAMON sysfs for target nodes, and weighted_interleave sysfs for weights. I don't think this coupling is very ideal. Off the opt of my head, I concern if users could mistakenly forget updating one of those, since the requirement is not very clear. I think the interface should clearly explain that. For example, writing a special keywords, say, "use_interleave_weights" to target_nid parameter sysfs file. But, even in the case, users who update weighted_interleave might foget updating target nodes on DAMON interface. I think letting DAMOS_MIGRATE_{HOT,COLD} to use all nodes as migration target when the special keyword is given is one of better options. This is what I suggested to the previous version of this patch series. But now I think it would be better if we could just remove this coupling. I understand a sort of this coupling is inevitable if the kernel should make the connection between DAMON and weighted interleaving itself, without user-space help. But now I think we could get user-space help, according to below. Please keep reading. [...] > As a toy example, imagine some application that uses 75% of the local > bandwidth. Assuming sufficient capacity, when running alone, we want to > keep that application's data in local memory. However, if a second > instance of that application begins, using the same amount of bandwidth, > it would be best to interleave the data of both processes to alleviate the > bandwidth pressure from the local node. Likewise, when one of the processes > ends, the data should be moves back to local memory. > > We imagine there would be a userspace application that would monitor system > performance characteristics, such as bandwidth utilization or memory access > latency, and uses that information to tune the interleave weights. Others > seem to have come to a similar conclusion in previous discussions [3]. > We are currently working on a userspace program that does this, but it is > not quite ready to be published yet. So, at least in this toy example, we have user-space control. Then, I think we could decouple DAMON and weighted interleaving, and ask the usr-space tool to be the connection between those. That is, extend DAMOS_MIGRATE_{HOT,COLD} to let users specify migration target nodes and their weights. And ask the user-space tool to periodically read weighted interleaving parameters that could be auto-tuned, and update DAMOS_MIGRATE_{HOT,COLD} parameters accordingly. Actually the user-space tool on this example is making the weights by itself, so this should be easy work to do? Also, even for general use case, I think such user-space intervention is not too much request. Please let me know if I'm wrong. > > We believe DAMON is the correct venue for the interleaving mechanism for a > few reasons. First, we noticed that we don't ahve to migrate all of the > application's pages to improve performance. we just need to migrate the > frequently accessed pages. DAMON's existing hotness traching is very useful > for this. Second, DAMON's quota system can be used to ensure we are not > using too much bandwidth for migrations. Finally, as Ying pointed out [4], > a complete solution must also handle when a memory node is at capacity. The > existing migrate_cold action can be used in conjunction with the > functionality added in this patch set to provide that complete solution. These make perfect sense to me. Thank you for adding this great summary. > > Functionality Test > ================== [...] > Performance Test > ================ [...] > Updating the interleave weights, and having DAMON migrate the workload > data according to the weights resulted in an approximately 25% speedup. Awesome. Thank you for conducting this great tests and sharing the results! > > Questions for Reviewers > ======================= > 1. Are you happy with the changes to the DAMON sysfs interface? I'm happy with it for RFC level implementation. And in my opinion, you now proved this is a good idea. For next steps toward mainline landing, I'd like to suggest below interface change. Let's allow users specify DAMOS_MIGRATE_{HOT,COLD} target nodes and weights using only DAMON interface. And let the user-space tool do the synchronization with weighted interleaving or other required works. This may require writing not small amount of code, especially for DAMON sysfs interface. I think it is doable, though. If you don't mind, I'd like to quickly make a prototype and share with you. What do you think? > 2. Setting an interleave weight to 0 is currently not allowed. This makes > sense when the weights are only used for allocation. Does it make sense > to allow 0 weights now? I have no opinion, and would like to let mempolicy folks make voices. But if we go on the decoupling approach as I suggested above, we can do this discussion in a separate thread :) [...] > Revision History > ================ > Changes from v1 > (https://lore.kernel.org/linux-mm/20250612181330.31236-1-bijan311@gmail.com/) > - Reuse migrate_{hot,cold} actions instead of creating a new action > - Remove vaddr implementation > - Remove most of the use of mempolicy, instead duplicate the interleave > logic and access interleave weights directly > - Write more about the use case in the cover letter > - Write about why DAMON was used for this in the cover letter > - Add correctness test to the cover letter > - Add performance test Again, thank you for revisioning. Please bear in mind with me at next steps. I believe this work is very promising. Thanks, SJ [...]