From patchwork Wed Nov 27 20:56:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13887372 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 07311D6D23B for ; Wed, 27 Nov 2024 20:56:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6249B6B0082; Wed, 27 Nov 2024 15:56:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AD0C6B0083; Wed, 27 Nov 2024 15:56:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44E746B0085; Wed, 27 Nov 2024 15:56:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 231EC6B0082 for ; Wed, 27 Nov 2024 15:56:32 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D28DEC12DB for ; Wed, 27 Nov 2024 20:56:31 +0000 (UTC) X-FDA: 82833083340.02.2C33154 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf28.hostedemail.com (Postfix) with ESMTP id 27000C000F for ; Wed, 27 Nov 2024 20:56:21 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Arx1PFHc; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732740984; 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:references:dkim-signature; bh=3dAjS7Thmtea+UBw8SXySGLrxLeLz5w2rQlIMmTNJwg=; b=h6aeoxCpU2LvG6Xr1T/aWTtqFVU1Kt0V69b0ghU1nibxQekdqHZCP8LKJcQbCDvbUlSEVW R9tCqRUlIKFINnhG+C/FU2RZKpH1DtnxYr7PcME0DCQ0lDMuxrtrWTDANrylN4VIHrIJnq gxkLJdrWrzbNaQlDOHDDPL/Ul/0O5a8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732740984; a=rsa-sha256; cv=none; b=Kjed18zIHAlC+L6T4ai9Hgo1w9sT/SEcvXTdIiwctdoMgos6HfIEqPzAjYLo4ZrkSPsa+x 0mEleXg+yGKHCHRZ6hzjhxGFVNFFO7sInWbJiMoIPA5+0qvrE+yTupHiny4/Gw6T7jGq0N 4wJDVOjDa4X8NbsSbTykZNS6cUyMJC4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Arx1PFHc; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 99EF3A439FD; Wed, 27 Nov 2024 20:54:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2C93C4CECC; Wed, 27 Nov 2024 20:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732740989; bh=IsY1p9peZtsuSZmN1lXqkSi2g3xTHsQCxshSsJgZG1w=; h=From:To:Cc:Subject:Date:From; b=Arx1PFHcSj+PqFbPWIkBHIkiHMkmNsiA+gH8W9NoTAtXL+V6o6tCrs43pca8YTKVc +66/1vUHZ1Dbvgj0UI+AhKnRrIWAtIse6PFMPQP1aDl9YMzgaTz2XKfkg+164BzAni 1v+nnYBIWCMmVETcLBfMGUMYrwW0kr4MmUelngWRtWGthYwSpIBBMwpcmsp0fcDxUF nMbEIav25ZUiVxMoZXL3lzwJbzMLPKkC5AsynbEyQmcggMs5z8t/EveVV7IeKhEYb1 yfh5RDiRXz8XszRjbf46JcNSA9QsCJFG1nOdNIQbZzzwUbr00MZM5skJvSJ5BEsGM0 KYlB5qrlsma6A== From: SeongJae Park To: Cc: SeongJae Park , Gregory Price , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] mm/damon: introduce DAMOS filter type UNMAPPED Date: Wed, 27 Nov 2024 12:56:24 -0800 Message-Id: <20241127205624.86986-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: 27000C000F X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: n8snga1oaxwg4p3rho8gb1wg7xtub9hm X-HE-Tag: 1732740981-963233 X-HE-Meta: U2FsdGVkX1+0erijriWSF4UMKlXroGeF6Hkg9xe5Teuk53CUxmi0rZ2Lo2lG8TrlDU9YsoG7n+fjROXRqSrB386Mo9h+0LXY6dLQBOVlfb2aJ87QTi0PQ3MK0lw9ukEHBnfroGHJr/kN/QosPbRHW4Nu9JHIiczqjkHRZcJYVHfU/JlzLCn+qy1ep4BwREUrTxqZQXWKM6TvfZEH0aTy85yMBu27ETllkl2irSI5zNbUAI66c0gGKs65oysOX04GCZ8yx1njULCMJ425QGULD/qCpYL0XoIZGYtpkevCEzI15A/CA2X/ieWM82cWsmQyN7MYfPYs/G155Ze1dods6HXpOplKXzJhWK8yHE7X2BxlupILjOS9wqJtoHxCWc9qmey/qKjuI755+5Nj2vuLHxU4KTSFBD8Cq2ilZGMV8RQeAonFn+FbezlGokUBMEhCcs9cGiiNCuuyTceOX3ww5GmmMk3oF9huMoE8bR8pdevasruOXgQdvObriTK3m9CBhE5tMf36XNn7IB0yxlXFclnyu0Sk2bQyMsLwRQ+VuIZuNflidbX0LQiTQB/bBfkvoClBSgwr7Xg+22qnrBKZiIoICl28BCcMb90ETytOtMjhBhJkdQDAs18WUPbErK3Bn7E6HU9VvcHNpHEfJgXuIZfSTrya0R336XTDy4yNv7ArTiJU/ja381eQLtMrGdwj+2HRv9k8P+PyWcVdUcxG9LUH5WtfQYteAi8/b42bNnGM8r3KPxbyopZZ88rCqkDiClKUG4QYxtadCtQfMQMF4TvZMVfekicr77p9rgPLKOUgw4M7LnWTIruxcD4RlDg84JwOdMHjomEAmcKNn5Z4jFv38gwhw40LjhdaQnhSYQnrAlcW40VIN/8agMCb48vE7RkGbqbfBgZZIagbspz2QojHLol5yyIYEr+F3sHQAwCaE/OeE4JnRe4GYyYt6kWjCMU8ChKJhwUS3Aer8rs 5dF5rgvA 5pL7nYAw+UhrvrhanZtvM7SSx9drL9me28QrS8JfAenP1z6hyNRo4CBExIgvrZoO7uFhgjIh+IE2XnUOLRTLIZVktHpztRFT9YZvA3KZ9bS/mvlbXhAiqT+1vxoztVVrAnyS5No3+X37JGVlc7PJr0fQCMHEXRwMMJVDoZnrXNckhNxx+jqFfvLrCcsrKkPSE7c60nzzpG80IxvC9R5jZ/tLzt2G+2HYTK97OeXnYzsQ06gw= 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: Some DAMOS actions may better to be applied to only mapped, or unmapped pages. For example, users might want to use NUMA hint fault based CXL-memory promotion for mapped pages, and DAMOS-based promotion for unmapped pages. For another example, users might want to proactively reclaim only unmapped page cache, since some people do mmap() for only performance-important files, to reduce read()/write() system call overheads. To support such use cases, introduce a new DAMOS filter type for unmapped pages. Signed-off-by: SeongJae Park --- It is unclear if the example usages are realistic, and how much benefit this idea will provide for the example usages. This is for showing only more specific shape of the idea, and hence RFC. No test other than build on my machine has run. include/linux/damon.h | 2 ++ mm/damon/paddr.c | 3 +++ mm/damon/sysfs-schemes.c | 1 + 3 files changed, 6 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 9d8bb6116df4..10fc6df52111 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -315,6 +315,7 @@ struct damos_stat { * @DAMOS_FILTER_TYPE_ANON: Anonymous pages. * @DAMOS_FILTER_TYPE_MEMCG: Specific memcg's pages. * @DAMOS_FILTER_TYPE_YOUNG: Recently accessed pages. + * @DAMOS_FILTER_TYPE_UNMAPPED: Unmapped pages. * @DAMOS_FILTER_TYPE_ADDR: Address range. * @DAMOS_FILTER_TYPE_TARGET: Data Access Monitoring target. * @NR_DAMOS_FILTER_TYPES: Number of filter types. @@ -334,6 +335,7 @@ enum damos_filter_type { DAMOS_FILTER_TYPE_ANON, DAMOS_FILTER_TYPE_MEMCG, DAMOS_FILTER_TYPE_YOUNG, + DAMOS_FILTER_TYPE_UNMAPPED, DAMOS_FILTER_TYPE_ADDR, DAMOS_FILTER_TYPE_TARGET, NR_DAMOS_FILTER_TYPES, diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 4733aaddcae8..b3cb2578a201 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -222,6 +222,9 @@ static bool __damos_pa_filter_out(struct damos_filter *filter, if (matched) damon_folio_mkold(folio); break; + case DAMOS_FILTER_TYPE_UNMAPPED: + matched = !folio_mapped(folio) || !folio_raw_mapping(folio); + break; default: break; } diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 6cc976b8e363..25356fe99273 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -345,6 +345,7 @@ static const char * const damon_sysfs_scheme_filter_type_strs[] = { "anon", "memcg", "young", + "unmapped", "addr", "target", };