Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/lru_sort: support young page filters

DAMON monitors access patterns at the region level, and hence there could
be some page level mismatches. A few hot pages could be located in cold
regions, and vice versa. Young page filters can be useful for doing
additional page level access checks before applying some DAMOS action.

DAMON_LRU_SORT is not using young page filters, though. Add a parameter
for using it.

Link: https://lkml.kernel.org/r/20260113152717.70459-7-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
303dbb1f 57d96d1a

+41
+41
mm/damon/lru_sort.c
··· 42 42 module_param(commit_inputs, bool, 0600); 43 43 44 44 /* 45 + * Filter [non-]young pages accordingly for LRU [de]prioritizations. 46 + * 47 + * If this is set, check page level access (youngness) once again before each 48 + * LRU [de]prioritization operation. LRU prioritization operation is skipped 49 + * if the page has not accessed since the last check (not young). LRU 50 + * deprioritization operation is skipped if the page has accessed since the 51 + * last check (young). The feature is enabled or disabled if this parameter is 52 + * set as ``Y`` or ``N``, respectively. 53 + * 54 + * Disabled by default. 55 + */ 56 + static bool filter_young_pages __read_mostly; 57 + module_param(filter_young_pages, bool, 0600); 58 + 59 + /* 45 60 * Access frequency threshold for hot memory regions identification in permil. 46 61 * 47 62 * If a memory region is accessed in frequency of this or higher, ··· 208 193 return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO); 209 194 } 210 195 196 + static int damon_lru_sort_add_filters(struct damos *hot_scheme, 197 + struct damos *cold_scheme) 198 + { 199 + struct damos_filter *filter; 200 + 201 + if (!filter_young_pages) 202 + return 0; 203 + 204 + /* disallow prioritizing not-young pages */ 205 + filter = damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, false, false); 206 + if (!filter) 207 + return -ENOMEM; 208 + damos_add_filter(hot_scheme, filter); 209 + 210 + /* disabllow de-prioritizing young pages */ 211 + filter = damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, true, false); 212 + if (!filter) 213 + return -ENOMEM; 214 + damos_add_filter(cold_scheme, filter); 215 + return 0; 216 + } 217 + 211 218 static int damon_lru_sort_apply_parameters(void) 212 219 { 213 220 struct damon_ctx *param_ctx; ··· 276 239 277 240 damon_set_schemes(param_ctx, &hot_scheme, 1); 278 241 damon_add_scheme(param_ctx, cold_scheme); 242 + 243 + err = damon_lru_sort_add_filters(hot_scheme, cold_scheme); 244 + if (err) 245 + goto out; 279 246 280 247 err = damon_set_region_biggest_system_ram_default(param_target, 281 248 &monitor_region_start,