What does macOS kernel return 28 (KERN_INVALID_POLICY) mean?

 

Could be also:

ConstantTypeOS
ERROR_OUT_OF_PAPERWin32 errorWindows
ippStsAffineQuadChangedIntel Ipp StatusAny
ENOSPCerrnoAny
PFN_REFERENCE_COUNTBugCheck CodeWindows
Previous Next
KERN_POLICY_LIMIT KERN_INVALID_OBJECT

KERN_INVALID_POLICY

The policy is not available in this context

KERN_INVALID_POLICY is a Mach scheduler result, not a statement that the policy-data pointer is malformed. The declaration in kern_return.h describes a scheduling policy that is not currently enabled for the processor-set context. In current XNU code, the same result is also used when a thread is not allowed to enter a requested real-time mode or when affinity sets are disabled.

That makes the policy flavor essential diagnostic data. A request that is valid on one system, thread class, or workload context can be unavailable on another without any change to the structure layout.

Two concrete policy contexts

  • THREAD_TIME_CONSTRAINT_POLICY requests real-time scheduling parameters. Current XNU rejects that request with KERN_INVALID_POLICY when the thread belongs to a work interval with a workload ID that does not permit real-time operation.
  • THREAD_AFFINITY_POLICY is marked experimental in the XNU header. It expresses an affinity relationship between threads; matching tags are only a scheduler hint to share an L2 cache when possible. It is not a request to pin a thread to a particular processor, and XNU returns KERN_INVALID_POLICY when affinity sets are disabled.

Separate availability from bad input

ResultWhat it points to
KERN_INVALID_POLICYThe policy cannot be applied in the target’s current scheduling context.
KERN_POLICY_LIMITThe requested attributes exceed a limit even though the policy is applicable.
KERN_INVALID_ARGUMENTThe call contract is wrong: for example, an invalid target, flavor, count, or field value.
KERN_NOT_SUPPORTEDThe selected facility is not supported by the current platform or implementation.

Useful investigation data

  • Log the policy flavor and its complete structure, rather than only the numeric return value.
  • Identify whether the target is the calling thread or another thread, and whether it has joined a work interval or has an existing QoS policy.
  • For affinity, verify the intended outcome. Cache-affinity tags are advisory relationships, not a portable CPU-binding mechanism.
  • For real-time requests, review the timing model before retrying. The policy data specifies period, computation, and constraint in absolute-time units, and the constraint must not be smaller than computation.

References