public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/damon/core: performance optimizations for kdamond hot path
@ 2026-03-22 18:46 Josh Law
  2026-03-22 18:46 ` [PATCH 1/2] mm/damon/core: optimize kdamond_apply_schemes() by inverting scheme and region loops Josh Law
  2026-03-22 18:46 ` [PATCH 2/2] mm/damon/core: eliminate hot-path integer division in damon_max_nr_accesses() Josh Law
  0 siblings, 2 replies; 13+ messages in thread
From: Josh Law @ 2026-03-22 18:46 UTC (permalink / raw)
  To: sj, akpm; +Cc: damon, linux-mm, linux-kernel

This patch series provides two performance optimizations for the DAMON
core, focusing on reducing unnecessary iterations and eliminating
expensive hardware integer divisions in the hot paths.

The first patch inverts the nested loops in kdamond_apply_schemes().
Previously, it iterated over all regions and then all schemes for each
region. By iterating over schemes on the outside, we can evaluate
scheme-level invariants (like activation status and quotas) once per
scheme and bypass the O(Regions) walk entirely when a scheme is inactive
or has fulfilled its quota.

The second patch eliminates a hardware integer division in
damon_max_nr_accesses(), which is called for every region during every
sample interval. It replaces the division with a read from a cached
field.

Together, these changes significantly reduce the CPU overhead of DAMON,
especially when monitoring large numbers of regions or using many
DAMOS schemes.

Josh Law (2):
  mm/damon/core: optimize kdamond_apply_schemes() by inverting scheme
    and region loops
  mm/damon/core: eliminate hot-path integer division in
    damon_max_nr_accesses()

 include/linux/damon.h |  3 +-
 mm/damon/core.c       | 72 ++++++++++++++++++-------------------------
 2 files changed, 31 insertions(+), 44 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-03-23 14:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-22 18:46 [PATCH 0/2] mm/damon/core: performance optimizations for kdamond hot path Josh Law
2026-03-22 18:46 ` [PATCH 1/2] mm/damon/core: optimize kdamond_apply_schemes() by inverting scheme and region loops Josh Law
2026-03-22 21:44   ` SeongJae Park
2026-03-22 21:47     ` Josh Law
2026-03-22 21:53     ` Josh Law
2026-03-22 21:59     ` Josh Law
2026-03-22 22:28       ` [PATCH 1/2] mm/damon/core: optimize kdamond_ap ply_schemes() " SeongJae Park
2026-03-22 22:39         ` Josh Law
2026-03-23 14:01           ` SeongJae Park
2026-03-22 22:44         ` Josh Law
2026-03-22 18:46 ` [PATCH 2/2] mm/damon/core: eliminate hot-path integer division in damon_max_nr_accesses() Josh Law
2026-03-22 21:30   ` SeongJae Park
2026-03-22 21:32     ` Josh Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox