Qianfeng Rong
adf085ff0d
mm: remove redundant __GFP_NOWARN
...
Commit 16f5dfbc85 ("gfp: include __GFP_NOWARN in GFP_NOWAIT") made
GFP_NOWAIT implicitly include __GFP_NOWARN.
Therefore, explicit __GFP_NOWARN combined with GFP_NOWAIT (e.g.,
`GFP_NOWAIT | __GFP_NOWARN`) is now redundant. Let's clean up these
redundant flags across subsystems.
No functional changes.
Link: https://lkml.kernel.org/r/20250812135225.274316-1-rongqianfeng@vivo.com
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com >
Reviewed-by: Harry Yoo <harry.yoo@oracle.com >
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com >
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com >
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Acked-by: David Hildenbrand <david@redhat.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2025-09-13 16:54:58 -07:00
Yueyang Pan
408b299a62
mm/damon/paddr: move filters existence check function to ops-common
...
Patch series "mm/damon/vaddr: support stat-purpose DAMOS filters", v4.
Extend DAMOS_STAT handling of the DAMON operations sets for virtual
address spaces for ops-level DAMOS filters.
Functionality Test
==================
I wrote a small test program which allocates 10GB of DRAM, use
madvise(MADV_HUGEPAGE) to convert the base pages to 2MB huge pages Then my
program does the following things in order:
1. Write sequentially to the whole 10GB region
2. Read the first 5GB region sequentially for 10 times
3. Sleep 5s
4. Read the second 5GB region sequentially for 10 times
With a proper damon setting, we are expected to see df-passed to be 10GB
and hot region move around with the read
$ # Start DAMON
$ sudo ./damo/damo start "./my_test/test" --monitoring_intervals 100ms\
1s 2s
$ # Show DAMON-generated access pattern snapshot
$ sudo ./damo/damo report access --snapshot_damos_filter allow \
hugepage_size 2MiB 2MiB
heatmap:
# min/max temperatures: -600,000,000, 100,001,000, column size: 137.352 MiB
intervals: sample 100 ms aggr 1 s (max access hz 10)
# damos filters (df): reject none hugepage_size [2.000 MiB, 2.000 MiB]
df-pass:
# min/max temperatures: -400,000,000, 100,001,000, column size: 128.031 MiB
0 addr 85.373 TiB size 745.555 MiB access 0 hz age 6 s df-passed 0 B
1 addr 127.608 TiB size 877.664 MiB access 3.000 hz age 0 ns df-passed 878.000 MiB
2 addr 127.609 TiB size 219.418 MiB access 2.000 hz age 0 ns df-passed 220.000 MiB
3 addr 127.609 TiB size 316.613 MiB access 1.000 hz age 1 s df-passed 316.000 MiB
4 addr 127.609 TiB size 474.922 MiB access 1.000 hz age 1 s df-passed 476.000 MiB
5 addr 127.610 TiB size 407.188 MiB access 1.000 hz age 0 ns df-passed 406.000 MiB
6 addr 127.610 TiB size 610.781 MiB access 1.000 hz age 0 ns df-passed 612.000 MiB
7 addr 127.611 TiB size 697.309 MiB access 0 hz age 0 ns df-passed 696.000 MiB
8 addr 127.611 TiB size 77.480 MiB access 1.000 hz age 0 ns df-passed 78.000 MiB
9 addr 127.611 TiB size 573.102 MiB access 1.000 hz age 0 ns df-passed 574.000 MiB
10 addr 127.612 TiB size 245.617 MiB access 2.000 hz age 0 ns df-passed 246.000 MiB
11 addr 127.612 TiB size 295.102 MiB access 1.000 hz age 1 s df-passed 294.000 MiB
12 addr 127.612 TiB size 295.105 MiB access 1.000 hz age 1 s df-passed 296.000 MiB
13 addr 127.613 TiB size 67.172 MiB access 1.000 hz age 1 s df-passed 66.000 MiB
14 addr 127.613 TiB size 604.570 MiB access 0 hz age 1 s df-passed 606.000 MiB
15 addr 127.613 TiB size 389.578 MiB access 0 hz age 4 s df-passed 388.000 MiB
16 addr 127.614 TiB size 259.719 MiB access 0 hz age 4 s df-passed 260.000 MiB
17 addr 127.614 TiB size 817.941 MiB access 0 hz age 4 s df-passed 818.000 MiB
18 addr 127.615 TiB size 204.488 MiB access 0 hz age 4 s df-passed 204.000 MiB
19 addr 127.615 TiB size 730.902 MiB access 0 hz age 4 s df-passed 732.000 MiB
20 addr 127.616 TiB size 182.727 MiB access 0 hz age 4 s df-passed 182.000 MiB
21 addr 127.616 TiB size 926.824 MiB access 0 hz age 2 s df-passed 928.000 MiB
22 addr 127.617 TiB size 102.984 MiB access 0 hz age 2 s df-passed 102.000 MiB
23 addr 127.617 TiB size 86.527 MiB access 0 hz age 2 s df-passed 86.000 MiB
24 addr 127.617 TiB size 778.777 MiB access 0 hz age 2 s df-passed 776.000 MiB
25 addr 127.999 TiB size 132.000 KiB access 0 hz age 6 s df-passed 0 B
memory bw estimate: 6.524 GiB per second df-passed: 6.527 GiB per second
total size: 10.731 GiB df-passed 10.000 GiB
record DAMON intervals: sample 100 ms, aggr 1 s
$ # Show DAMON-generated access pattern snapshot again
$ sudo ./damo/damo report access --snapshot_damos_filter allow \
hugepage_size 2MiB 2MiB
heatmap:
# min/max temperatures: -1,100,000,000, 2,000, column size: 137.352 MiB
intervals: sample 100 ms aggr 1 s (max access hz 10)
# damos filters (df): reject none hugepage_size [2.000 MiB, 2.000 MiB]
df-pass:
# min/max temperatures: -900,000,000, 2,000, column size: 128.031 MiB
0 addr 85.373 TiB size 745.555 MiB access 0 hz age 11 s df-passed 0 B
1 addr 127.608 TiB size 579.715 MiB access 2.000 hz age 0 ns df-passed 580.000 MiB
2 addr 127.608 TiB size 144.930 MiB access 2.000 hz age 0 ns df-passed 146.000 MiB
3 addr 127.608 TiB size 452.453 MiB access 2.000 hz age 0 ns df-passed 452.000 MiB
4 addr 127.609 TiB size 113.117 MiB access 1.000 hz age 0 ns df-passed 114.000 MiB
5 addr 127.609 TiB size 182.367 MiB access 2.000 hz age 0 ns df-passed 182.000 MiB
6 addr 127.609 TiB size 182.371 MiB access 2.000 hz age 0 ns df-passed 182.000 MiB
7 addr 127.609 TiB size 350.488 MiB access 1.000 hz age 0 ns df-passed 350.000 MiB
8 addr 127.610 TiB size 525.738 MiB access 1.000 hz age 0 ns df-passed 526.000 MiB
9 addr 127.610 TiB size 401.352 MiB access 1.000 hz age 0 ns df-passed 402.000 MiB
10 addr 127.611 TiB size 100.340 MiB access 1.000 hz age 0 ns df-passed 100.000 MiB
11 addr 127.611 TiB size 19.523 MiB access 0 hz age 0 ns df-passed 20.000 MiB
12 addr 127.611 TiB size 175.727 MiB access 0 hz age 0 ns df-passed 176.000 MiB
13 addr 127.611 TiB size 106.629 MiB access 0 hz age 0 ns df-passed 106.000 MiB
14 addr 127.611 TiB size 959.676 MiB access 0 hz age 0 ns df-passed 960.000 MiB
15 addr 127.612 TiB size 424.469 MiB access 1.000 hz age 0 ns df-passed 424.000 MiB
16 addr 127.612 TiB size 424.469 MiB access 1.000 hz age 0 ns df-passed 424.000 MiB
17 addr 127.613 TiB size 201.648 MiB access 0 hz age 6 s df-passed 202.000 MiB
18 addr 127.613 TiB size 806.609 MiB access 0 hz age 6 s df-passed 806.000 MiB
19 addr 127.614 TiB size 862.125 MiB access 0 hz age 9 s df-passed 862.000 MiB
20 addr 127.614 TiB size 215.535 MiB access 0 hz age 9 s df-passed 216.000 MiB
21 addr 127.615 TiB size 104.500 MiB access 0 hz age 9 s df-passed 104.000 MiB
22 addr 127.615 TiB size 940.523 MiB access 0 hz age 9 s df-passed 942.000 MiB
23 addr 127.616 TiB size 640.281 MiB access 0 hz age 7 s df-passed 640.000 MiB
24 addr 127.616 TiB size 426.855 MiB access 0 hz age 7 s df-passed 426.000 MiB
25 addr 127.617 TiB size 90.105 MiB access 0 hz age 7 s df-passed 90.000 MiB
26 addr 127.617 TiB size 810.965 MiB access 0 hz age 7 s df-passed 808.000 MiB
27 addr 127.999 TiB size 132.000 KiB access 0 hz age 11 s df-passed 0 B
memory bw estimate: 5.297 GiB per second df-passed: 5.297 GiB per second
total size: 10.731 GiB df-passed 10.000 GiB
record DAMON intervals: sample 100 ms, aggr 1 s
As you can see the total df-passed region is 10GiB and the hot region
moves as the seq read keeps going
This patch (of 2):
This patch moves damon_pa_scheme_has_filter to ops-common. renaming to
damos_ops_has_filter. Doing so allows us to reuse its logic in the vaddr
version of DAMOS_STAT.
Link: https://lkml.kernel.org/r/cover.1754135312.git.pyyjason@gmail.com
Link: https://lkml.kernel.org/r/cbe01740f7ac5ac7c9fd1ca367d297c3d7f2a69d.1754135312.git.pyyjason@gmail.com
Signed-off-by: Yueyang Pan <pyyjason@gmail.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Cc: Usama Arif <usamaarif642@gmail.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2025-09-13 16:54:47 -07:00
SeongJae Park
7e6c313069
mm/damon/ops-common: ignore migration request to invalid nodes
...
damon_migrate_pages() tries migration even if the target node is invalid.
If users mistakenly make such invalid requests via
DAMOS_MIGRATE_{HOT,COLD} action, the below kernel BUG can happen.
[ 7831.883495] BUG: unable to handle page fault for address: 0000000000001f48
[ 7831.884160] #PF: supervisor read access in kernel mode
[ 7831.884681] #PF: error_code(0x0000) - not-present page
[ 7831.885203] PGD 0 P4D 0
[ 7831.885468] Oops: Oops: 0000 [#1 ] SMP PTI
[ 7831.885852] CPU: 31 UID: 0 PID: 94202 Comm: kdamond.0 Not tainted 6.16.0-rc5-mm-new-damon+ #93 PREEMPT(voluntary)
[ 7831.886913] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-4.el9 04/01/2014
[ 7831.887777] RIP: 0010:__alloc_frozen_pages_noprof (include/linux/mmzone.h:1724 include/linux/mmzone.h:1750 mm/page_alloc.c:4936 mm/page_alloc.c:5137)
[...]
[ 7831.895953] Call Trace:
[ 7831.896195] <TASK>
[ 7831.896397] __folio_alloc_noprof (mm/page_alloc.c:5183 mm/page_alloc.c:5192)
[ 7831.896787] migrate_pages_batch (mm/migrate.c:1189 mm/migrate.c:1851)
[ 7831.897228] ? __pfx_alloc_migration_target (mm/migrate.c:2137)
[ 7831.897735] migrate_pages (mm/migrate.c:2078)
[ 7831.898141] ? __pfx_alloc_migration_target (mm/migrate.c:2137)
[ 7831.898664] damon_migrate_folio_list (mm/damon/ops-common.c:321 mm/damon/ops-common.c:354)
[ 7831.899140] damon_migrate_pages (mm/damon/ops-common.c:405)
[...]
Add a target node validity check in damon_migrate_pages(). The validity
check is stolen from that of do_pages_move(), which is being used for the
move_pages() system call.
Link: https://lkml.kernel.org/r/20250720185822.1451-1-sj@kernel.org
Fixes: b51820ebea ("mm/damon/paddr: introduce DAMOS_MIGRATE_COLD action for demotion") [6.11.x]
Signed-off-by: SeongJae Park <sj@kernel.org >
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com >
Cc: Honggyu Kim <honggyu.kim@sk.com >
Cc: Hyeongtak Ji <hyeongtak.ji@sk.com >
Cc: <stable@vger.kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2025-07-24 19:12:43 -07:00
Bijan Tabatabai
0a707d6b04
mm/damon: move folio filtering from paddr to ops-common
...
This patch moves damos_pa_filter_match and the functions it calls to
ops-common, renaming it to damos_folio_filter_match. Doing so allows us
to share the filtering logic for the vaddr version of the
migrate_{hot,cold} schemes.
Link: https://lkml.kernel.org/r/20250709005952.17776-13-bijan311@gmail.com
Co-developed-by: Ravi Shankar Jonnalagadda <ravis.opensrc@micron.com >
Signed-off-by: Ravi Shankar Jonnalagadda <ravis.opensrc@micron.com >
Signed-off-by: Bijan Tabatabai <bijantabatab@micron.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Cc: Jonathan Corbet <corbet@lwn.net >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2025-07-19 18:59:50 -07:00
Bijan Tabatabai
13dde31db7
mm/damon: move migration helpers from paddr to ops-common
...
This patch moves the damon_pa_migrate_pages function along with its
corresponding helper functions from paddr to ops-common. The function
prefix of "damon_pa_" was also changed to just "damon_" accordingly.
This patch will allow page migration to be available to vaddr schemes as
well as paddr schemes.
Link: https://lkml.kernel.org/r/20250709005952.17776-9-bijan311@gmail.com
Co-developed-by: Ravi Shankar Jonnalagadda <ravis.opensrc@micron.com >
Signed-off-by: Ravi Shankar Jonnalagadda <ravis.opensrc@micron.com >
Signed-off-by: Bijan Tabatabai <bijantabatab@micron.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Cc: Jonathan Corbet <corbet@lwn.net >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2025-07-19 18:59:49 -07:00
Enze Li
ea68ea9091
mm/damon: s/primitives/code/ on comments
...
The word 'primitive' is not explicit. To make the code more easily
understood, this commit renames 'primitives' to 'code' in header comments
of some source files.
Link: https://lkml.kernel.org/r/20250530053115.153238-1-lienze@kylinos.cn
Signed-off-by: Enze Li <lienze@kylinos.cn >
Reviewed-by: SeongJae Park <sj@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2025-06-05 21:55:41 -07:00
Usama Arif
3a06696305
mm/damon/ops: have damon_get_folio return folio even for tail pages
...
Patch series "mm/damon/paddr: fix large folios access and schemes handling".
DAMON operations set for physical address space, namely 'paddr', treats
tail pages as unaccessed always. It can also apply DAMOS action to a
large folio multiple times within single DAMOS' regions walking. As a
result, the monitoring output has poor quality and DAMOS works in
unexpected ways when large folios are being used. Fix those.
The patches were parts of Usama's hugepage_size DAMOS filter patch
series[1]. The first fix has collected from there with a slight commit
message change for the subject prefix. The second fix is re-written by SJ
and posted as an RFC before this series. The second one also got a slight
commit message change for the subject prefix.
[1] https://lore.kernel.org/20250203225604.44742-1-usamaarif642@gmail.com
[2] https://lore.kernel.org/20250206231103.38298-1-sj@kernel.org
This patch (of 2):
This effectively adds support for large folios in damon for paddr, as
damon_pa_mkold/young won't get a null folio from this function and won't
ignore it, hence access will be checked and reported. This also means
that larger folios will be considered for different DAMOS actions like
pageout, prioritization and migration. As these DAMOS actions will
consider larger folios, iterate through the region at folio_size and not
PAGE_SIZE intervals. This should not have an affect on vaddr, as
damon_young_pmd_entry considers pmd entries.
Link: https://lkml.kernel.org/r/20250207212033.45269-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20250207212033.45269-2-sj@kernel.org
Fixes: a28397beb5 ("mm/damon: implement primitives for physical address space monitoring")
Signed-off-by: Usama Arif <usamaarif642@gmail.com >
Signed-off-by: SeongJae Park <sj@kernel.org >
Reviewed-by: SeongJae Park <sj@kernel.org >
Cc: <stable@vger.kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2025-03-16 22:06:08 -07:00
David Hildenbrand
1f3ac4c577
mm/damon: handle device-exclusive entries correctly in damon_folio_mkold_one()
...
Ever since commit b756a3b5e7 ("mm: device exclusive memory access") we
can return with a device-exclusive entry from page_vma_mapped_walk().
damon_folio_mkold_one() is not prepared for that and calls
damon_ptep_mkold() with PFN swap PTEs. Teach damon_ptep_mkold() to deal
with these PFN swap PTEs. Note that device-private entries are so far not
applicable on that path, as damon_get_folio() filters out non-lru folios.
Should we just skip PFN swap PTEs completely? Possible, but it seems
straight forward to just handle it correctly.
Note that we could currently only run into this case with device-exclusive
entries on THPs. We still adjust the mapcount on conversion to
device-exclusive; this makes the rmap walk abort early for small folios,
because we'll always have !folio_mapped() with a single device-exclusive
entry. We'll adjust the mapcount logic once all page_vma_mapped_walk()
users can properly handle device-exclusive entries.
Link: https://lkml.kernel.org/r/20250210193801.781278-16-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Tested-by: Alistair Popple <apopple@nvidia.com >
Cc: Alex Shi <alexs@kernel.org >
Cc: Danilo Krummrich <dakr@kernel.org >
Cc: Dave Airlie <airlied@gmail.com >
Cc: Jann Horn <jannh@google.com >
Cc: Jason Gunthorpe <jgg@nvidia.com >
Cc: Jerome Glisse <jglisse@redhat.com >
Cc: John Hubbard <jhubbard@nvidia.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Karol Herbst <kherbst@redhat.com >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com >
Cc: Lyude <lyude@redhat.com >
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Pasha Tatashin <pasha.tatashin@soleen.com >
Cc: Peter Xu <peterx@redhat.com >
Cc: Peter Zijlstra (Intel) <peterz@infradead.org >
Cc: Simona Vetter <simona.vetter@ffwll.ch >
Cc: Vlastimil Babka <vbabka@suse.cz >
Cc: Yanteng Si <si.yanteng@linux.dev >
Cc: Barry Song <v-songbaohua@oppo.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2025-03-16 22:06:00 -07:00
SeongJae Park
3bafc47d3c
mm/damon/ops-common: avoid divide-by-zero during region hotness calculation
...
When calculating the hotness of each region for the under-quota regions
prioritization, DAMON divides some values by the maximum nr_accesses.
However, due to the type of the related variables, simple division-based
calculation of the divisor can return zero. As a result, divide-by-zero
is possible. Fix it by using damon_max_nr_accesses(), which handles the
case.
Link: https://lkml.kernel.org/r/20231019194924.100347-4-sj@kernel.org
Fixes: 198f0f4c58 ("mm/damon/vaddr,paddr: support pageout prioritization")
Signed-off-by: SeongJae Park <sj@kernel.org >
Reported-by: Jakub Acs <acsjakub@amazon.de >
Cc: <stable@vger.kernel.org > [5.16+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-10-25 16:47:15 -07:00
Levi Yun
e7ee3f9791
damon: use pmdp_get instead of drectly dereferencing pmd
...
As ptep_get, Use the pmdp_get wrapper when we accessing pmdval instead of
directly dereferencing pmd.
Link: https://lkml.kernel.org/r/20230727212157.2985025-1-ppbuk5246@gmail.com
Signed-off-by: Levi Yun <ppbuk5246@gmail.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-08-21 13:37:30 -07:00
Ryan Roberts
c33c794828
mm: ptep_get() conversion
...
Convert all instances of direct pte_t* dereferencing to instead use
ptep_get() helper. This means that by default, the accesses change from a
C dereference to a READ_ONCE(). This is technically the correct thing to
do since where pgtables are modified by HW (for access/dirty) they are
volatile and therefore we should always ensure READ_ONCE() semantics.
But more importantly, by always using the helper, it can be overridden by
the architecture to fully encapsulate the contents of the pte. Arch code
is deliberately not converted, as the arch code knows best. It is
intended that arch code (arm64) will override the default with its own
implementation that can (e.g.) hide certain bits from the core code, or
determine young/dirty status by mixing in state from another source.
Conversion was done using Coccinelle:
----
// $ make coccicheck \
// COCCI=ptepget.cocci \
// SPFLAGS="--include-headers" \
// MODE=patch
virtual patch
@ depends on patch @
pte_t *v;
@@
- *v
+ ptep_get(v)
----
Then reviewed and hand-edited to avoid multiple unnecessary calls to
ptep_get(), instead opting to store the result of a single call in a
variable, where it is correct to do so. This aims to negate any cost of
READ_ONCE() and will benefit arch-overrides that may be more complex.
Included is a fix for an issue in an earlier version of this patch that
was pointed out by kernel test robot. The issue arose because config
MMU=n elides definition of the ptep helper functions, including
ptep_get(). HUGETLB_PAGE=n configs still define a simple
huge_ptep_clear_flush() for linking purposes, which dereferences the ptep.
So when both configs are disabled, this caused a build error because
ptep_get() is not defined. Fix by continuing to do a direct dereference
when MMU=n. This is safe because for this config the arch code cannot be
trying to virtualize the ptes because none of the ptep helpers are
defined.
Link: https://lkml.kernel.org/r/20230612151545.3317766-4-ryan.roberts@arm.com
Reported-by: kernel test robot <lkp@intel.com >
Link: https://lore.kernel.org/oe-kbuild-all/202305120142.yXsNEo6H-lkp@intel.com/
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alex Williamson <alex.williamson@redhat.com >
Cc: Al Viro <viro@zeniv.linux.org.uk >
Cc: Andrey Konovalov <andreyknvl@gmail.com >
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com >
Cc: Christian Brauner <brauner@kernel.org >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Daniel Vetter <daniel@ffwll.ch >
Cc: Dave Airlie <airlied@gmail.com >
Cc: Dimitri Sivanich <dimitri.sivanich@hpe.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Jason Gunthorpe <jgg@ziepe.ca >
Cc: Jérôme Glisse <jglisse@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Johannes Weiner <hannes@cmpxchg.org >
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com >
Cc: Lorenzo Stoakes <lstoakes@gmail.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Matthew Wilcox <willy@infradead.org >
Cc: Miaohe Lin <linmiaohe@huawei.com >
Cc: Michal Hocko <mhocko@kernel.org >
Cc: Mike Kravetz <mike.kravetz@oracle.com >
Cc: Mike Rapoport (IBM) <rppt@kernel.org >
Cc: Muchun Song <muchun.song@linux.dev >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com >
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com >
Cc: Pavel Tatashin <pasha.tatashin@soleen.com >
Cc: Roman Gushchin <roman.gushchin@linux.dev >
Cc: SeongJae Park <sj@kernel.org >
Cc: Shakeel Butt <shakeelb@google.com >
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com >
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Yu Zhao <yuzhao@google.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-06-19 16:19:25 -07:00
Ryan Roberts
fa8c919dac
mm/damon/ops-common: refactor to use {pte|pmd}p_clear_young_notify()
...
With the fix in place to atomically test and clear young on ptes and pmds,
simplify the code to handle the clearing for both the primary mmu and the
mmu notifier with a single API call.
Link: https://lkml.kernel.org/r/20230602092949.545577-4-ryan.roberts@arm.com
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com >
Acked-by: Yu Zhao <yuzhao@google.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com >
Cc: Lorenzo Stoakes <lstoakes@gmail.com >
Cc: Matthew Wilcox (Oracle) <willy@infradead.org >
Cc: Mike Rapoport (IBM) <rppt@kernel.org >
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com >
Cc: Zi Yan <ziy@nvidia.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-06-09 16:25:55 -07:00
Ryan Roberts
c11d34fa13
mm/damon/ops-common: atomically test and clear young on ptes and pmds
...
It is racy to non-atomically read a pte, then clear the young bit, then
write it back as this could discard dirty information. Further, it is bad
practice to directly set a pte entry within a table. Instead clearing
young must go through the arch-provided helper,
ptep_test_and_clear_young() to ensure it is modified atomically and to
give the arch code visibility and allow it to check (and potentially
modify) the operation.
Link: https://lkml.kernel.org/r/20230602092949.545577-3-ryan.roberts@arm.com
Fixes: 3f49584b26 ("mm/damon: implement primitives for the virtual memory address spaces").
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com >
Reviewed-by: Zi Yan <ziy@nvidia.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com >
Cc: Lorenzo Stoakes <lstoakes@gmail.com >
Cc: Matthew Wilcox (Oracle) <willy@infradead.org >
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com >
Cc: Yu Zhao <yuzhao@google.com >
Cc: <stable@vger.kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-06-09 16:25:55 -07:00
Kefeng Wang
70e314c9ab
mm/damon: convert damon_ptep/pmdp_mkold() to use a folio
...
With damon_get_folio(), let's convert damon_ptep_mkold() and
damon_pmdp_mkold() to use a folio.
Link: https://lkml.kernel.org/r/20221230070849.63358-5-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Cc: David Hildenbrand <david@redhat.com >
Cc: Matthew Wilcox (Oracle) <willy@infradead.org >
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-01-18 17:12:52 -08:00
Kefeng Wang
5e012bba01
mm/damon: introduce damon_get_folio()
...
Introduce damon_get_folio(), and the temporary wrapper function
damon_get_page(), which help us to convert damon related functions to use
folios, and it will be dropped once the conversion is completed.
Link: https://lkml.kernel.org/r/20221230070849.63358-4-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Cc: David Hildenbrand <david@redhat.com >
Cc: Matthew Wilcox (Oracle) <willy@infradead.org >
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2023-01-18 17:12:52 -08:00
Kaixu Xia
e3e486e634
mm/damon: rename damon_pageout_score() to damon_cold_score()
...
In the beginning there is only one damos_action 'DAMOS_PAGEOUT' that need
to get the coldness score of a region for a scheme, which using
damon_pageout_score() to do that. But now there are also other
damos_action actions need the coldness score, so rename it to
damon_cold_score() to make more sense.
Link: https://lkml.kernel.org/r/1663423014-28907-1-git-send-email-kaixuxia@tencent.com
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2022-10-03 14:03:31 -07:00
SeongJae Park
cbeaa77b04
mm/damon/core: use a dedicated struct for monitoring attributes
...
DAMON monitoring attributes are directly defined as fields of 'struct
damon_ctx'. This makes 'struct damon_ctx' a little long and complicated.
This commit defines and uses a struct, 'struct damon_attrs', which is
dedicated for only the monitoring attributes to make the purpose of the
five values clearer and simplify 'struct damon_ctx'.
Link: https://lkml.kernel.org/r/20220913174449.50645-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2022-10-03 14:03:10 -07:00
Kaixu Xia
8eabc77c38
mm/damon: get the hotness from damon_hot_score() in damon_pageout_score()
...
We can get the hotness value from damon_hot_score() directly in
damon_pageout_score() function and improve the code readability.
Link: https://lkml.kernel.org/r/1661766366-20998-1-git-send-email-kaixuxia@tencent.com
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2022-09-11 20:26:05 -07:00
SeongJae Park
8cdcc53226
mm/damon/schemes: add 'LRU_PRIO' DAMOS action
...
This commit adds a new DAMOS action called 'LRU_PRIO' for the physical
address space. The action prioritizes pages in the memory regions of the
user-specified target access pattern on their LRU lists. This is hence
supposed to be used for frequently accessed (hot) memory regions so that
hot pages could be more likely protected under memory pressure.
Internally, it simply calls 'mark_page_accessed()'.
Link: https://lkml.kernel.org/r/20220613192301.8817-5-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org >
Cc: Jonathan Corbet <corbet@lwn.net >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2022-07-03 18:08:42 -07:00
Kefeng Wang
02e34fff19
mm: damon: use HPAGE_PMD_SIZE
...
Use HPAGE_PMD_SIZE instead of open coding.
Link: https://lkml.kernel.org/r/20220517145120.118523-1-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com >
Reviewed-by: SeongJae Park <sj@kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
2022-05-19 14:08:55 -07:00
SeongJae Park
f7d911c39c
mm/damon: rename damon_primitives to damon_operations
...
Patch series "Allow DAMON user code independent of monitoring primitives".
In-kernel DAMON user code is required to configure the monitoring context
(struct damon_ctx) with proper monitoring primitives (struct
damon_primitive). This makes the user code dependent to all supporting
monitoring primitives. For example, DAMON debugfs interface depends on
both DAMON_VADDR and DAMON_PADDR, though some users have interest in only
one use case. As more monitoring primitives are introduced, the problem
will be bigger.
To minimize such unnecessary dependency, this patchset makes monitoring
primitives can be registered by the implemnting code and later dynamically
searched and selected by the user code.
In addition to that, this patchset renames monitoring primitives to
monitoring operations, which is more easy to intuitively understand what
it means and how it would be structed.
This patch (of 8):
DAMON has a set of callback functions called monitoring primitives and let
it can be configured with various implementations for easy extension for
different address spaces and usages. However, the word 'primitive' is not
so explicit. Meanwhile, many other structs resembles similar purpose
calls themselves 'operations'. To make the code easier to be understood,
this commit renames 'damon_primitives' to 'damon_operations' before it is
too late to rename.
Link: https://lkml.kernel.org/r/20220215184603.1479-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20220215184603.1479-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org >
Cc: Xin Hao <xhao@linux.alibaba.com >
Cc: David Rientjes <rientjes@google.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2022-03-22 15:57:12 -07:00