Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp668379lql; Mon, 11 Mar 2024 13:46:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4qiL2IQgisrlFstidR/uvTfJIwvK4OKcZrmBgiAmyJW1vnN+BBqYcPn3BGacJTu8MYQtsyq6rT/z2ht7evRVxy4axE1O+k+OtEY+3Ug== X-Google-Smtp-Source: AGHT+IGPidLy174+RkvQV3Ieqso9knQWbZ1tV4pk9ReYqtLlfWa2zhDJ4uMv2M73iSG+2UxSUOTk X-Received: by 2002:a17:906:af1a:b0:a45:a731:d021 with SMTP id lx26-20020a170906af1a00b00a45a731d021mr4114960ejb.33.1710189979355; Mon, 11 Mar 2024 13:46:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710189979; cv=pass; d=google.com; s=arc-20160816; b=UoF4yAUlKR332wemKhyNUvw5E+Z0ITGIBimF0hhLgY5PcY/OOpJtC8jUaZQM6YCPIc fD5gg/4QWY4dLd4UE3ixyL35mgOkEZHvoLOj6iOOsE3zmgpTqAAll0QHczcjlV0+ijLj AilveKhzihLu+2TOdtcgzNX90dKlgyzR+zAi2G0+kWzHfyrQG+OBI2Y6NsGG2ZVuTSOJ 8gVOzapDuETxdeaRhpVf/de9MXHtUU/e0YX90fMKvyVpnY5WY+OpxbbG1QszWFCkFy6E nntwsoPNzHqCNd3jiScqOm9fYlqjwVl4R6/JrNnSGgQLJGRSuPB3xxLOGrxQsZbvomoh 3yGA== 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=J9pPeQJREYFyqXk82X+P+nuC2kp1HSgA9o6yP/N1kFw=; fh=E/hPYPMZffwpMkqvbMzuoLlOj7U1fatLsderTFwZRHw=; b=xRS/2eMXUKx0B+CPz2jxH8LJwGrWMqQ4TP94G/ajBCaBwXhJTrlhMXlDAqgUwzWKzO rJkE5KxnbECpsTbvyBsepfViy3vjryWRRT0zTr0+596iJPRhvQicSQHsMbNnus4DYzNp e4Zwn8fdTMboCZKIsxa+m60Zs7bRCwROZX8NnLcrzCGx6CFLrJaXCD946FyHYu186/ub k8NPrMtBNtp2PMjj8GgkAmFqJA2mfHvvvW2pJY+F7NSTT58l6zwr5R0ilmfrFLpvWXNT LVsYLiGt7GGgY84TZ0cJkbCd80B0yPyXKkOS0Q4tat0S6vLdEhh6zoc4UBNSX21EfH2s IwMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GLGmSRcn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99532-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99532-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ak6-20020a170906888600b00a461992165esi1870443ejc.264.2024.03.11.13.46.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 13:46:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99532-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GLGmSRcn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99532-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99532-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 197C61F21F9C for ; Mon, 11 Mar 2024 20:46:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD6E756B78; 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="GLGmSRcn" 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 D3B6B53807; 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=DbQa1MZuvl4u3/94MAK/sBwk7WuZsdNdL7ojC1ORcap4b1J6CvcogpdaAPwCV4MvqJLiCQ6gwZ96ZX/icv/Y9+hxthWKqmQiOZwz9uVKTlyMQwVGdcRNSOvpoMZqwunAx+MCcNjttkkNv7qYN00ow3B+SJXDrWGO4xh9XvRnC1k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710189958; c=relaxed/simple; bh=hs6WHjvRmbJudqL2dyXIyQo9wvOsoRsFOzjiQ+KCyr0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OrZwtGBbdqpFkWm0+j8/JRHSWOjbgSSZUYgC2e9wbx/vhUQwKDdyjHtotWrTVukG5XjCIFFnrxR1gmshJPcaW0Hav/fh4Mx8P+ArxOvz6xKvVgPeAGGN7YZA13X56cmBWD8PfL2tIfRRurVIGTR5RQSADxSTbINwpHx0ah5gB/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GLGmSRcn; arc=none smtp.client-ip=10.30.226.201 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> 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_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); } -- 2.39.2