mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] sched/core: Handle unavailable pointer hash in PR_SCHED_CORE_GET
@ 2026-09-13 14:10 Hui Su
  2026-09-13 14:10 ` [PATCH v2 1/2] sched/core: Propagate pointer hash errors from PR_SCHED_CORE_GET Hui Su
  2026-09-13 14:10 ` [PATCH v2 2/2] selftests/sched: Retry PR_SCHED_CORE_GET on EBUSY Hui Su
  0 siblings, 2 replies; 3+ messages in thread
From: Hui Su @ 2026-09-13 14:10 UTC (permalink / raw)
  To: peterz
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, shuah,
	linux-kernel, linux-kselftest, Hui Su

PR_SCHED_CORE_GET converts the internal core scheduling cookie to an
opaque userspace value with ptr_to_hashval().

When the pointer hash key is not initialized yet, ptr_to_hashval()
returns -EBUSY without storing a hash. PR_SCHED_CORE_GET currently
ignores this error and returns the zero-initialized id instead. Since
cookie 0 denotes the default core scheduling cookie, this reports
incorrect state to userspace.

Propagate the hashing error and make the scheduler selftest retry the
transient EBUSY. Do not wait for RNG initialization in
PR_SCHED_CORE_GET; ptr_to_hashval() already reports an unavailable
pointer hash key as -EBUSY, so propagate that condition through the
prctl interface.

Testing on x86_64:

  - An entropy-starved early-boot QEMU reproducer observed on the
    unfixed kernel:

        CREATE ret=0 errno=0 (Success)
        GET ret=0 errno=0 (Success) cookie=0x0000000000000000

    With patch 1, the same probe returned:

        GET ret=-1 errno=16 (Device or resource busy)

  - The selftest built successfully with:

        make -C tools/testing/selftests/sched -j12

  - With PR_SCHED_CORE_GET fault-injected to return EBUSY, the v1
    selftest continued evaluating cookie assertions using the error
    sentinel and finished with 5 failures. The v2 selftest instead
    aborted without evaluating cookie assertions after the failed GET.

  - The v2 selftest passed with normal random initialization:
    SUCCESS !!!

Changes since v1:
- Patch 1 is unchanged.
- Keep the PR_SCHED_CORE_GET status separate from the returned cookie.
- Abort after an unrecoverable or timed-out GET instead of comparing an
  error sentinel as a valid cookie.
- Return cookie values directly from the fatal error helper to keep the
  selftest comparisons compact.
- Avoid sleeping after the final retry.
- Rebased onto 2f0c1cf72f46.

v1: https://lore.kernel.org/all/20260913063439.1513107-1-sh_def@163.com/

Hui Su (2):
  sched/core: Propagate pointer hash errors from PR_SCHED_CORE_GET
  selftests/sched: Retry PR_SCHED_CORE_GET on EBUSY

 kernel/sched/core_sched.c                     |  5 +-
 tools/testing/selftests/sched/cs_prctl_test.c | 93 +++++++++++++------
 2 files changed, 66 insertions(+), 32 deletions(-)


base-commit: 2f0c1cf72f4682178506f513bbf015e591b1aa4a
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-13 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-13 14:10 [PATCH v2 0/2] sched/core: Handle unavailable pointer hash in PR_SCHED_CORE_GET Hui Su
2026-09-13 14:10 ` [PATCH v2 1/2] sched/core: Propagate pointer hash errors from PR_SCHED_CORE_GET Hui Su
2026-09-13 14:10 ` [PATCH v2 2/2] selftests/sched: Retry PR_SCHED_CORE_GET on EBUSY Hui Su

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®