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/paddr: support addr_unit for access monitoring

Add support of addr_unit paramer for access monitoing operations of paddr.

Link: https://lkml.kernel.org/r/20250828171242.59810-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Quanmin Yan <yanquanmin1@huawei.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
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>
Cc: ze zuo <zuoze1@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
d8096848 09a616cb

+21 -11
+21 -11
mm/damon/paddr.c
··· 18 18 #include "../internal.h" 19 19 #include "ops-common.h" 20 20 21 - static void damon_pa_mkold(unsigned long paddr) 21 + static phys_addr_t damon_pa_phys_addr( 22 + unsigned long addr, unsigned long addr_unit) 23 + { 24 + return (phys_addr_t)addr * addr_unit; 25 + } 26 + 27 + static void damon_pa_mkold(phys_addr_t paddr) 22 28 { 23 29 struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); 24 30 ··· 35 29 folio_put(folio); 36 30 } 37 31 38 - static void __damon_pa_prepare_access_check(struct damon_region *r) 32 + static void __damon_pa_prepare_access_check(struct damon_region *r, 33 + unsigned long addr_unit) 39 34 { 40 35 r->sampling_addr = damon_rand(r->ar.start, r->ar.end); 41 36 42 - damon_pa_mkold(r->sampling_addr); 37 + damon_pa_mkold(damon_pa_phys_addr(r->sampling_addr, addr_unit)); 43 38 } 44 39 45 40 static void damon_pa_prepare_access_checks(struct damon_ctx *ctx) ··· 50 43 51 44 damon_for_each_target(t, ctx) { 52 45 damon_for_each_region(r, t) 53 - __damon_pa_prepare_access_check(r); 46 + __damon_pa_prepare_access_check(r, ctx->addr_unit); 54 47 } 55 48 } 56 49 57 - static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) 50 + static bool damon_pa_young(phys_addr_t paddr, unsigned long *folio_sz) 58 51 { 59 52 struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); 60 53 bool accessed; ··· 69 62 } 70 63 71 64 static void __damon_pa_check_access(struct damon_region *r, 72 - struct damon_attrs *attrs) 65 + struct damon_attrs *attrs, unsigned long addr_unit) 73 66 { 74 - static unsigned long last_addr; 67 + static phys_addr_t last_addr; 75 68 static unsigned long last_folio_sz = PAGE_SIZE; 76 69 static bool last_accessed; 70 + phys_addr_t sampling_addr = damon_pa_phys_addr( 71 + r->sampling_addr, addr_unit); 77 72 78 73 /* If the region is in the last checked page, reuse the result */ 79 74 if (ALIGN_DOWN(last_addr, last_folio_sz) == 80 - ALIGN_DOWN(r->sampling_addr, last_folio_sz)) { 75 + ALIGN_DOWN(sampling_addr, last_folio_sz)) { 81 76 damon_update_region_access_rate(r, last_accessed, attrs); 82 77 return; 83 78 } 84 79 85 - last_accessed = damon_pa_young(r->sampling_addr, &last_folio_sz); 80 + last_accessed = damon_pa_young(sampling_addr, &last_folio_sz); 86 81 damon_update_region_access_rate(r, last_accessed, attrs); 87 82 88 - last_addr = r->sampling_addr; 83 + last_addr = sampling_addr; 89 84 } 90 85 91 86 static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) ··· 98 89 99 90 damon_for_each_target(t, ctx) { 100 91 damon_for_each_region(r, t) { 101 - __damon_pa_check_access(r, &ctx->attrs); 92 + __damon_pa_check_access( 93 + r, &ctx->attrs, ctx->addr_unit); 102 94 max_nr_accesses = max(r->nr_accesses, max_nr_accesses); 103 95 } 104 96 }