From patchwork Fri Apr 26 19:52:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13645325 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 49065C04FFE for ; Fri, 26 Apr 2024 19:53:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C81DB6B0092; Fri, 26 Apr 2024 15:53:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BECEA6B0093; Fri, 26 Apr 2024 15:53:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5D536B0095; Fri, 26 Apr 2024 15:53:04 -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 769596B0093 for ; Fri, 26 Apr 2024 15:53:04 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 385DCA08C8 for ; Fri, 26 Apr 2024 19:53:04 +0000 (UTC) X-FDA: 82052731488.24.0425BCB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id 93DF5C001D for ; Fri, 26 Apr 2024 19:53:02 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q2nYt7mW; spf=pass (imf28.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=1714161182; 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=bmBGpD4FzLpxb6o4z/r1N7rmnUy5h4Pe+Fu+Xju4DGc=; b=F4I0fVSX36/P+ij4D0OXwyifm8XgtzCAx9bXX1s3DCl1XuIjPXvcNAv4sgV54IVruvn5ZI Dvite59G6KxEiwohgCr7JzVN1CHrxPGB6eC5MOPHd7HqmVK+FYduKYU4ukCgUiL/pg66zc KGM0r8Mz4Z3a0PDp3awPpArSSD9oVis= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q2nYt7mW; spf=pass (imf28.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=1714161182; a=rsa-sha256; cv=none; b=5MWla1nWJm/aqBQ/QLT/sl3zLrV0jhYHzMONoRNvTxOahFpdKRobDckHW8GF9Oaz5Ct+Qy O59wnGhY22ao4L2OoVGJQs+DclWpbWsh4qyF1ZtlGiIu3eYhPElVzl8NExd2u4dNUF9bhZ yF/h7geukTpmLgZ7u98FAcLn6kobbZo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B62CF62134; Fri, 26 Apr 2024 19:53:01 +0000 (UTC) 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> MIME-Version: 1.0 X-Stat-Signature: qn7f69bom54pd551rzody98ixfbstri4 X-Rspam-User: X-Rspamd-Queue-Id: 93DF5C001D X-Rspamd-Server: rspam05 X-HE-Tag: 1714161182-930004 X-HE-Meta: U2FsdGVkX19BkMXrpmklYBMo526J0RjkaGHhtuG8dMTAdQGRYGQaER2Wn336Bky/CRH8gQQZ14x3d/zldisYM6mnFppckyXNqJ3TsXa4vSIa5sRuis8COQ2YEqess8Xi4HFEsg8W7f4gxVrzFZb89CVNDVP2DMT85Yu715XHFRbezfaqpBY2x23xXZBky34tIxTdlRQE6M10GsILRfIAYIpuHvf9hagtZnWHDdHRlESwu6HA3C5/woJhG/Dzd/l1U/SFTSFCQ2Anqd1hT1RepVeZFm4LVZWBHT393o/qcbOcOhyjeRqYV8A+6QRDmeB1WeS6jUQ4mjU5zd+wHQKq6GNbKcl9yC814/Wtd7C1uxAuTvYTHt2CBhjF6J0Z5sWRR0o2AtZJv7YKURoc6YyEtANP1ZbYy0H68q5sFeKRA1RBhcXE43BXrYbo1wGjEFmK3qGokcyG4+QNzJSUe2kdg7C67u8OK2wIc4P9tF7sCMpZO1VCIoLy+i2IlTbvi7EuzmZyZJYDWFRxskyUhLPPr2xt6NqQyBCw0jdGfUCwkQsHd17xaUwY178XtfcF0R4+/IAWjb3nQXqzI3zJ7n+/iDzky2/qfkANAd5ZmkYru1ZDRKgXAncm+34SrmFF4P3QFIxONMNQ9RCFoGSFycXyW4RtjpNEdW/qKbFAYKZYbRn/D3G6Q+0WWk4QjWT5yueX1uqdbbCGPt3tmE+WXgeLHX9RUR/nRj3ugVBss8cS+6jp7P0YR79FfBXFeqBkxKFGbfwyojcIinAu4B4h8ovnH6UuIAnwpUNtIZAWWboUgPDYRBZ1OfhJVOqN3eM2W7dMw4lWqKKUv4bzYDk6NZkK6g7E4TVrk5WnrNjUjicNpnWuEX1LlT/eLxhdXjobjIab0lS5ZKSXQJKdeSGtqZaCg8Oq7ttsZilHahs7IGtH+mZzOb/tP9BTwm3VFmqWISKq2p/1pq6GhLdw2KwXTES ARxfg99q zGPnYV/iVlaxCW6TZaqRR74grgOFA3e/cb275SW1gPMoSFF650H9w6dP20j3kiatv4utzY8mSVJCUhNkse9l1AtuCLxaP/EjRPfqiSyXyaF4JsZ0KsKI+2LHqCt5zdZ0e98B130cfbk5VZiT8PvUCcr8Q/qNNfuckN/Vu/ya/Q3wxzBR9Mn1TZfLgWivUfM149RPM+WP9WpdSBkLy0/5OoDi3bvnmRmQGDjW4ZXL1nMsE/dcV/We3TvhLQ//YpJMOvyK39Rl7hkFl+72VX72x9tKA/IwNrnY7o9eUaQg2IrXnHonh7P65yE8NkWecy6pUxLP4p65D2LixYBvOcNrS5TcZeQ== 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 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" -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); }