sysfs.py: extend assert_ctx_committed() for monitoring targets

assert_ctx_committed() is not asserting monitoring targets commitment,
since all existing callers of the function assume no target changes. 
Extend it for future usage.

Link: https://lkml.kernel.org/r/20251023012535.69625-9-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>
This commit is contained in:
SeongJae Park
2025-10-22 18:25:32 -07:00
committed by Andrew Morton
parent a00f18abef
commit 65a9033db7

View File

@@ -164,6 +164,16 @@ def assert_monitoring_attrs_committed(attrs, dump):
assert_true(dump['max_nr_regions'] == attrs.max_nr_regions,
'max_nr_regions', dump)
def assert_monitoring_target_committed(target, dump):
# target.pid is the pid "number", while dump['pid'] is 'struct pid'
# pointer, and hence cannot be compared.
assert_true(dump['obsolete'] == target.obsolete, 'target obsolete', dump)
def assert_monitoring_targets_committed(targets, dump):
assert_true(len(targets) == len(dump), 'len_targets', dump)
for idx, target in enumerate(targets):
assert_monitoring_target_committed(target, dump[idx])
def assert_ctx_committed(ctx, dump):
ops_val = {
'vaddr': 0,
@@ -172,6 +182,7 @@ def assert_ctx_committed(ctx, dump):
}
assert_true(dump['ops']['id'] == ops_val[ctx.ops], 'ops_id', dump)
assert_monitoring_attrs_committed(ctx.monitoring_attrs, dump['attrs'])
assert_monitoring_targets_committed(ctx.targets, dump['adaptive_targets'])
assert_schemes_committed(ctx.schemes, dump['schemes'])
def assert_ctxs_committed(ctxs, dump):