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.

Merge tag 'cgroup-for-6.18-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup

Pull cgroup fixes from Tejun Heo:

- Fix seqcount lockdep assertion failure in cgroup freezer on
PREEMPT_RT.

Plain seqcount_t expects preemption disabled, but PREEMPT_RT
spinlocks don't disable preemption. Switch to seqcount_spinlock_t to
properly associate css_set_lock with the freeze timing seqcount.

- Misc changes including kernel-doc warning fix for misc_res_type enum
and improved selftest diagnostics.

* tag 'cgroup-for-6.18-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
cgroup/misc: fix misc_res_type kernel-doc warning
selftests: cgroup: Use values_close_report in test_cpu
selftests: cgroup: add values_close_report helper
cgroup: Fix seqcount lockdep assertion in cgroup freezer

+32 -12
+1 -1
include/linux/cgroup-defs.h
··· 452 452 int nr_frozen_tasks; 453 453 454 454 /* Freeze time data consistency protection */ 455 - seqcount_t freeze_seq; 455 + seqcount_spinlock_t freeze_seq; 456 456 457 457 /* 458 458 * Most recent time the cgroup was requested to freeze.
+1 -1
include/linux/misc_cgroup.h
··· 19 19 MISC_CG_RES_SEV_ES, 20 20 #endif 21 21 #ifdef CONFIG_INTEL_TDX_HOST 22 - /* Intel TDX HKIDs resource */ 22 + /** @MISC_CG_RES_TDX: Intel TDX HKIDs resource */ 23 23 MISC_CG_RES_TDX, 24 24 #endif 25 25 /** @MISC_CG_RES_TYPES: count of enum misc_res_type constants */
+1 -1
kernel/cgroup/cgroup.c
··· 5892 5892 * if the parent has to be frozen, the child has too. 5893 5893 */ 5894 5894 cgrp->freezer.e_freeze = parent->freezer.e_freeze; 5895 - seqcount_init(&cgrp->freezer.freeze_seq); 5895 + seqcount_spinlock_init(&cgrp->freezer.freeze_seq, &css_set_lock); 5896 5896 if (cgrp->freezer.e_freeze) { 5897 5897 /* 5898 5898 * Set the CGRP_FREEZE flag, so when a process will be
+20
tools/testing/selftests/cgroup/lib/include/cgroup_util.h
··· 25 25 return labs(a - b) <= (a + b) / 100 * err; 26 26 } 27 27 28 + /* 29 + * Checks if two given values differ by less than err% of their sum and assert 30 + * with detailed debug info if not. 31 + */ 32 + static inline int values_close_report(long a, long b, int err) 33 + { 34 + long diff = labs(a - b); 35 + long limit = (a + b) / 100 * err; 36 + double actual_err = (a + b) ? (100.0 * diff / (a + b)) : 0.0; 37 + int close = diff <= limit; 38 + 39 + if (!close) 40 + fprintf(stderr, 41 + "[FAIL] actual=%ld expected=%ld | diff=%ld | limit=%ld | " 42 + "tolerance=%d%% | actual_error=%.2f%%\n", 43 + a, b, diff, limit, err, actual_err); 44 + 45 + return close; 46 + } 47 + 28 48 extern ssize_t read_text(const char *path, char *buf, size_t max_len); 29 49 extern ssize_t write_text(const char *path, char *buf, ssize_t len); 30 50
+9 -9
tools/testing/selftests/cgroup/test_cpu.c
··· 219 219 if (user_usec <= 0) 220 220 goto cleanup; 221 221 222 - if (!values_close(usage_usec, expected_usage_usec, 1)) 222 + if (!values_close_report(usage_usec, expected_usage_usec, 1)) 223 223 goto cleanup; 224 224 225 225 ret = KSFT_PASS; ··· 291 291 292 292 user_usec = cg_read_key_long(cpucg, "cpu.stat", "user_usec"); 293 293 nice_usec = cg_read_key_long(cpucg, "cpu.stat", "nice_usec"); 294 - if (!values_close(nice_usec, expected_nice_usec, 1)) 294 + if (!values_close_report(nice_usec, expected_nice_usec, 1)) 295 295 goto cleanup; 296 296 297 297 ret = KSFT_PASS; ··· 404 404 goto cleanup; 405 405 406 406 delta = children[i + 1].usage - children[i].usage; 407 - if (!values_close(delta, children[0].usage, 35)) 407 + if (!values_close_report(delta, children[0].usage, 35)) 408 408 goto cleanup; 409 409 } 410 410 ··· 444 444 int ret = KSFT_FAIL, i; 445 445 446 446 for (i = 0; i < num_children - 1; i++) { 447 - if (!values_close(children[i + 1].usage, children[0].usage, 15)) 447 + if (!values_close_report(children[i + 1].usage, children[0].usage, 15)) 448 448 goto cleanup; 449 449 } 450 450 ··· 573 573 574 574 nested_leaf_usage = leaf[1].usage + leaf[2].usage; 575 575 if (overprovisioned) { 576 - if (!values_close(leaf[0].usage, nested_leaf_usage, 15)) 576 + if (!values_close_report(leaf[0].usage, nested_leaf_usage, 15)) 577 577 goto cleanup; 578 - } else if (!values_close(leaf[0].usage * 2, nested_leaf_usage, 15)) 578 + } else if (!values_close_report(leaf[0].usage * 2, nested_leaf_usage, 15)) 579 579 goto cleanup; 580 580 581 581 582 582 child_usage = cg_read_key_long(child, "cpu.stat", "usage_usec"); 583 583 if (child_usage <= 0) 584 584 goto cleanup; 585 - if (!values_close(child_usage, nested_leaf_usage, 1)) 585 + if (!values_close_report(child_usage, nested_leaf_usage, 1)) 586 586 goto cleanup; 587 587 588 588 ret = KSFT_PASS; ··· 691 691 expected_usage_usec 692 692 = n_periods * quota_usec + MIN(remainder_usec, quota_usec); 693 693 694 - if (!values_close(usage_usec, expected_usage_usec, 10)) 694 + if (!values_close_report(usage_usec, expected_usage_usec, 10)) 695 695 goto cleanup; 696 696 697 697 ret = KSFT_PASS; ··· 762 762 expected_usage_usec 763 763 = n_periods * quota_usec + MIN(remainder_usec, quota_usec); 764 764 765 - if (!values_close(usage_usec, expected_usage_usec, 10)) 765 + if (!values_close_report(usage_usec, expected_usage_usec, 10)) 766 766 goto cleanup; 767 767 768 768 ret = KSFT_PASS;