From nobody Sun May 19 16:31:40 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3ABD120319; Fri, 26 Apr 2024 19:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161181; cv=none; b=ie6/QaaTWw9kigJBQSEfeUuDrHw+Dadnnz4QpW/unJPOlf5YtJdZICZB8WrQoa5pOfORmEUGN8GpL51IuCTfnIFCkkyuSKYCHNm8yXPlNO5EccjPFuJ5qcRKhizgfJxSAaQnsa47151MzfYCZ96zTdQFjuNW81rLWW0uDkLi4AU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161181; c=relaxed/simple; bh=q0ougyw7Umb7GSxVQouuuoREw7O7beWYRZUPMMfuCtA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FVWAT+WXSSnuXkAZLVdGzb6OS8b9xoZHChOWbtRSMLw+cdoDBgivIcIBULc7ht4RZ54969tA9KliDEBnj//SQl3z3CECYZj6lM88xKT4ISYHij3zkkc+/tPxs8llKnFrGeKtBDOr+oDeq/h5nIro6HO+oowGxt0HRq+UCuFWnMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NuBZFNFW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NuBZFNFW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EF07C2BD10; Fri, 26 Apr 2024 19:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714161180; bh=q0ougyw7Umb7GSxVQouuuoREw7O7beWYRZUPMMfuCtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NuBZFNFW+n7ysMXFK5xQPz08L8HRsd3vbiGBevHLvdhLazTjRtvHpHpeZTEURwoY6 SIKHqPQbzTtOt5nTuqBxLnRdn2+xnW6Sq5Ehcg9D/xOP10v4Uw2VklESDv5RS5kWLK kCdl7iIr1QMfKYlwBMCTiQISFW7CiIBG0jddZemWXJNNTm9HROiQxlqWr6DvdqefiG gvxDL9uuYv4JeU398CZUPWMGostf6585yV9p1rNjCGF4Jeo6Bo7zHe/KZNW8HbrmOd j/jnPzerkABscsKz8LT5yYfJFhEfikGBob9CzFCIJLZY6utDk+rDtETC8OAoshJzCE SZ8jSW88XABLw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Honggyu Kim Subject: [PATCH 1/7] mm/damon/paddr: implement damon_folio_young() Date: Fri, 26 Apr 2024 12:52:40 -0700 Message-Id: <20240426195247.100306-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426195247.100306-1-sj@kernel.org> References: <20240426195247.100306-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" damon_pa_young() receives physical address, get the folio covering the address, and show if the folio is accessed since the last check. A following commit will reuse the internal logic for checking access to a given folio. To avoid duplication of the code, split the internal logic. Also, change the rmap walker function's name from __damon_pa_young() to damon_folio_young_one(), following the change of the caller's name and the naming rule that more commonly used by other rmap walkers. Signed-off-by: SeongJae Park Tested-by: Honggyu Kim --- mm/damon/paddr.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 5e6dc312072cd..25c3ba2a9eaf4 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -79,8 +79,8 @@ static void damon_pa_prepare_access_checks(struct damon_c= tx *ctx) } } =20 -static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *v= ma, - unsigned long addr, void *arg) +static bool damon_folio_young_one(struct folio *folio, + struct vm_area_struct *vma, unsigned long addr, void *arg) { bool *accessed =3D arg; DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, addr, 0); @@ -111,38 +111,44 @@ static bool __damon_pa_young(struct folio *folio, str= uct vm_area_struct *vma, return *accessed =3D=3D false; } =20 -static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) +static bool damon_folio_young(struct folio *folio) { - struct folio *folio =3D damon_get_folio(PHYS_PFN(paddr)); bool accessed =3D false; struct rmap_walk_control rwc =3D { .arg =3D &accessed, - .rmap_one =3D __damon_pa_young, + .rmap_one =3D damon_folio_young_one, .anon_lock =3D folio_lock_anon_vma_read, }; bool need_lock; =20 - if (!folio) - return false; - if (!folio_mapped(folio) || !folio_raw_mapping(folio)) { if (folio_test_idle(folio)) - accessed =3D false; + return false; else - accessed =3D true; - goto out; + return true; } =20 need_lock =3D !folio_test_anon(folio) || folio_test_ksm(folio); if (need_lock && !folio_trylock(folio)) - goto out; + return false; =20 rmap_walk(folio, &rwc); =20 if (need_lock) folio_unlock(folio); =20 -out: + return accessed; +} + +static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) +{ + struct folio *folio =3D damon_get_folio(PHYS_PFN(paddr)); + bool accessed; + + if (!folio) + return false; + + accessed =3D damon_folio_young(folio); *folio_sz =3D folio_size(folio); folio_put(folio); return accessed; --=20 2.39.2 From nobody Sun May 19 16:31:40 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08338224D2; Fri, 26 Apr 2024 19:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161182; cv=none; b=G209bQELee74JbQ4ihPXRuqpZ6KdqtsxJM1Wz+wlhdKy3Il3naYnEXV9K1gVX7GxpjDZFDG79zIMyhAYBF0paQW0RyF56kD518qHY5B8IyoUscIIP5bocEizMSvAYYb9H9U7bSCGKmCUs26PU3x+XJ/ZmJIYCi9MMGpRG5MUkEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161182; c=relaxed/simple; bh=2SdOrYSwPaCcW6lpCEqRPan9kbnzKrEsfc9vQDQS2P4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pCNJuDHum9+pbM0tTf1ls08f2gcEzuAHshU19mLUqQCyjOfICoQjG1Zv9NQ31SH9nemRbzJlUPzZwGNEZfUdj2yjYR0AW/hStNWlId+K5W6d2ESuYfbUv6YFifRK9bSCRQyKGRXOj3jdu2Tee1Cvzj5/fuMxk+2JRkyEe6LN0Js= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q2nYt7mW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q2nYt7mW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09FFEC32783; Fri, 26 Apr 2024 19:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714161181; bh=2SdOrYSwPaCcW6lpCEqRPan9kbnzKrEsfc9vQDQS2P4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2nYt7mWd13qgtKTEmdZ8bbPoMfYI4/cOsKLqW337FVMFVnXLzHas4Q3U7I8sR9Z9 acTnbyUuez7gsIQG1uH7YW6DXA+S5rVfeQ0tGBhTrPDECy5NqITSc0RYvKJiY1Sv2C CZUHHD8wpa421gUwEDHr6tOiBdbKORfwX5bL5imLi41RJ28KPLcRXdkDMfa1lROS64 gl2TbHvNv0P4Kq5NxFRbFiWfbHqm290wByZkMtJ7kN3GDgDsoIiQCf4ozaCuxsRysr YFNOXfG/yUIi63M0aNql8e5LePHrLd+73bb0cs3r9r1pkB6A6DeYp8JyfcYSDlUJjW e78umN2Oi8T7A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Honggyu Kim Subject: [PATCH 2/7] mm/damon/paddr: implement damon_folio_mkold() Date: Fri, 26 Apr 2024 12:52:41 -0700 Message-Id: <20240426195247.100306-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426195247.100306-1-sj@kernel.org> References: <20240426195247.100306-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" damon_pa_mkold() receives physical address, get the folio covering the address, and makes the folio as old. A following commit will reuse the internal logic for marking a given folio as old. To avoid duplication of the code, split the internal logic. Also, change the rmap walker function's name from __damon_pa_mkold() to damon_folio_mkold_one(), following the change of the caller's name and the naming rule that more commonly used by other rmap walkers. Signed-off-by: SeongJae Park Tested-by: Honggyu Kim --- mm/damon/paddr.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 25c3ba2a9eaf4..310b803c62779 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -16,8 +16,8 @@ #include "../internal.h" #include "ops-common.h" =20 -static bool __damon_pa_mkold(struct folio *folio, struct vm_area_struct *v= ma, - unsigned long addr, void *arg) +static bool damon_folio_mkold_one(struct folio *folio, + struct vm_area_struct *vma, unsigned long addr, void *arg) { DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, addr, 0); =20 @@ -31,33 +31,38 @@ static bool __damon_pa_mkold(struct folio *folio, struc= t vm_area_struct *vma, return true; } =20 -static void damon_pa_mkold(unsigned long paddr) +static void damon_folio_mkold(struct folio *folio) { - struct folio *folio =3D damon_get_folio(PHYS_PFN(paddr)); struct rmap_walk_control rwc =3D { - .rmap_one =3D __damon_pa_mkold, + .rmap_one =3D damon_folio_mkold_one, .anon_lock =3D folio_lock_anon_vma_read, }; bool need_lock; =20 - if (!folio) - return; - if (!folio_mapped(folio) || !folio_raw_mapping(folio)) { folio_set_idle(folio); - goto out; + return; } =20 need_lock =3D !folio_test_anon(folio) || folio_test_ksm(folio); if (need_lock && !folio_trylock(folio)) - goto out; + return; =20 rmap_walk(folio, &rwc); =20 if (need_lock) folio_unlock(folio); =20 -out: +} + +static void damon_pa_mkold(unsigned long paddr) +{ + struct folio *folio =3D damon_get_folio(PHYS_PFN(paddr)); + + if (!folio) + return; + + damon_folio_mkold(folio); folio_put(folio); } =20 --=20 2.39.2 From nobody Sun May 19 16:31:40 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8A8E250EC; Fri, 26 Apr 2024 19:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161182; cv=none; b=jnLqtN6vs7jtvIvFJSQIsIPm2/rd+CNrK1fYdgVqv63F90NVA0tU7WcOeKCFvV1kpvxAtB147+HfdOGComeZlc+wzGtILKOzHU1l0DF0JLEmi8AKDIh29+nh0XJzW1uxEsIj4OoiXMErqcnfTI64d+K0ckKyso77tBNcsElgBAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161182; c=relaxed/simple; bh=46Ldc4399x5vGxfdUW5g3TDQSnO265hzzOnyBh65g88=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T9XkKsZ85ICIfGv25PTN3rFHaLeuRrNXrR8LqU6EeF7xgroCuwErk1acMGKJNviHcP+bf50fBLpzHycW4SJw9vT26OwT6jnYTGlRvFhEN3XrlKyUKp03d9NMND0gYBcgXD5Qh9n7ll4BsI20WeiCXBpdDO2A+OeoA4XvgGixq7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RHJRU25s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RHJRU25s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA417C32782; Fri, 26 Apr 2024 19:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714161182; bh=46Ldc4399x5vGxfdUW5g3TDQSnO265hzzOnyBh65g88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RHJRU25sNcZ3kflmc9l32q9W9O5dkcFuYIFx4htbsFTTzuLcIKoq9OYjbHSgGAoxN wBr7lR9mubXiLcmQPxKdxlvdKtYeIYiPQ7w48zCP0wR2rlG9ASPxuxwMIucHe+55b+ PwKyiWbJnIBFXfDxrmCkwgTTKrd1pSIv/QPS29wLCzkg20hJXH6VeSafdXfQ7AD30s rAEh9hr00Eso94b+xhsEI0G0OE8QVQmM59lL2AvNN9bdQJlGnTWcKsVnLcWnbjGBpA SmA35yWD0jqw4y4ByPWOtykdRf1ZPqrAfDlIs3DlgjtwHhAVkseI7H82QAVJ9/txXc y0gQttRPRGmbw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Honggyu Kim Subject: [PATCH 3/7] mm/damon: add DAMOS filter type YOUNG Date: Fri, 26 Apr 2024 12:52:42 -0700 Message-Id: <20240426195247.100306-4-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426195247.100306-1-sj@kernel.org> References: <20240426195247.100306-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Define yet another DAMOS filter type, YOUNG. Like anon and memcg, the type of filter will be applied to each page in the memory region, and see if the page is accessed since the last check. Based on the 'matching' parameter, the page is filtered out or in. Note that this commit is adding only the type definition. The implementation should be made by DAMON operations sets. A commit for the implementation on 'paddr' DAMON operations set will follow. Signed-off-by: SeongJae Park Tested-by: Honggyu Kim --- include/linux/damon.h | 2 ++ mm/damon/sysfs-schemes.c | 1 + 2 files changed, 3 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 886d07294f4e7..f7da65e1ac041 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -297,6 +297,7 @@ struct damos_stat { * enum damos_filter_type - Type of memory for &struct damos_filter * @DAMOS_FILTER_TYPE_ANON: Anonymous pages. * @DAMOS_FILTER_TYPE_MEMCG: Specific memcg's pages. + * @DAMOS_FILTER_TYPE_YOUNG: Recently accessed pages. * @DAMOS_FILTER_TYPE_ADDR: Address range. * @DAMOS_FILTER_TYPE_TARGET: Data Access Monitoring target. * @NR_DAMOS_FILTER_TYPES: Number of filter types. @@ -315,6 +316,7 @@ struct damos_stat { enum damos_filter_type { DAMOS_FILTER_TYPE_ANON, DAMOS_FILTER_TYPE_MEMCG, + DAMOS_FILTER_TYPE_YOUNG, DAMOS_FILTER_TYPE_ADDR, DAMOS_FILTER_TYPE_TARGET, NR_DAMOS_FILTER_TYPES, diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 53a90ac678fb9..bea5bc52846a6 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -343,6 +343,7 @@ static struct damon_sysfs_scheme_filter *damon_sysfs_sc= heme_filter_alloc(void) static const char * const damon_sysfs_scheme_filter_type_strs[] =3D { "anon", "memcg", + "young", "addr", "target", }; --=20 2.39.2 From nobody Sun May 19 16:31:40 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC3422577B; Fri, 26 Apr 2024 19:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161183; cv=none; b=ten+jbFetPvi/pMvlusHwTYrwcpT98Q7PYcLCtRiBn4w5MCSZwsDd3RiS8WvWbmF5LRvlsBi9jLPHiXbDv63KJ5NxDGDGDDmNjoDGjX1CwWgvhdQ6rUZog/JCnPAB7BqqWU7W8yzovV4nVP+NhQUSlSInlGDgQOrMUZ28yFu0HM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161183; c=relaxed/simple; bh=7DU4R9EMCr6vh5Iz6aftKnw6t4Q6vqj1u1UiBTV/q1o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kJa/C2k7f5iM1OPyxHmKVM7QAb2PNSzFqIVis/qzK0FlGxxdVcJ5C3qo0EpmCwNG0ozPlhHU1kXBkR0C7TWc9pmG0D/39O4Wnpgj08V4me4fMTUYlcgnk6ibcm7ogTznlJJG84KHoeXBJtQYIAWscSDZlsLVUtWc/6DCpL/bauY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eLYNgvdE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eLYNgvdE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65BCEC32786; Fri, 26 Apr 2024 19:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714161182; bh=7DU4R9EMCr6vh5Iz6aftKnw6t4Q6vqj1u1UiBTV/q1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eLYNgvdEpIUlrtvvzOSTquF5rJ5xcLuqkYJPZFObcmdIo933ByRPadsnhaF0urhMB YXynjowLyC6EWBNiJliRtGXw029dtrwOIwudD5yaPt4yNHLnmXqlD2DS5ggEWQTgqN rIQJYVPRkqgRVjpkkKGWniPqQTrUE8DeZesGCd6g/lF2VqnM4aOXomTQ3nVbj7zqkn rBZB1FjzeYMIbgMTBCVONBq+8wGBdUGzknY4oZRM5Ucu86v2w+Ho8KeAZlGuURO4pB 1vZNtX39au9u7qXJ97WSUfJnGkvy1iwJ8AlfyUQZzM9K+AbRij2G3wAzPxqfSLFBZD 3LUwJAuzP1l9A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Honggyu Kim Subject: [PATCH 4/7] mm/damon/paddr: implement DAMOS filter type YOUNG Date: Fri, 26 Apr 2024 12:52:43 -0700 Message-Id: <20240426195247.100306-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426195247.100306-1-sj@kernel.org> References: <20240426195247.100306-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DAMOS filter of type YOUNG is defined, but not yet implemented by any DAMON operations set. Add the implementation on 'paddr', the DAMON operations set for the physical address space. Signed-off-by: SeongJae Park Tested-by: Honggyu Kim --- mm/damon/paddr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 310b803c62779..5685ba485097d 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -214,6 +214,11 @@ static bool __damos_pa_filter_out(struct damos_filter = *filter, matched =3D filter->memcg_id =3D=3D mem_cgroup_id(memcg); rcu_read_unlock(); break; + case DAMOS_FILTER_TYPE_YOUNG: + matched =3D damon_folio_young(folio); + if (matched) + damon_folio_mkold(folio); + break; default: break; } --=20 2.39.2 From nobody Sun May 19 16:31:40 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFF3F2C848; Fri, 26 Apr 2024 19:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161184; cv=none; b=WYk33sXD5uhO1wnnxi3X7569bTZuivmGoyqYsR+ZYnmWJDGllXE5z9G6YXkUBzhyWLEnX9DvG2wLdbNNZzuVePUoQfHbevQ+lnN+ppdvIt5Ix2K8eE1Akw2Y0pmil4goUK6PZywCG3y93XbSIK5Lk+hy0+qoBC5MhIW/qH/dT8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161184; c=relaxed/simple; bh=Dn52cDE5Pk1z+Ex2+NSRLPE8W1EnK4AAtmH09ziQ5Go=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qVD2SrJNY+RGJ7hABFpAixj9vrHClGpJCVthYwAediUUyGXAzirmvuSg3ho1V3ydim0CbMiw5L5d32aliNV9hJqb2VEfpWRD+DzxKYrCN04B+t6cI8W6q3GFSo+dNPYVB4sQWD1bxvNa9w6bedC8IziZ5tz5oVoDTf+inLXPWdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FaY7xpWf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FaY7xpWf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11159C113CD; Fri, 26 Apr 2024 19:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714161183; bh=Dn52cDE5Pk1z+Ex2+NSRLPE8W1EnK4AAtmH09ziQ5Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FaY7xpWfrq2qjeYXOwwOAZVETK3xRZ4BxENUObbcz7u+jRxkYrBEvm858VQn6g3W7 Vekg9u8ya7fwc0J4yH0UOxjzG6Np4hOXm+/eQoHQTN+mVOAaxSNhpFobPivRMWZk+0 JuamddyfKk4YlShNuwYzemkcyyidfA0P/kdAWMRGBjCvHKAetm3nVO91ytlCvyPQFA Ugrhr/lf5hM7Q5BInN/rFbGaTqlMOiNKhBOYrPamVy11SiKWIZr/aP//bGpfDO3Zmu gQuVQ1NTskmEnwjxWxDMtkPsZOhqTng13jmR1COz8BfNuKdpCD8esBcuhvZ3RDnvOp qf21CwHedF6lg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] Docs/mm/damon/design: document 'young page' type DAMOS filter Date: Fri, 26 Apr 2024 12:52:44 -0700 Message-Id: <20240426195247.100306-6-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426195247.100306-1-sj@kernel.org> References: <20240426195247.100306-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update DAMON design document for the newly added DAMOS filter type, 'young page'. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index 5620aab9b3850..f2baf617184d0 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -461,15 +461,17 @@ number of filters for each scheme. Each filter speci= fies the type of target memory, and whether it should exclude the memory of the type (filter-out),= or all except the memory of the type (filter-in). =20 -Currently, anonymous page, memory cgroup, address range, and DAMON monitor= ing -target type filters are supported by the feature. Some filter target types -require additional arguments. The memory cgroup filter type asks users to -specify the file path of the memory cgroup for the filter. The address ra= nge -type asks the start and end addresses of the range. The DAMON monitoring -target type asks the index of the target from the context's monitoring tar= gets -list. Hence, users can apply specific schemes to only anonymous pages, -non-anonymous pages, pages of specific cgroups, all pages excluding those = of -specific cgroups, pages in specific address range, pages in specific DAMON +Currently, anonymous page, memory cgroup, young page, address range, and D= AMON +monitoring target type filters are supported by the feature. Some filter +target types require additional arguments. The memory cgroup filter type = asks +users to specify the file path of the memory cgroup for the filter. The +address range type asks the start and end addresses of the range. The DAM= ON +monitoring target type asks the index of the target from the context's +monitoring targets list. Hence, users can apply specific schemes to only +anonymous pages, non-anonymous pages, pages of specific cgroups, all pages +excluding those of specific cgroups, pages that not accessed after the last +access check from the scheme, pages that accessed after the last access ch= eck +from the scheme, pages in specific address range, pages in specific DAMON monitoring targets, and any combination of those. =20 To handle filters efficiently, the address range and DAMON monitoring targ= et --=20 2.39.2 From nobody Sun May 19 16:31:40 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DD8C3613E; Fri, 26 Apr 2024 19:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161184; cv=none; b=hUQl87jsTzzsh9i2CyCf50VKnDOYpLnTj15ZG/pduc8WaQEgXZNlXeTT2i4UjPl/xSwk170WW/vN/Tq974jVJa3soCi333gjZu2PJ1zEgU2SiDl+25+rr8+OOdFWUGcHjKUo1HOSRhC0gS3p97cWSzq/jX8HHLyd7SACQ9ibCBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161184; c=relaxed/simple; bh=K2q9FissW13tAkvxEMeW2S5JbkJ5qv3UfNIiwo/yV/I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ffCI8aT8qx6P5Xqmp5lG0vnru2ZvlSI3UXabwvuYUzxsEs6oEou6AsVQzOms3RUYODxZEA1DXAQvFCiKg4dOmLaXSvaATAQkszBCAJq6pQtcXoWZmHor3HIwQCVSuZP9sipDxPU+gyiGz41/3/sUazQKwY+dfNgXfaVCzLI5VdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DSFNDYcZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DSFNDYcZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3142C2BD10; Fri, 26 Apr 2024 19:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714161184; bh=K2q9FissW13tAkvxEMeW2S5JbkJ5qv3UfNIiwo/yV/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DSFNDYcZ5ydHl9BLQEPGlilvTLW2NF0PHASHNaeYYzH/IQkb7TIhayU7DHFGXKWuq yDnjWbS6g5F/zwAj2dSG84H1DBt9ceqztSEcropReTs4M7kuxPV9TThRzeKu/JuD0U h2gjAkllDCJQSEr4OWpX16oU+h/cobOIqx/kvuZr/ZPvqRxLsdDz1TWq58Y1uSjTdB KG2/YRUz3XFQ2lUMj8D4sUDlvXOvo0ZwJYL+Zh8slDqm6FtGDbhgNPxTbZ/CqoMjY7 4C07ybL+Udwe/39rogZpBtUgPe9/Cefr/RZWfqMfcHwYR7QnGWrNRTLKkjCC5eUayp wgHoLmDGbo8Nw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] Docs/admin-guide/mm/damon/usage: update for young page type DAMOS filter Date: Fri, 26 Apr 2024 12:52:45 -0700 Message-Id: <20240426195247.100306-7-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426195247.100306-1-sj@kernel.org> References: <20240426195247.100306-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update DAMON usage document for the newly added DAMOS filter type, 'young page'. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/a= dmin-guide/mm/damon/usage.rst index 6fce035fdbf5c..69bc8fabf3781 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -410,19 +410,19 @@ in the numeric order. =20 Each filter directory contains six files, namely ``type``, ``matcing``, ``memcg_path``, ``addr_start``, ``addr_end``, and ``target_idx``. To ``ty= pe`` -file, you can write one of four special keywords: ``anon`` for anonymous p= ages, -``memcg`` for specific memory cgroup, ``addr`` for specific address range = (an -open-ended interval), or ``target`` for specific DAMON monitoring target -filtering. In case of the memory cgroup filtering, you can specify the me= mory -cgroup of the interest by writing the path of the memory cgroup from the -cgroups mount point to ``memcg_path`` file. In case of the address range -filtering, you can specify the start and end address of the range to -``addr_start`` and ``addr_end`` files, respectively. For the DAMON monito= ring -target filtering, you can specify the index of the target between the list= of -the DAMON context's monitoring targets list to ``target_idx`` file. You c= an -write ``Y`` or ``N`` to ``matching`` file to filter out pages that does or= does -not match to the type, respectively. Then, the scheme's action will not be -applied to the pages that specified to be filtered out. +file, you can write one of five special keywords: ``anon`` for anonymous p= ages, +``memcg`` for specific memory cgroup, ``young`` for young pages, ``addr`` = for +specific address range (an open-ended interval), or ``target`` for specific +DAMON monitoring target filtering. In case of the memory cgroup filtering= , you +can specify the memory cgroup of the interest by writing the path of the m= emory +cgroup from the cgroups mount point to ``memcg_path`` file. In case of the +address range filtering, you can specify the start and end address of the = range +to ``addr_start`` and ``addr_end`` files, respectively. For the DAMON +monitoring target filtering, you can specify the index of the target betwe= en +the list of the DAMON context's monitoring targets list to ``target_idx`` = file. +You can write ``Y`` or ``N`` to ``matching`` file to filter out pages that= does +or does not match to the type, respectively. Then, the scheme's action wi= ll +not be applied to the pages that specified to be filtered out. =20 For example, below restricts a DAMOS action to be applied to only non-anon= ymous pages of all memory cgroups except ``/having_care_already``.:: --=20 2.39.2 From nobody Sun May 19 16:31:40 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 021BD374EB; Fri, 26 Apr 2024 19:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161185; cv=none; b=MX38i297PvQ9Fphs5g4ngqFiTRBy1O0QcS0rpjLVXymhvg+E8Z7MaRnZRHLUaGJtT9aPQSHxpWS/gS7wsxs6VJGD0LX87kcXy6Bnn7AS0XtoAPjpNWhSeF6Jmd6Mixn29BvMscEkgBCiuzAvlfv4bUl/+9NG6k+06Y+mW4QwTTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714161185; c=relaxed/simple; bh=RA6PboPvhcVkcAJe7wxUVuzFYhYpojur65LWu1bwj5g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JSbFoHqWX41idCFENU34nZP9FURsECkDKmeXhiv9Q9AKlgBDhtF2sNu2J2YeB3S7qKMJPcVmRzGVthFD7NOaWqckgfXLsznVjTcEk3raHXErnMYCGi9UuUx3XiC7N2wi5zR3ZPQvYUzhIKdZn63rULA5QaWdZx2EPbMEjeg+qqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FG1/Aps5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FG1/Aps5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EEBDC32786; Fri, 26 Apr 2024 19:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714161184; bh=RA6PboPvhcVkcAJe7wxUVuzFYhYpojur65LWu1bwj5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FG1/Aps5GdL0Ks9HkrFAnjcXf1jDcQeMztQLEUxPkyemkrNBlIsivEPFXVcOTghO8 nYfvAmqq/jLd0QJIQ7nJWQhtzoxG+eMN/rkImGY83QwoclWSEY/DowaafLa+0HVTQf GO9/K0J0GT5WbYUo6R9Y15igkF7m9WVDW/x0amkvWAyoOxkgqKD5FdSFSDToF9Rv3d DDK8WT1EKG4bulBdxb5t2B3atQrNwwnxI5TBfTtcbYwYs2QhPLQHUFGYqqtq1JOxYc fuwBZnSGjFPy/RSxgjOPphtBHKV7Tgi0eh7aQEXWKpVV463lTnG0aVDIPqU+DNk87B X5+ZiaS3UEROA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] Docs/ABI/damon: update for 'youg page' type DAMOS filter Date: Fri, 26 Apr 2024 12:52:46 -0700 Message-Id: <20240426195247.100306-8-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240426195247.100306-1-sj@kernel.org> References: <20240426195247.100306-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update DAMON ABI document for the newly added DAMO filter type, 'young page'. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentatio= n/ABI/testing/sysfs-kernel-mm-damon index dad4d5ffd7865..cef6e1d20b185 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -314,9 +314,9 @@ Date: Dec 2022 Contact: SeongJae Park Description: Writing to and reading from this file sets and gets the type = of the memory of the interest. 'anon' for anonymous pages, - 'memcg' for specific memory cgroup, 'addr' for address range - (an open-ended interval), or 'target' for DAMON monitoring - target can be written and read. + 'memcg' for specific memory cgroup, 'young' for young pages, + 'addr' for address range (an open-ended interval), or 'target' + for DAMON monitoring target can be written and read. =20 What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//fi= lters//memcg_path Date: Dec 2022 --=20 2.39.2