Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1665458lqa; Mon, 29 Apr 2024 15:45:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOPr5pPpQ1yWI4kACYM81DgXoH8c/iLksx5iUK33gqDZrnqAgaxE9g6KQIkfFm8hYUaZ7DUWB+LfwLbZNlbAT4fOrPeo/+muQyC44X/Q== X-Google-Smtp-Source: AGHT+IE0MrXe2U2T5oLZesddEl7vvmNeO66XzG8KHa5dJgX+FSezWkYn2uQaIvtwKC2J7tEulwUZ X-Received: by 2002:a17:903:2c6:b0:1ec:304e:90c4 with SMTP id s6-20020a17090302c600b001ec304e90c4mr635205plk.17.1714430723695; Mon, 29 Apr 2024 15:45:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714430723; cv=pass; d=google.com; s=arc-20160816; b=NWcoPChAKpFKzCYhRYpvv+93gz8Tbr8Iu4TSB0nRfJbSdgRmfdSnxNkX1c0ArpjsTn 5q18pBV+I9arF0URi+R9TWtQ9ki2pZHR6dGg6O8iKTB5sRqu+m9bBdKf5eVm2VcQNNk3 ktNv7cWVPrH35XwNooLkEMSG6TB4t1ACG5PLrL6poqX4VoR5pctYjhrXP5uTgERS27MU eSODJQX7o6PEeqzWc9TOBz6JOeXI7DTn15WcoG68936H6QLFPvnKd4SM034xmXLITA+/ k+cDcjrtkTMYDmDbkYUJawzYlDrW/ZsjPbGXklFi08jr8rQQYVk97eZ53gIGiMAhIhh+ NFyQ== 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=x/0502E9DYmuYINbipbxBREBkS8UlJDMhTMpwHVSq4A=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=zoyxXsnDBQsxnFpDwYM2iKoleHzQXqU3mz1tgvM69KAQ/CioK80J2ATwOQb7wOAARK HC6xP0ZN0lHkOOkRHIiHlnnSSvkFcbRuowRtMkuNWb18TOQ3RcOY9/dgnQkU0N6Ehxlo 9ZNF4YN05svfkgjMULVEdC2OQbTHYgbTlTWRXWFYq9V2f/f3J71thTOjIlGHWi/h3Q3K mrwrwyWfFK6v0LP5t2gHK6GUf1WWtfXBl+d6xdjtRaF7h3UE6nDiQg+JgfVO2JrPjkVP /SMAgC6rDAch3WeWPf7HBmqXsyJ5hn0g6KUESmmYXScGL9mBenmHZN4r3qxEBZNuKdZj cZbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ny6osMgl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e9-20020a17090301c900b001eab1e95c01si9027142plh.500.2024.04.29.15.45.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 15:45:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ny6osMgl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163111-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id CD51CB214C6 for ; Mon, 29 Apr 2024 22:45:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EABD13AD18; Mon, 29 Apr 2024 22:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ny6osMgl" 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 311B92E3E8; Mon, 29 Apr 2024 22:44: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=1714430698; cv=none; b=F5Irr09iDScoNZnFRsd8Vwo9l8W+8sNMAY9S+I1gOF97++YTdR7M/kLebIDwwph8YalL50TZqVtwuvdTnCNzL0mk35DjcJBYxXhVXvBxmBqTF98jIT0g/hSs0fDdPGG9zdD/yQXqn3BkGGHXtbScUMFjD/hDpgigE3PKSFu56mI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714430698; c=relaxed/simple; bh=AH03oSjW6IlmpdP3TkCfshDEgNgfP3nlydglW7MDGsQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FEFrpd2/C0+nlY6onlGXS8jFjPT1Gkkr++lgsCMU0+RKFkPmpUz1MG4ykhaEalPKV5RitOyIOfrp/NXSvU9W5ILGJCITs1HufWfEkn1MAZY+rbfZdtNPUx7CKzb7uSUJg7SMMVwRVVmnEpO2pBgq70IDw/xbX9i9Q1d/DmYcKCE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ny6osMgl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC6FFC4AF1B; Mon, 29 Apr 2024 22:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714430698; bh=AH03oSjW6IlmpdP3TkCfshDEgNgfP3nlydglW7MDGsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ny6osMgl45sRK1kTdOdB6auEHpoy9gyum6G8OViYWxx5YHF2tI09BaNYiUiQcM1XE CwsnkaXlQWiDC4fyWrn1I+XwFkdEwvX5dKhuKg/nm+9bdGn0y7PKJAyKCFUuyklO9D dvDeBNzrSWTFQOx08wMh6KdfBsiQbT+oMRUzz0/87a37KlHyp2AjnGZqCxPAsg0LSU NF6ze2KTg100UJ2SoPwg/gpn6iM4fjetutiBmcJ6PYtj9f3UKD3nPGU5Q9DHSrgW74 rFUA74TFGHpHWd8ilXj58w3CIyNERfRMxsz02cOVqB4FhMBaBy9mceOVkTlgZpeCax FjpYOOiaKPSjQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] mm/damon/paddr: do page level access check for pageout DAMOS action on its own Date: Mon, 29 Apr 2024 15:44:49 -0700 Message-Id: <20240429224451.67081-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429224451.67081-1-sj@kernel.org> References: <20240429224451.67081-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 'pageout' DAMOS action implementation of 'paddr' DAMON operations set asks reclaim_pages() to do page level access check if the user is not asking DAMOS to do that on its own. Simplify the logic by making the check always be done by 'paddr'. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index d5f2f7ddf863..974edef1740d 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -244,16 +244,22 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) { unsigned long addr, applied; LIST_HEAD(folio_list); - bool ignore_references = false; + bool install_young_filter = true; struct damos_filter *filter; - /* respect user's page level reference check handling request */ + /* check access in page level again by default */ damos_for_each_filter(filter, s) { if (filter->type == DAMOS_FILTER_TYPE_YOUNG) { - ignore_references = true; + install_young_filter = false; break; } } + if (install_young_filter) { + filter = damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, true); + if (!filter) + return 0; + damos_add_filter(s, filter); + } for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { struct folio *folio = damon_get_folio(PHYS_PFN(addr)); @@ -275,7 +281,9 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) put_folio: folio_put(folio); } - applied = reclaim_pages(&folio_list, ignore_references); + if (install_young_filter) + damos_destroy_filter(filter); + applied = reclaim_pages(&folio_list, true); cond_resched(); return applied * PAGE_SIZE; } -- 2.39.2