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.

selftests/damon/sysfs: add obsolete_target test

A new DAMON sysfs file for pin-point target removal, namely
obsolete_target, has been added. Add a test for the functionality. It
starts DAMON with three monitoring target processes, mark one in the
middle as obsolete, commit it, and confirm the internal DAMON status is
updated to remove the target in the middle.

Link: https://lkml.kernel.org/r/20251023012535.69625-10-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Bijan Tabatabai <bijan311@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
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: Shuah Khan <shuah@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
809ba69f 65a9033d

+37
+37
tools/testing/selftests/damon/sysfs.py
··· 279 279 280 280 kdamonds.stop() 281 281 282 + # test obsolete_target. 283 + proc1 = subprocess.Popen(['sh'], stdout=subprocess.PIPE, 284 + stderr=subprocess.PIPE) 285 + proc2 = subprocess.Popen(['sh'], stdout=subprocess.PIPE, 286 + stderr=subprocess.PIPE) 287 + proc3 = subprocess.Popen(['sh'], stdout=subprocess.PIPE, 288 + stderr=subprocess.PIPE) 289 + kdamonds = _damon_sysfs.Kdamonds( 290 + [_damon_sysfs.Kdamond( 291 + contexts=[_damon_sysfs.DamonCtx( 292 + ops='vaddr', 293 + targets=[ 294 + _damon_sysfs.DamonTarget(pid=proc1.pid), 295 + _damon_sysfs.DamonTarget(pid=proc2.pid), 296 + _damon_sysfs.DamonTarget(pid=proc3.pid), 297 + ], 298 + schemes=[_damon_sysfs.Damos()], 299 + )])]) 300 + err = kdamonds.start() 301 + if err is not None: 302 + print('kdamond start failed: %s' % err) 303 + exit(1) 304 + kdamonds.kdamonds[0].contexts[0].targets[1].obsolete = True 305 + kdamonds.kdamonds[0].commit() 306 + 307 + status, err = dump_damon_status_dict(kdamonds.kdamonds[0].pid) 308 + if err is not None: 309 + print(err) 310 + kdamonds.stop() 311 + exit(1) 312 + 313 + del kdamonds.kdamonds[0].contexts[0].targets[1] 314 + 315 + assert_ctxs_committed(kdamonds.kdamonds[0].contexts, status['contexts']) 316 + 317 + kdamonds.stop() 318 + 282 319 if __name__ == '__main__': 283 320 main()