Notifier Chain Framework¶
Overview¶
Notifier Chain is a generic event notification framework used throughout the Linux kernel.
It allows one subsystem to broadcast events to multiple interested subscribers without creating direct dependencies between components.
The framework provides a loosely coupled mechanism for event propagation.
Why Notifier Chain Exists¶
Without a notifier chain:
The publisher must know every consumer.
This creates strong coupling between subsystems.
Using a notifier chain:
The publisher only knows the notifier chain.
Subscribers register themselves independently.
Core Components¶
notifier_block¶
A notifier callback is represented by:
Fields:
| Field | Description |
|---|---|
| notifier_call | Callback function |
| next | Next notifier in chain |
| priority | Execution priority |
Callback Prototype¶
Parameters:
| Parameter | Description |
|---|---|
| nb | Current notifier block |
| action | Event identifier |
| data | Event payload |
Event Propagation¶
Publisher:
Kernel internally:
Every registered subscriber receives the event.
Priority Ordering¶
Notifier callbacks are executed according to:
Example:
Execution order:
Priority determines ordering regardless of registration time.
Event Payload¶
Notifier chains support event-specific payloads.
Example:
Publisher:
Subscriber:
This allows callbacks to receive additional context about the event.
Propagation Control¶
Callback return values influence chain execution.
Common values:
NOTIFY_OK¶
Continue executing remaining callbacks.
NOTIFY_STOP¶
Stop further event propagation.
Example:
CLIENT-A is not executed.
Blocking Notifier¶
Definition:
Registration:
Event propagation:
Characteristics:
Suitable for:
Atomic Notifier¶
Definition:
Registration:
Event propagation:
Characteristics:
Typical callback restrictions:
Important Clarification¶
Atomic notifier does not guarantee execution inside interrupt context.
Instead:
Raw Notifier¶
Definition:
Characteristics:
Users must provide their own synchronization.
Examples:
Dynamic Registration¶
Subscribers may join or leave at runtime.
Register:
Unregister:
The notifier chain immediately reflects the changes.
Internal Structure¶
Conceptually:
The framework internally maintains a priority-ordered linked list.
Comparison with Other Synchronization Mechanisms¶
Wait Queue¶
Purpose:
Relationship:
Completion¶
Purpose:
Relationship:
Workqueue¶
Purpose:
Relationship:
Notifier Chain¶
Purpose:
Relationship:
Real Kernel Examples¶
Notifier chains are widely used throughout the kernel.
Examples:
CPUFreq¶
Reboot Notifier¶
Power Management¶
Network Subsystems¶
USB Subsystems¶
Summary¶
Notifier Chain is the Linux kernel's generic event broadcast framework.
Key features:
- Multiple subscribers
- Dynamic registration
- Priority ordering
- Event payload delivery
- Propagation control
- Blocking, Atomic, and Raw variants
It is one of the fundamental mechanisms used by kernel subsystems to propagate events while maintaining loose coupling between components.