Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1870098lqe; Tue, 9 Apr 2024 02:57:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFa/JeOjyf+IbA751HRcksjbtaj8W0/09ei32IZXmM8UqJXVe5FifoA5wsSRuQo24u15pMRy295g+L3SeUPmSImMlRQ7AUI4vQzCNhBA== X-Google-Smtp-Source: AGHT+IGAJISm1Fhs7yZcqONvLnkJyTU6cxpHZUxQ02EvN1jpWL53Ax719kN/4L5K3qFWgK4IXmkV X-Received: by 2002:a05:6808:1801:b0:3c5:ea64:a471 with SMTP id bh1-20020a056808180100b003c5ea64a471mr9092500oib.6.1712656640763; Tue, 09 Apr 2024 02:57:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712656640; cv=pass; d=google.com; s=arc-20160816; b=x0zzoiv9s5CZkLKOyiVjAJqs7gXp8tYWftu/P4qFPkGEdMysRInIJm4OeW4P2M+EMG urxoEW2uyTKI6QFAz5Su1/tdWY9vhCby2RSjwWcW1tVHiJObgg6IJ4HR6ZhDccaFRNwB fefg58sPGoiGfuQ+5Ug85rn8AW23LHdwmjQDVCMbgL1aRzu0VvLFtVTecHYIdj8u2YNG kiK/iDBck8tz6dRyRmRA05Xbkl+fHBFkVagT+9++O9KJTpL+1skOynw96pA0mUuOWSoG KwA9Yei72o2dAP9gUeroQpQZ1eNGKEIt3N333+ZmEwXrRgu/OiGafxWsS602x6Vr1vOG 16bQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=iUS/h9oHY3Otx6pMewH2WvNF7wvsEUBSjW83cNTKr2w=; fh=oAtQoQCLCQQH8mDDWdH0YJjwgHnsljZCr+1HLFRRxyA=; b=FhGQXWthtruKWBbXRX9+HMPQl8ynRPaT6wu3XwhFYeb4T/EXgTzrx8iGGgKk/vHUVJ 9+mr1R3yFqUMjZbV8ZwTFMbuAGbEEkcCQzBhoGlEqhOmWwXncZ/qUgxKXhuSyifMRCLC CY+PS69c3TrklcSqIeJi05EUJvQyfdRYmus22yjKSbZN+2aKYmapKvn8ZyfHDpkGNze5 ZvHvZxRhp4mvF3gop3E/qPK6xdgas68hR4HbYrfiKby4YVz59Zp9ms3MVmpb4egU4uIp xv6C3CyPjhlSIy/pzo5HIT+5+Prpr57dWYx/N1nppLJRMIjqz+s84bbHJhOw/9813Ru4 qXNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-136600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136600-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o4-20020a634e44000000b005cecd95b6besi8090146pgl.685.2024.04.09.02.57.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:57:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-136600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136600-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C2E03B20E87 for ; Tue, 9 Apr 2024 09:54:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55A2180603; Tue, 9 Apr 2024 09:54:47 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13F057F46A; Tue, 9 Apr 2024 09:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712656486; cv=none; b=dXZ4T/hEFSLY83dTD9WXS/060Gzzdb6pysGCCUk5ip0WH9GWzYKMc9z6Mmwej311tIQOuxTuJKLYAVND9yMXyFfZzGxUZsK4ePBCzVOfM9W6F/FTiRARM1nTAMq3ku4HvWVFLUcBAzQQc/d6In0kx9le3XwwhuP0M4R7I3GmzD8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712656486; c=relaxed/simple; bh=ZhL2S8X8G4T007S4qYVJLd7OiEopZB8XYTdXdhK/h44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NBpNcNMttIxEJ0aOHgjFICaIcqK6f/WL+FrghSVFrpYjA8Z6i7t+tl8x2XMTzYBGv0dfR6VbEPr1O8vqIn5uGSunF5WiQxrsi4ihVxkpqSeX4In/PCnXkXZF/TQJS1DH73uwBhqShaj82J7On6n4TLVKy9t/A5e5NTAE5ypssaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d6dff70000001748-ad-6615105f05cb From: Honggyu Kim To: SeongJae Park Cc: damon@lists.linux.dev, linux-mm@kvack.org, akpm@linux-foundation.org, apopple@nvidia.com, baolin.wang@linux.alibaba.com, dave.jiang@intel.com, hyeongtak.ji@sk.com, kernel_team@skhynix.com, linmiaohe@huawei.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, mhiramat@kernel.org, rakie.kim@sk.com, rostedt@goodmis.org, surenb@google.com, yangx.jy@fujitsu.com, ying.huang@intel.com, ziy@nvidia.com, 42.hyeyoo@gmail.com, art.jeongseob@gmail.com, Honggyu Kim Subject: Re: [RFC PATCH v3 5/7] mm/damon/paddr: introduce DAMOS_MIGRATE_COLD action for demotion Date: Tue, 9 Apr 2024 18:54:14 +0900 Message-ID: <20240409095418.3051-1-honggyu.kim@sk.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20240408175228.91414-1-sj@kernel.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEIsWRmVeSWpSXmKPExsXC9ZZnkW6CgGiawduDzBYTewws5qxfw2ax 60aIxf0Hr9kt/u89xmjx5P9vVosTNxvZLDq/L2WxuLxrDpvFvTX/WS2OrD/LYrH57Blmi8XL 1Sz2dTxgsjj89Q2TxeRLC9gsXkw5w2hxctZkFovZR++xOwh7LD39hs1jQxOQ2DnrLrtHy75b 7B4LNpV6tBx5y+qxeM9LJo9NqzrZPDZ9msTucWLGbxaPnQ8tPV5snsno0dv8js3j8ya5AL4o LpuU1JzMstQifbsEroz2iY8ZC07pVux4/J+9gfGeUhcjB4eEgInEpW6hLkZOMHPOo9csIDab gJrElZeTmEBsEQFFiXOPL7J2MXJxMAvsYZHoOvWGHSQhLJAg0XbjIyvIHBYBVYn7CxxBwrwC ZhJ/1u9kg5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VuYcYJTiYlUR4g00F04R4UxIr q1KL8uOLSnNSiw8xSnOwKInzeoWnJggJpCeWpGanphakFsFkmTg4pRoY7b/XJ9fJXJ6y+eL5 sGA2n38FZwT7xU5O+vbgTtuh3tqd03SOXNE/d7/t8zRBiZ62A/7tM8yOXZG6aDfl8IS2t/kq JQkL9766uPhTmMcES7G1LFNbp4vcc3vnx9n56lh5YW2Go7Dh7aeu5lZ1Z/vupD/wU1eRY039 c9ppm2bgjRX7Ly+z4Sl/psRSnJFoqMVcVJwIAAtzjpaxAgAA X-CFilter-Loop: Reflected Hi SeongJae, On Mon, 8 Apr 2024 10:52:28 -0700 SeongJae Park wrote: > On Mon, 8 Apr 2024 21:06:44 +0900 Honggyu Kim wrote: > > > On Fri, 5 Apr 2024 12:24:30 -0700 SeongJae Park wrote: > > > On Fri, 5 Apr 2024 15:08:54 +0900 Honggyu Kim wrote: > [...] > > > > Here is one of the example usage of this 'migrate_cold' action. > > > > > > > > $ cd /sys/kernel/mm/damon/admin/kdamonds/ > > > > $ cat contexts//schemes//action > > > > migrate_cold > > > > $ echo 2 > contexts//schemes//target_nid > > > > $ echo commit > state > > > > $ numactl -p 0 ./hot_cold 500M 600M & > > > > $ numastat -c -p hot_cold > > > > > > > > Per-node process memory usage (in MBs) > > > > PID Node 0 Node 1 Node 2 Total > > > > -------------- ------ ------ ------ ----- > > > > 701 (hot_cold) 501 0 601 1101 > > > > > > > > Since there are some common routines with pageout, many functions have > > > > similar logics between pageout and migrate cold. > > > > > > > > damon_pa_migrate_folio_list() is a minimized version of > > > > shrink_folio_list(), but it's minified only for demotion. > > > > > > MIGRATE_COLD is not only for demotion, right? I think the last two words are > > > better to be removed for reducing unnecessary confuses. > > > > You mean the last two sentences? I will remove them if you feel it's > > confusing. > > Yes. My real intended suggestion was 's/only for demotion/only for > migration/', but entirely removing the sentences is also ok for me. Ack. > > > > > > > > > > Signed-off-by: Honggyu Kim > > > > Signed-off-by: Hyeongtak Ji > > > > --- > > > > include/linux/damon.h | 2 + > > > > mm/damon/paddr.c | 146 ++++++++++++++++++++++++++++++++++++++- > > > > mm/damon/sysfs-schemes.c | 4 ++ > > > > 3 files changed, 151 insertions(+), 1 deletion(-) > [...] > > > > --- a/mm/damon/paddr.c > > > > +++ b/mm/damon/paddr.c > [...] > > > > +{ > > > > + unsigned int nr_succeeded; > > > > + nodemask_t allowed_mask = NODE_MASK_NONE; > > > > + > > > > > > I personally prefer not having empty lines in the middle of variable > > > declarations/definitions. Could we remove this empty line? > > > > I can remove it, but I would like to have more discussion about this > > issue. The current implementation allows only a single migration > > target with "target_nid", but users might want to provide fall back > > migration target nids. > > > > For example, if more than two CXL nodes exist in the system, users might > > want to migrate cold pages to any CXL nodes. In such cases, we might > > have to make "target_nid" accept comma separated node IDs. nodemask can > > be better but we should provide a way to change the scanning order. > > > > I would like to hear how you think about this. > > Good point. I think we could later extend the sysfs file to receive the > comma-separated numbers, or even mask. For simplicity, adding sysfs files > dedicated for the different format of inputs could also be an option (e.g., > target_nids_list, target_nids_mask). But starting from this single node as is > now looks ok to me. If you think we can start from a single node, then I will keep it as is. But are you okay if I change the same 'target_nid' to accept comma-separated numbers later? Or do you want to introduce another knob such as 'target_nids_list'? What about rename 'target_nid' to 'target_nids' at the first place? > [...] > > > > + /* 'folio_list' is always empty here */ > > > > + > > > > + /* Migrate folios selected for migration */ > > > > + nr_migrated += migrate_folio_list(&migrate_folios, pgdat, target_nid); > > > > + /* Folios that could not be migrated are still in @migrate_folios */ > > > > + if (!list_empty(&migrate_folios)) { > > > > + /* Folios which weren't migrated go back on @folio_list */ > > > > + list_splice_init(&migrate_folios, folio_list); > > > > + } > > > > > > Let's not use braces for single statement > > > (https://docs.kernel.org/process/coding-style.html#placing-braces-and-spaces). > > > > Hmm.. I know the convention but left it as is because of the comment. > > If I remove the braces, it would have a weird alignment for the two > > lines for comment and statement lines. > > I don't really hate such alignment. But if you don't like it, how about moving > the comment out of the if statement? Having one comment for one-line if > statement looks not bad to me. Ack. I will manage this in the next revision. > > > > > > + > > > > + try_to_unmap_flush(); > > > > + > > > > + list_splice(&ret_folios, folio_list); > > > > > > Can't we move remaining folios in migrate_folios to ret_folios at once? > > > > I will see if it's possible. > > Thank you. Not a strict request, though. > > [...] > > > > + nid = folio_nid(lru_to_folio(folio_list)); > > > > + do { > > > > + struct folio *folio = lru_to_folio(folio_list); > > > > + > > > > + if (nid == folio_nid(folio)) { > > > > + folio_clear_active(folio); > > > > > > I think this was necessary for demotion, but now this should be removed since > > > this function is no more for demotion but for migrating random pages, right? > > > > Yeah, it can be removed because we do migration instead of demotion, > > but I need to make sure if it doesn't change the performance evaluation > > results. > > Yes, please ensure the test results are valid :) Sure. Thanks for your review in details! Please note that I will be out of office this week so won't be able to answer quickly. Thanks, Honggyu > > Thanks, > SJ > > [...] >