From patchwork Mon Mar 11 20:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13589314 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 4E061C5475B for ; Mon, 11 Mar 2024 20:46:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80FEC6B0121; Mon, 11 Mar 2024 16:46:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BF846B0122; Mon, 11 Mar 2024 16:46:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 687146B0123; Mon, 11 Mar 2024 16:46:01 -0400 (EDT) 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 576F16B0121 for ; Mon, 11 Mar 2024 16:46:01 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D42DC80442 for ; Mon, 11 Mar 2024 20:46:00 +0000 (UTC) X-FDA: 81885940080.29.3DCA7CF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 35F1740005 for ; Mon, 11 Mar 2024 20:45:59 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=td2zp50G; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710189959; 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=zsIMqcXcJhWYwGsWoJ7Jty+YO7EmPMuaCF/Fyz2ErpY=; b=gZN2BtyPC7hyhiH9WvgOsGYJV22tyxukwbctnAebvDaYU0y0KDqpVLF3r3BdRzTE5S1BtC Bn4zCl4sMzxPwJKGRsZUoWHhCzqfhmMbLiN4f50cPLz1rGeuCrsLY9i9wrY2Yea3hYKJx7 IGhvKQCQYfVtF1NfQei8l1Dl9kHqiIs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=td2zp50G; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710189959; a=rsa-sha256; cv=none; b=fQrIMLiFDFJbXhQzpW382lhZaHP4KEbjOR5nE+Rs+E8LLiF/1bN67rtB5+V5GVUTK48JbB mmRCMzu9NRORSEUMICa9XCxy7bYxleBFEY3dtcELb3gC4QVGnjCu+VnVv4JVc2TTB/Rpqn ym2trpbp91bzq0iddu1R4xjYZSotWNM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4C67960F70; Mon, 11 Mar 2024 20:45:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71566C433F1; Mon, 11 Mar 2024 20:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710189958; bh=UuuVmb738blr2pB61tpIDxHO3PUHT5WkafuK2N/sEFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=td2zp50GqM3oHJlnxChlumu1/94uTMfKJnHQqsPeNz16+H1HzcBmhqMqLCxRnMiFT Y6uES8HIJjl+SwTjfzxxHWYm+HL7Z3FRMMt8SbJ9+lErFtA6V6qmidyHFf/O1V3gPa orY1Iuv9SnlsA0OQmdzQMplsz01BPPxSnwAYPYfxwwBz9IRoHNmVTJxQ6dT1g+Bpj/ Mb9LP01sZNLXrNR4tN0kff+1oELPmWRnlNUDDrlBJc+JG4mFHKCS6+OQ6l5d0PfAln GJtW1BE+HA8yuyegskWeYCXue0tYoSL4okBtkLcYd9TO1WiASR7WDg5ifi0C/Yigm1 fEFGgsi50HezQ== From: SeongJae Park To: Cc: honggyu.kim@sk.com, hyeongtak.ji@sk.com, kernel_team@skhynix.com, SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 1/4] mm/damon/paddr: implement damon_folio_young() Date: Mon, 11 Mar 2024 13:45:42 -0700 Message-Id: <20240311204545.47097-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311204545.47097-1-sj@kernel.org> References: <20240311204545.47097-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 35F1740005 X-Stat-Signature: 78tza8orq53eqj6q4jh75baoiiinzjjx X-Rspam-User: X-HE-Tag: 1710189958-839079 X-HE-Meta: U2FsdGVkX1+nXHs70msqFptwLCm/GTu1SDHEZgW+u9vjLhff3p82q9CRaDAb45uqzLdqniBSzwo3d/DTm8Z+cuxZtmTUA4owI90uCf8lv0g4Eke11hcBZzn0kR/2fbGRfrwfglMMbylg2j2oByLWWldw2vURpr2YTLzvDehDuNEPttJ/jDLhYecESTZEn1oPgU+MEmjuqjDxGgFKZ2m+okdVKKFIX5T0kqnOVt2ejxEfEOTPLQn9iSpW0M+hf1nVKJtQ+0CAKjoV8yNoUssA+WkB6HC9FCG2U5cjmrWDqkG+FrbFFVUdtGtiT5OWLLrxmpAz7zhm0J8tVPmalbngQspWvys0fIlQZbtQIMewbDLDfwMXhpSTfdk4qUJ2mQ6mieYXAa8jJZRYbLlIhyUjmPdjNu5SiqrFMds+C6VsetaXXdeOlE2T4gVmLZ6xf8RrzklqJ86Np+SeMu5Xk8zeaNAS9DKM1X+Zc6pmHe2wtkoSQiJUUU850u+J0cn2uuuBLDv3KZ8cpU8X4ZQXLTfHkahGw+04i5cDAnTmil8ww/LBj2l3blYF0kYVWm+St+z1cUe0VFnJdLRJnLMVfpIRrr4SxTFIdE4Q+U7CL+uJ060uqCf0g29SP7pIHp97SC4xXDfvbL47BaO8FqDuFTdKxymL4sdeKTaBk/jWrb3Rcu3wBud7lBWdme2BDKz65exffzyr5DtmJqIOOb1kGCk5R3A7e80g8UeMjoqhEGaMgt573GKJRwWBZ8kwZq/QzaAakehi5SKxRwVCvqe+QNX0xbFZ5+tn9xnOigfzAiGyCNGxvp7re/zMmajOWiqbArPmdN9JquKQn3zhsZ6avxJsyU2zFDWXXK3HCriAXARfl822dJmgVEn2ArH8R7zdqIqDJZlWCVVDBYuHRMKdgsoUlpJC9re2w/Y6FcExQqRIt2pL5ZSoP/6oYEWuB8GEFSVcCQXoNwR64yxrnulLbNn R+oEavCq P7Dbl 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: damon_pa_young() receives physical address, get the folio covering the address, and show if the folio is accessed since the last check. Split the internal logic for checking access to the given folio, for future reuse of the logic from code that already got the folio of the address of the question. Also, change the rmap walker function's name from __damon_pa_young() to damon_folio_young_one(), for consistent naming. Signed-off-by: SeongJae Park --- 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 5e6dc312072c..25c3ba2a9eaf 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -79,8 +79,8 @@ static void damon_pa_prepare_access_checks(struct damon_ctx *ctx) } } -static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, - 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 = arg; DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, addr, 0); @@ -111,38 +111,44 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, return *accessed == false; } -static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) +static bool damon_folio_young(struct folio *folio) { - struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); bool accessed = false; struct rmap_walk_control rwc = { .arg = &accessed, - .rmap_one = __damon_pa_young, + .rmap_one = damon_folio_young_one, .anon_lock = folio_lock_anon_vma_read, }; bool need_lock; - if (!folio) - return false; - if (!folio_mapped(folio) || !folio_raw_mapping(folio)) { if (folio_test_idle(folio)) - accessed = false; + return false; else - accessed = true; - goto out; + return true; } need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); if (need_lock && !folio_trylock(folio)) - goto out; + return false; rmap_walk(folio, &rwc); if (need_lock) folio_unlock(folio); -out: + return accessed; +} + +static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) +{ + struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); + bool accessed; + + if (!folio) + return false; + + accessed = damon_folio_young(folio); *folio_sz = folio_size(folio); folio_put(folio); return accessed; From patchwork Mon Mar 11 20:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13589315 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 3F1E7C54E5D for ; Mon, 11 Mar 2024 20:46:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D1D66B0124; Mon, 11 Mar 2024 16:46:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1319E6B0125; Mon, 11 Mar 2024 16:46:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9E576B0126; Mon, 11 Mar 2024 16:46:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D25076B0124 for ; Mon, 11 Mar 2024 16:46:04 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9A25480590 for ; Mon, 11 Mar 2024 20:46:04 +0000 (UTC) X-FDA: 81885940248.21.26AC881 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf07.hostedemail.com (Postfix) with ESMTP id A869040014 for ; Mon, 11 Mar 2024 20:46:02 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GLGmSRcn; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710189963; 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=J9pPeQJREYFyqXk82X+P+nuC2kp1HSgA9o6yP/N1kFw=; b=0HQYwTJ3GmN1UD3xCAzw/0KNPDnViyFx8ABcpG/s1jAH+kQcYvs21pd8xLg977ESqURyp8 9DunuSpapOnqoxLIX01Jujoid33opDGQlazI8aZVslQzgGWeOYTFzsAwdct51V2qI4mb2V SCXe2Ui7TRfC9FGKtEPM3Hy3nDDy9sw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GLGmSRcn; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710189963; a=rsa-sha256; cv=none; b=cAvtkT4behIdtDxRKHUGfSH3yHZ6E8oGOpnkUOxsU8XUpfcgqDcbxnMvIax3LP14AiKv0C ezjJfkITefyAxo18AKOxr6Q70fVV5ENh7+vOEdrrrMBtR4aE5SmgLB7POWB4Zd90lWAND5 IpaDpO7Mw0yOHDoBOyVEFaQv2hBr8x0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7452ACE128B; Mon, 11 Mar 2024 20:45:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31DA6C43330; Mon, 11 Mar 2024 20:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710189958; bh=hs6WHjvRmbJudqL2dyXIyQo9wvOsoRsFOzjiQ+KCyr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GLGmSRcnglAYFoU2dg75r1a8ysLh7ADCj/UW8G9z5COG6rYaR+oFko6vN9VFr0HdX 4SZcXS4bFb43mkNF98vNQx+WEswCo+05vvuffzq5yqSUZSkTl4as+le6RKnMR6dE6z brQ6rl5Cw21Bzgqntp4cOov83EzMP9hRMrtIDP5X2kGvwsLTiVYq0x4F55dVgJyNTc /hTvuGG7ALQGfh5WTTzWdXWKU1BgvJqyYu8vMMh+m4ur+ygHV0fUBVpfk/7oQuit74 vO/L0FIzD4tXZWhv5AAPmrdQbXVJNbH2NBYkV03VekMlczaoeAaLXulGrRlo2PdUmG uxELAUxdm0z6Q== From: SeongJae Park To: Cc: honggyu.kim@sk.com, hyeongtak.ji@sk.com, kernel_team@skhynix.com, SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 2/4] mm/damon/paddr: implement damon_folio_mkold() Date: Mon, 11 Mar 2024 13:45:43 -0700 Message-Id: <20240311204545.47097-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311204545.47097-1-sj@kernel.org> References: <20240311204545.47097-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: A869040014 X-Rspam-User: X-Stat-Signature: psq6nefntgtw1he4dkfzj3dmfzwujyb1 X-Rspamd-Server: rspam01 X-HE-Tag: 1710189962-919995 X-HE-Meta: U2FsdGVkX18VgRbFAAh/cYYA8BjR+5g/zcP6rjvryXYSsJ8I41Cs/dvuaoX6XuVw66f/2Kc5ZtAVlXb4pPPPo/NfqMXUmanPk+sHd5mDkdpcCeGMVOFmA3YlKi5kyNGNaYR2+ItJC4unqkUxc8B+YDzDbHLDO3tjQLS4nzDvo2ECJXzqvMjkm40J5duD/ssObzAK809BlWudQDxsQsxchI7VXTnE2WNqoApOBsPrgTQ//Kx5XLobvYy2V+u1Ta0tUTYo7ZM6Mg30wuWU/lV/j9tzWj6n2jolxQOWjT8WS64pdyOW7rCEwZTP4yTo/04retkYD3Ik788l2d4GWso6J2oqIDCqLULXBuojOVYSEaqUeybGIp83Hxp+ZXQraqV6YoFNG5sX/Xqpl3tkYpgTY2DRUd24CW91wxFSsP71g9ZtyDWPq5l7+LjRpyM7UuHQuUSSuw7OgPsAJyW8ZXucW6RZojuJ3OKhFzApINTDRRMRltLZmoHbzqiotwKJbApSIpQbWQyyJqWkULIuWgSjKmjfeKbuHV1tByzN92SN0wy0+ndLPCKWbP4yuqqMkHoIuDBMTOFepFIE2Ze7OAcZdJqd4zw0fMMjFQwh7GTt12JJiu8vvAn87h4qQmhUZrs4tJIrrgqWBaSdoW5oC+fi0/4GjdmehoW7mZb2Bc0+guBUV37oZuCsboC0JgmxegZzLz765qfjU0uXecxOF7SAsTjYe9FAcZUDcqkSPRMYYyKEQQheVEzgWyw7rKtWNewk1JitxfOjdCIIkAEuTQH9+cXkKGEXWWq+x+2QjCbPJgiyWbVkIGyqOFNmIETw96O+Tqhe5oRoNliJ/p0RncHBg+mMQ67+Kn9thdsZuvbE15zQiMG7UOdl488bfsZ/HpEUr3Fb5ocCQ2OjmNcok1LY8fu8RR4YbFyvT28J59huxw1llc3Ed33BQc98DvvrTQllTymAn5+aiGO6lm0ur+P njsMjdQQ IK7vt 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: damon_pa_mkold() receives a physical address, finds the folio covering the address, and makes the folio as old. Split the internal logic for checking access to the given folio, for future reuse of the logic. Also, change the name of the rmap walker from __damon_pa_mkold() to damon_folio_mkold_one() for more consistent naming. Signed-off-by: SeongJae Park --- 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 25c3ba2a9eaf..310b803c6277 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -16,8 +16,8 @@ #include "../internal.h" #include "ops-common.h" -static bool __damon_pa_mkold(struct folio *folio, struct vm_area_struct *vma, - 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); @@ -31,33 +31,38 @@ static bool __damon_pa_mkold(struct folio *folio, struct vm_area_struct *vma, return true; } -static void damon_pa_mkold(unsigned long paddr) +static void damon_folio_mkold(struct folio *folio) { - struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); struct rmap_walk_control rwc = { - .rmap_one = __damon_pa_mkold, + .rmap_one = damon_folio_mkold_one, .anon_lock = folio_lock_anon_vma_read, }; bool need_lock; - if (!folio) - return; - if (!folio_mapped(folio) || !folio_raw_mapping(folio)) { folio_set_idle(folio); - goto out; + return; } need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); if (need_lock && !folio_trylock(folio)) - goto out; + return; rmap_walk(folio, &rwc); if (need_lock) folio_unlock(folio); -out: +} + +static void damon_pa_mkold(unsigned long paddr) +{ + struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); + + if (!folio) + return; + + damon_folio_mkold(folio); folio_put(folio); } From patchwork Mon Mar 11 20:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13589313 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 737C7C54E66 for ; Mon, 11 Mar 2024 20:46:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3569D6B00F8; Mon, 11 Mar 2024 16:46:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 304636B00FA; Mon, 11 Mar 2024 16:46:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F6046B00F9; Mon, 11 Mar 2024 16:46:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 129226B0122 for ; Mon, 11 Mar 2024 16:46:02 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C8776160A11 for ; Mon, 11 Mar 2024 20:46:01 +0000 (UTC) X-FDA: 81885940122.16.D03A550 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 4D0C34000A for ; Mon, 11 Mar 2024 20:46:00 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uQNI7zWP; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710189960; a=rsa-sha256; cv=none; b=pa5NDxxm7eWtH0pDCQp7EMlxZS013cpa2TEZvumdhGoh8o9+Cz07/c57oB15XV55BoqKAF QKnYvpcfeIqla7D/IAq62tOBNTgzlW86V9NuNbPrG40I1t5YjWP7DFjIi2Z04XSIp06vQn Vl4DMXK1YU1NL0pTLqUq6HdxJUAN2Bw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uQNI7zWP; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710189960; 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=KW7k2yEs1IhNFivzAY8dNuVjq4m3njEs7sEi/VP7zyk=; b=s/UROI7MTVOyLFiZvnAp2lV2WXma072h+i8Hofo4yTy3RmOpY3R1NKiHqPcqUbZFKNfOBk wHR102fx8ejo3169kWRN+YIKlQmh1b9yNeU5n0QrGOfI1oXLtICnquuXdZxZztVj7Dx+QC pGhPgBygz8S/oTSXdbsxcOeO9GP3B38= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 966DA60FB1; Mon, 11 Mar 2024 20:45:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E78B2C43609; Mon, 11 Mar 2024 20:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710189959; bh=LO88k+dd/BebwXvUzvdC1iypWVc1Mb6U9juVYlKD5Nk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uQNI7zWPftUXcAfchepbgu8pxGBdbSEAdCcgL0ZjBDDyDymzJz0oEGIjl1OL+4pOt vUUdgM/UGEUp+bWCp1PrYYONwHar+psVszUNLtPUFGicKlMIC14alMAomTeoLBXq4d XRX42K0XQUw+pfrz7kvEdLVuEeV3Ro1H5LszW9h9yE52XzWosaYdLX41fQc16Rm/7U 9vWI5p8uNYo+yyJbbQn9XLalmRiILMwr+Y+u9ct79phKv9T9KKMbBHoMZLtdJsYsdX Nm02cMdyHt7eixGAwW9mDAePdrQmDJY0NEfiaDstr/nBbSy7p+j7D6ofARR9C4OLZ9 wEqqUEnKRvp4A== From: SeongJae Park To: Cc: honggyu.kim@sk.com, hyeongtak.ji@sk.com, kernel_team@skhynix.com, SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 3/4] mm/damon: add DAMOS filter type YOUNG Date: Mon, 11 Mar 2024 13:45:44 -0700 Message-Id: <20240311204545.47097-4-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311204545.47097-1-sj@kernel.org> References: <20240311204545.47097-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4D0C34000A X-Stat-Signature: bg7fgtthbtcxpcrmc3n38yyxuaufijg6 X-Rspam-User: X-HE-Tag: 1710189960-908530 X-HE-Meta: U2FsdGVkX18GySZN19KFBkij6W2fWHZSyTe16c3Zu6WfR65UE6mc07kUpj0mr0eOMCtm2nQqasd6IxXnNrX27mj79dqH1ua38ROFk2AoRUgwUDryMDCHtN/WhFsgf7607jIIWRaW+jk1dT6lKb5WmKuqQcRcD4QJBVsIETJhM5lvfBWI6/5Ux984lB1I+AF7ZCfbg42VqQoUClv/zB+lkgeuro/cj5v39Ec53O8wlLSzOayoNg2lZsFwIHpeaGBu4vt+MkMzL59woczI7HOOvrTUXW5QzPlCgUgc6Rmp+atUTteBJENINUdprOoC6uRhuv++kMEWHQtRnTVaAy1QA+HqjBRfNFD/om3qaytS6i8+nWzEXVza1pPfF3eHLTwviNsZ4sh0u7BxDfHUr/vglwwAycniyaD3SyTDAVEH5TVA84si7xeIpzMUmF1prIi8Fdw87Bb6SJHoKJ3245hrMiTdjVhMZmEFy71o4N0NsCmEgHf00RgallUGTTmtNo8w93BdBDoWT3KV67XKmDuRTRgAN11RwFK7ECiQfjLxAtLS2eTBBYkISaPe329LLrdOp2WVNqufb07sptzvMZjDO/7OgXv9tXawTI5Y2A9+5usL3ZR6th3bUeyCEHM7FxsGmOiTsphBd84iVUrK/eHxvIxOivOJ3prm0Obqvm0zhHSpsGPDXdWjy6XW01LGEfnWzAFIL8ZtWiFtdjSezyEtD51/nZ+n82v3//xLyi00TovohJvzcYP+1nj9fCwyL0LlICr8qJ+NDf7QGB0e6BrBDWMXUtZmPaIWiMhJATJLI9WbuchoMXEiQBee+E5xulwSdPxj5CE4MXijUpyUjxMk+q85VeGHpST/QlCJ1GkmbS9Bzoh8WnfxMOHC7KD1eCVH0sYtX0XL/vn2ij/mKimrAUnCv88t7Wsy9aib/qIxPu8= 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: 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 check if the page is accessed since the last check. Note that this commit is only defining the type. Implementation of it should be made on DAMON operations sets. A couple of commits for the implementation on 'paddr' DAMON operations set will follow. Signed-off-by: SeongJae Park --- 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 886d07294f4e..f7da65e1ac04 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 53a90ac678fb..bea5bc52846a 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_scheme_filter_alloc(void) static const char * const damon_sysfs_scheme_filter_type_strs[] = { "anon", "memcg", + "young", "addr", "target", }; From patchwork Mon Mar 11 20:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13589316 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 8A02BC54E58 for ; Mon, 11 Mar 2024 20:46:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BD046B0125; Mon, 11 Mar 2024 16:46:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 269606B0126; Mon, 11 Mar 2024 16:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10DF36B0127; Mon, 11 Mar 2024 16:46:06 -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 F19586B0125 for ; Mon, 11 Mar 2024 16:46:05 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B717580590 for ; Mon, 11 Mar 2024 20:46:05 +0000 (UTC) X-FDA: 81885940290.07.4372FA2 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf30.hostedemail.com (Postfix) with ESMTP id 7A76F80022 for ; Mon, 11 Mar 2024 20:46:03 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eLvgqV3r; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710189964; 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=PVxYXcPwHuDlvucLJAUIYq1iY2f3LRUkqxwYC+Y1obA=; b=revXKFBpofHSSwDEySb7TCKMJ2/rD9Zs0W7nAjsoOwaMUEE5VTCcY/GR/x5rZ5Dtezw2TW IFlwCV3j6rfjqM8fSaZrkjViZIqHG8VP1sssyzxVLPs404T1gT5D36cTbfrdrppS2qvpQ9 CFRwA+YUFTDVflgx9bCzACY3l51CA1k= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eLvgqV3r; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710189964; a=rsa-sha256; cv=none; b=Lv2Cqq3nLI4/VvPPD0na9GfO1AiXH+bXraYr2cBBt8h11wb/IHmHZoReIWhutbN09HwduC mM4bYLNTIRqNxc8FRUHPtWVu+CSvl1QE/5nr8+c0ibw4nVkj40uW1DTCnQTn2vMv8yhOdq VfSL0MYKRMeXxggX0fvrDpz0KSgAHEQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 715BACE1294; Mon, 11 Mar 2024 20:46:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99101C43394; Mon, 11 Mar 2024 20:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710189960; bh=fHultMqP8gCokferFy6tApU0Sk9aroAt2aHpbSo1nsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eLvgqV3r4YMJlZJBEZKjbrWC6om6P7NHp4+td02wctGQ4N3G4z7GE9qAALIugj8Iy zWuhVw5VPeN5BFBkHQEw2DqnN9PJ8PzP12e7TgKpaglJp5zBNDZGXDv0WhHOd6AiRG /tdhcB0X496jLKbXT1XXDe73H+lrmBfWEKaG3wQHATYab+otN2mFbzqlxdkLmPpyYe PDN2igIJSFeMWgbraZ1APtggzK2pUeRE4QCsdt2fkTarI6TL0DSCzH7KXThT1wdML0 33+Xqm19q6A4lZlgFZz3iU0cMUq8GpK9WvSuWLa3H2gk9OADSIsLpAPWfvMuTED53D lfVd5ZjQ1OwWg== From: SeongJae Park To: Cc: honggyu.kim@sk.com, hyeongtak.ji@sk.com, kernel_team@skhynix.com, SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 4/4] mm/damon/paddr: support DAMOS filter type YOUNG Date: Mon, 11 Mar 2024 13:45:45 -0700 Message-Id: <20240311204545.47097-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311204545.47097-1-sj@kernel.org> References: <20240311204545.47097-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7A76F80022 X-Rspam-User: X-Stat-Signature: 9t6c73afmjkgrd4bgohw3ogw3695armt X-Rspamd-Server: rspam01 X-HE-Tag: 1710189963-465467 X-HE-Meta: U2FsdGVkX1+D0axC+UuYq0au0IQQt4kI0ubjdA+Hywi3nqR5XuLCfPOrEMM4mHlEmjMrzsfW5DFvZlXlCIGWmYNly2XP3K4X5C5O/S37O3c9ynt3IgJkiBRndvuIwOk7OnVwozoL77QoY2ZWQ7udSliKyhFfn6439wzdkvGJPFs3yHkfO0YfEYIcD5FgkzmER4E/nzft17dlj1RbtgmN3OhlVbuRCl/ExlZgiYQqSUyJIfJSZTr3fFt0kqQGNVA+neuv7TZ45cXxiNWI3XfbcuhRmS9bWpRQ52z/o+JJs6oGlFWNBlPPydZtAtlzgv6F+pYxqZzAmZLka7kWCA8znJ9Uf6FfrSrup6JG4wsZAsFJBLq3y8atY5aAuIuhbJ30AFNISMXhPlv3KXIIuk/C10INnLEEKi2dyGO3Gux9GSNbJ2Zopq+2BO9NKxxJGB1VgK0YQ8V+6Ou9ryUyoB6shQmpIaDqW0VAQYj17C/nHo2J4HekHswOTE0w4fKze/hxSsE+zx4zZIAD0Sli7mr50f5FLKc+2FUZx1TVjN6YFQsSURhbHqZM9hbMBMdOeTz1IOJJj7B4gXglwxZJPXX3Qu+P+4qA0lSxhyxfw6nhLjcwNKjswWXb9hbUAEfRcY9QAb/6qJHOBzauHc5C6VXH/o8zmTsuTO8f6YD5X3208TS92iPnitf4w7fC2XbbzZL3yC0G5iLTnyt7UNxlSMfdjqjkrNQtC/ClNVIrva7Grbt2UqqZ+pxNKQEMM71teerJ/5VgNal8V9Fw1NWJwV8eN1ecTQOIZXcyJIcW4kZhA3WSO0uDnrMQcUXt4dJj+rhyZhgXtlJ97MpR4sbQDaYzcc0yUvSpyHtFExtTCgBtdH3BermBNZLpq/p7XrCT6pcUjjRlI84t6A/f+bG+zD9eQzerjdTXU74KTcPafnpx7wZEOqTiBT3ZHLRl3QvCdQoPiHbkS2M3sZbFE2mDIeT D6lKCCvK sk7I4xxW0nmtKrQrbHqmrJaXsAdVxz4pDUIXlRLZjc/JGeZmYb8TN5KnbqcgrnK20vI+0hjNQcpnINWMLcZsTgkcfg61vG25SWMJ+vGWTAwx9toien6F6k7d0mWGz1ONaOEf+1IIIz/jFkwODHJIua2T7C6PzpHVUqueyNezq3/U+lt+jciCBoRPacddq8suXnMbGZJl2Iit9eay0gshzyxxWtmu2bYcsEfRj6iImD/gy4JM= 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: DAMOS filter of type YOUNG is defined, but not yet implemented by any DAMON operations set. Add the implementation to the DAMON operations set for the physical address space, paddr. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 310b803c6277..5685ba485097 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 = filter->memcg_id == mem_cgroup_id(memcg); rcu_read_unlock(); break; + case DAMOS_FILTER_TYPE_YOUNG: + matched = damon_folio_young(folio); + if (matched) + damon_folio_mkold(folio); + break; default: break; }