include/linux/workqueue.h

Source file repositories/reference/linux-study-clean/include/linux/workqueue.h

File Facts

System
Linux kernel
Corpus path
include/linux/workqueue.h
Extension
.h
Size
32027 bytes
Lines
914
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct delayed_work {
	struct work_struct work;
	struct timer_list timer;

	/* target workqueue and CPU ->timer uses to queue ->work */
	struct workqueue_struct *wq;
	int cpu;
};

struct rcu_work {
	struct work_struct work;
	struct rcu_head rcu;

	/* target workqueue ->rcu uses to queue ->work */
	struct workqueue_struct *wq;
};

enum wq_affn_scope {
	WQ_AFFN_DFL,			/* use system default */
	WQ_AFFN_CPU,			/* one pod per CPU */
	WQ_AFFN_SMT,			/* one pod per SMT */
	WQ_AFFN_CACHE,			/* one pod per LLC */
	WQ_AFFN_CACHE_SHARD,		/* synthetic sub-LLC shards */
	WQ_AFFN_NUMA,			/* one pod per NUMA node */
	WQ_AFFN_SYSTEM,			/* one pod across the whole system */

	WQ_AFFN_NR_TYPES,
};

/**
 * struct workqueue_attrs - A struct for workqueue attributes.
 *
 * This can be used to change attributes of an unbound workqueue.
 */
struct workqueue_attrs {
	/**
	 * @nice: nice level
	 */
	int nice;

	/**
	 * @cpumask: allowed CPUs
	 *
	 * Work items in this workqueue are affine to these CPUs and not allowed
	 * to execute on other CPUs. A pool serving a workqueue must have the
	 * same @cpumask.
	 */
	cpumask_var_t cpumask;

	/**
	 * @__pod_cpumask: internal attribute used to create per-pod pools
	 *
	 * Internal use only.
	 *
	 * Per-pod unbound worker pools are used to improve locality. Always a
	 * subset of ->cpumask. A workqueue can be associated with multiple
	 * worker pools with disjoint @__pod_cpumask's. Whether the enforcement
	 * of a pool's @__pod_cpumask is strict depends on @affn_strict.
	 */
	cpumask_var_t __pod_cpumask;

	/**
	 * @affn_strict: affinity scope is strict
	 *
	 * If clear, workqueue will make a best-effort attempt at starting the
	 * worker inside @__pod_cpumask but the scheduler is free to migrate it
	 * outside.
	 *
	 * If set, workers are only allowed to run inside @__pod_cpumask.
	 */
	bool affn_strict;

	/*
	 * Below fields aren't properties of a worker_pool. They only modify how
	 * :c:func:`apply_workqueue_attrs` select pools and thus don't
	 * participate in pool hash calculations or equality comparisons.
	 *
	 * If @affn_strict is set, @cpumask isn't a property of a worker_pool
	 * either.
	 */

	/**
	 * @affn_scope: unbound CPU affinity scope
	 *
	 * CPU pods are used to improve execution locality of unbound work
	 * items. There are multiple pod types, one for each wq_affn_scope, and
	 * every CPU in the system belongs to one pod in every pod type. CPUs
	 * that belong to the same pod share the worker pool. For example,
	 * selecting %WQ_AFFN_NUMA makes the workqueue use a separate worker
	 * pool for each NUMA node.

Annotation

Implementation Notes