linux-stable/mm/damon
Ryan Roberts 7eeed3ed1a mm/damon/ops-common: atomically test and clear young on ptes and pmds
commit c11d34fa13 upstream.

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>
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-07-23 13:47:47 +02:00
..
Kconfig mm/damon: add kunit tests 2021-09-08 11:50:25 -07:00
Makefile mm/damon: implement a debugfs-based user space interface 2021-09-08 11:50:24 -07:00
core-test.h mm/damon/core-test: fix wrong expectations for 'damon_split_regions_of()' 2021-10-28 17:18:55 -07:00
core.c mm/damon/core: fix fake load reports due to uninterruptible sleeps 2021-12-14 10:57:11 +01:00
dbgfs-test.h mm/damon: don't use strnlen() with known-bogus source length 2021-09-24 16:13:34 -07:00
dbgfs.c mm/damon/dbgfs: check if rm_contexts input is for a real context 2022-11-16 09:58:27 +01:00
vaddr-test.h mm/damon: add kunit tests 2021-09-08 11:50:25 -07:00
vaddr.c mm/damon/ops-common: atomically test and clear young on ptes and pmds 2023-07-23 13:47:47 +02:00