From patchwork Mon Apr 29 22:44:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13647842 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 82137C19F4F for ; Mon, 29 Apr 2024 22:45:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 072D06B0093; Mon, 29 Apr 2024 18:45:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F1AC06B0098; Mon, 29 Apr 2024 18:45:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0E496B0095; Mon, 29 Apr 2024 18:45:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9DE1B6B0093 for ; Mon, 29 Apr 2024 18:45:01 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 14D90802C5 for ; Mon, 29 Apr 2024 22:45:01 +0000 (UTC) X-FDA: 82064051202.03.46D3B99 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 65F9240012 for ; Mon, 29 Apr 2024 22:44:59 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ny6osMgl; spf=pass (imf12.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=1714430699; 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=x/0502E9DYmuYINbipbxBREBkS8UlJDMhTMpwHVSq4A=; b=p27OevGdZaUqGiJttzS+KGfOtveJgb4QFjh5D3Vjvno1BIvnpZjsLPlpPfXi58ifZSiPuV AfBWOysk1flJ70eaBPzjkN09WZIrofoLSXTWsAAi7xgT0MdRRindv+QTop/r7GGeWjvc7v yxknauEOZA2Nev+ZHc9m6Xq4oC1SsSI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714430699; a=rsa-sha256; cv=none; b=Y7sq7jrOcW1e45+k2dBX8VuIUrejUqzsJGZpdn7G31TmBUnkJsjRYBVXi7O+7OJIPfHMF1 iDoWnw3e4GLnAKJDSIyGWDCiizUQzAU0zF2w9P4gwilqSmFDEOuThuviYSgOy+E8IThLhQ Wq+MCIgNBQ1je3Ws+xs5cKmnoWgrr6Q= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ny6osMgl; spf=pass (imf12.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6291861143; Mon, 29 Apr 2024 22:44:58 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 5g598fff573rsoeneqayi91wttr8nkrt X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 65F9240012 X-HE-Tag: 1714430699-480922 X-HE-Meta: U2FsdGVkX1/CW5YkOpvNaSoqXBx00HJ5Y1PFrKmc3tFqgKkYMaEl3WOqLcjcO+mNEExP3vtHlFxARk0pFrlDaip/DhxHt6FTvYOyyYJ2kjf6x/ASqrPtsG+AeitJFrpNyMIzSSUJggAMQtV/kPObbo5gzNU3uyX9wV+eFfdxdQY5GdLncOo1/R0kDb6cC1Q3Pq2Ft29HoRwsTTwkrkx9jycZjKgpt+lQVPnFdKJpBK2fPIpdBtx3lEI9mvqOXNbyis+p6AQQGzvuhCobeeRBAbKqEvO7ySjfSBFBwsrxMIsRhCR5x4whPc/NybjIlQ2ZIz/FyqsONbVqXKYBMdZqv2o0PAyIm3Bj9HW4Z8hay8NSrfDRHv7rIFENBLapg25csmCeneakVlZFOwKyF0ivqQw5UMGqXoA5WFS1CUpnao8lklst4e3gHvYbhlmWnQLd9+qnD3lt9mdTrY3k7+coj5+/yHBzLEZ2jrbkr273R419tOqQN9BeK+UKp8h1/ggxDQN1Nrl4mV8Uam/RZEpH3Y89EO+cjnsi39gc9I5J1FAFzKBJk41MIsZyusvqbVSZzETEPzzf0Hl7hbNY9yvIOjVUUiGFLfG3ggbnpK+VBmW71UzwkCwpXq+T7JGFWpniTAWPcbu/ied0heMuuRsdQQvqwPQXx6ejZ289gijeTyxzOY4XVIGfUJlnHvK2eqnQcq5qxrXCrD7RydJU8/Mf5FPca0cP9N8vlRODKzhaRdcuSBcXAC97hD5wCcfAfTt7RLj6S81Ed0TxyYy6QEEFdyxvqy/IyxEfdx7+yPaOCGYm86ZxOunJKZOKbMfB57dSdQ7opkKzEYBRNBhHPRp/1qOGkKgDrSfyYTh+mAIHYFRV2Gjj0NwRRZ3SzsEnTxFQ723SvCiAaKM9jT/5wFqm0aTWIbzElCqXOTMLBiQPAFhJauct7PEj6viUZw7c7Y5i4SEdzw4PCkGl4xeWg8I r9E1m9dL 2iHJ4tILpIM0jFjpSR3k+kJkJYPa+f0TR7ms80dTR8RUlqe4nOXnDGAaN7EWr4eW1G4k2Z0hwSb6Nx8ALTdSlhYBymXd5DVjLE/f7f5aX4jUlsDaPR0KrO0hpKvae6KKjPLwEmbpy2gRzMdUHrVtDodZajpNht1D2wnQzftb2pMjBRrbt3CYNi6zctQ3LzeSPqFBBm+7+iRl3BROC95JKhL2+E6buNRWzlRd5qnXbj1OdJ0KsRhPxYDET+KxP23hacNxQSo5R3Umjpxs= 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: '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; }