kernel/sched/isolation.c
Source file repositories/reference/linux-study-clean/kernel/sched/isolation.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/sched/isolation.c- Extension
.c- Size
- 10198 bytes
- Lines
- 368
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched/isolation.hlinux/pci.hsched.h
Detected Declarations
struct housekeepingenum hk_flagsfunction housekeeping_enabledfunction housekeeping_dereference_checkfunction housekeeping_any_cpufunction housekeeping_affinefunction housekeeping_test_cpufunction housekeeping_updatefunction housekeeping_initfunction kfreefunction housekeeping_setup_typefunction housekeeping_setupfunction for_each_set_bitfunction housekeeping_nohz_full_setupfunction housekeeping_isolcpus_setupexport housekeeping_overriddenexport housekeeping_enabledexport housekeeping_cpumaskexport housekeeping_any_cpuexport housekeeping_affineexport housekeeping_test_cpu
Annotated Snippet
struct housekeeping {
struct cpumask __rcu *cpumasks[HK_TYPE_MAX];
unsigned long flags;
};
static struct housekeeping housekeeping;
bool housekeeping_enabled(enum hk_type type)
{
return !!(READ_ONCE(housekeeping.flags) & BIT(type));
}
EXPORT_SYMBOL_GPL(housekeeping_enabled);
static bool housekeeping_dereference_check(enum hk_type type)
{
if (IS_ENABLED(CONFIG_LOCKDEP) && type == HK_TYPE_DOMAIN) {
/* Cpuset isn't even writable yet? */
if (system_state <= SYSTEM_SCHEDULING)
return true;
/* CPU hotplug write locked, so cpuset partition can't be overwritten */
if (IS_ENABLED(CONFIG_HOTPLUG_CPU) && lockdep_is_cpus_write_held())
return true;
/* Cpuset lock held, partitions not writable */
if (IS_ENABLED(CONFIG_CPUSETS) && lockdep_is_cpuset_held())
return true;
return false;
}
return true;
}
static inline struct cpumask *housekeeping_cpumask_dereference(enum hk_type type)
{
return rcu_dereference_all_check(housekeeping.cpumasks[type],
housekeeping_dereference_check(type));
}
const struct cpumask *housekeeping_cpumask(enum hk_type type)
{
const struct cpumask *mask = NULL;
if (static_branch_unlikely(&housekeeping_overridden)) {
if (READ_ONCE(housekeeping.flags) & BIT(type))
mask = housekeeping_cpumask_dereference(type);
}
if (!mask)
mask = cpu_possible_mask;
return mask;
}
EXPORT_SYMBOL_GPL(housekeeping_cpumask);
int housekeeping_any_cpu(enum hk_type type)
{
int cpu;
if (static_branch_unlikely(&housekeeping_overridden)) {
if (housekeeping.flags & BIT(type)) {
cpu = sched_numa_find_closest(housekeeping_cpumask(type), smp_processor_id());
if (cpu < nr_cpu_ids)
return cpu;
cpu = cpumask_any_and_distribute(housekeeping_cpumask(type), cpu_online_mask);
if (likely(cpu < nr_cpu_ids))
return cpu;
/*
* Unless we have another problem this can only happen
* at boot time before start_secondary() brings the 1st
* housekeeping CPU up.
*/
WARN_ON_ONCE(system_state == SYSTEM_RUNNING ||
type != HK_TYPE_TIMER);
}
}
return smp_processor_id();
}
EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
void housekeeping_affine(struct task_struct *t, enum hk_type type)
{
if (static_branch_unlikely(&housekeeping_overridden))
if (housekeeping.flags & BIT(type))
set_cpus_allowed_ptr(t, housekeeping_cpumask(type));
}
EXPORT_SYMBOL_GPL(housekeeping_affine);
bool housekeeping_test_cpu(int cpu, enum hk_type type)
{
Annotation
- Immediate include surface: `linux/sched/isolation.h`, `linux/pci.h`, `sched.h`.
- Detected declarations: `struct housekeeping`, `enum hk_flags`, `function housekeeping_enabled`, `function housekeeping_dereference_check`, `function housekeeping_any_cpu`, `function housekeeping_affine`, `function housekeeping_test_cpu`, `function housekeeping_update`, `function housekeeping_init`, `function kfree`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.