Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp668346lql; Mon, 11 Mar 2024 13:46:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYQxLbLCCmOmjiD0tmfqlYgUY6V8KK6Wtg8Zwf9LRo1pLD7h7cVF4oOZkJzG958xfSNO4rLr4kmo2G11K86nc1pwTzB07bgmeqI1kamw== X-Google-Smtp-Source: AGHT+IHV+jga2w+lLtwQiTMd1zev5jFbgpWXZ5yUfLnmn5LgD7xHjIbuhYTzhvl0rDVGsT2EoJcR X-Received: by 2002:a17:902:7403:b0:1d9:7095:7e3c with SMTP id g3-20020a170902740300b001d970957e3cmr6932398pll.57.1710189972373; Mon, 11 Mar 2024 13:46:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710189972; cv=pass; d=google.com; s=arc-20160816; b=sHVFe5b8ECtYb0xnlJVIv7Ehz2HGNS/HuBDRwzhvd/HEG1aIjzcZJn5ceEBgX21wHJ ujtl+ci859kkdZKJrTAoIGMOCzHvCfxG9U1TNkGzRJ5pGU/nk0vubEuC4tHuRQtazDsy jTjzowGSuUGmINTmXRkY/Q55YfSBSF8WCl51/uOrWkikMIA/NLRlNt28By9Pv/bOjRVj eDdECTkCaO1AZraRP0I7Up1+y93dsqw6RKei3mMStXIjFUe9mePcJcXlTxAPXcfdeVnH q8DGZRNj6sew7moYMaF9ii3mFWok4TC7cYkJNY+q5VzmL7NMbq0/z4q0FfBwYIwin4Qg MeUg== 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:dkim-signature; bh=zsIMqcXcJhWYwGsWoJ7Jty+YO7EmPMuaCF/Fyz2ErpY=; fh=E/hPYPMZffwpMkqvbMzuoLlOj7U1fatLsderTFwZRHw=; b=epsH85qsqVX9B4sQaum0okSZdTdQj7Xqlqo4rK4wcZtNNljHmKJKs2nr/NfoDV2XRm jELFoNzRHE87Cq0WKBfvfoz5d/ZsEiZE0JNiNrsOun/+qD6N/vgUirsSWRZPegXiT5II +mQfW8uB1E6eMtI+MnAUvGLPE84kyoG5puY4qN0/bSXh4Ern06YPzfhQQxKrp4x4dTAz hP0zmz7UhgJ/riyWt5W+5Uea6Env428l6eH+Zjolcil+Oq5o5vzw1iIIyxDQL1tqzr/O mwdUiFL6mNUkCECMRenWA0dpq9MLMqeGghpEdjriF/MZnK2ay7hYLK2ZdXtC+HBPE6kF kAGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=td2zp50G; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99531-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99531-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h9-20020a170902680900b001da1b31fc38si5434026plk.497.2024.03.11.13.46.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 13:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99531-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=td2zp50G; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99531-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99531-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D61EA281AAC for ; Mon, 11 Mar 2024 20:46:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A6A356B67; Mon, 11 Mar 2024 20:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="td2zp50G" 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 61ECD433CC; Mon, 11 Mar 2024 20:45:58 +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=1710189958; cv=none; b=SNJw6Hl3vCxLgp1oM/stjZklXquZ6vItYe9OiZrZzMCQY+xFPw0mANKY+MMjzgHFWGVr7d+UDpKjVEO8OhN/cfKclYTI4acdsTPdRSIXf1jUe7pdPcM96N0kKroZV2SVYPdjqJytGUTsoiMjqxbIpRHWkyWMvzP+xOp/KJuPQnw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710189958; c=relaxed/simple; bh=UuuVmb738blr2pB61tpIDxHO3PUHT5WkafuK2N/sEFA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jVm69r6t1oLUIxWY5R5QidempGGFznBEwo06/T43lNvrkxpY1ATS7UeGOumMKlyPmMEVLlWyr11/65zTGnAmuJm7iQLjxUzEpYFdOw+0ex1F6XUp0o4gN+zjFYAzDj4xaW59v1a41UVXnzKYphPKY7LcsDzJ1CMDFhhGmj54gQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=td2zp50G; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.39.2