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); }