Notifier Chain¶
Overview¶
Notifier Chain is the Linux kernel's generic event notification framework.
It provides a mechanism for one subsystem to broadcast events to multiple subscribers without creating direct dependencies between components.
The framework is widely used throughout the kernel whenever multiple modules need to react to the same event.
Common examples include:
- CPU frequency transitions
- System reboot and shutdown
- Power management events
- Network device state changes
- USB device attach and removal
Problem Statement¶
Consider a subsystem that needs to notify several independent components about an event.
Without a notifier chain:
The publisher must know every consumer.
This creates strong coupling and poor maintainability.
Using a notifier chain:
The publisher only interacts with the notifier chain.
Subscribers register independently.
This creates a loosely coupled event propagation model.
Core Idea¶
Notifier Chain implements:
The publisher broadcasts an event.
Every registered subscriber receives the notification.
Subscribers may:
- Process the event
- Ignore the event
- Stop event propagation
Event Flow¶
Typical execution flow:
Priority Ordering¶
Subscribers may define priorities.
Example:
Execution order:
Higher priority callbacks execute first.
Event Payload¶
Events may carry additional information.
Example:
Subscribers receive:
through the callback interface.
Propagation Control¶
Subscribers may stop further event propagation.
Example:
Subscribers after B are not executed.
Notifier Chain Variants¶
Linux provides several notifier implementations.
Blocking Notifier¶
Characteristics:
Common usage:
Atomic Notifier¶
Characteristics:
Common usage:
Raw Notifier¶
Characteristics:
Used when the caller manages synchronization explicitly.
Relationship to Other Synchronization Mechanisms¶
Wait Queue¶
Purpose:
Used when a task waits until a condition becomes true.
Completion¶
Purpose:
Used when one task waits for another task to finish an operation.
Workqueue¶
Purpose:
Used to move work into process context.
Notifier Chain¶
Purpose:
Used to broadcast events to multiple subscribers.
Design Comparison¶
| Mechanism | Primary Purpose |
|---|---|
| Wait Queue | Wait for condition |
| Completion | Wait for operation completion |
| Workqueue | Execute work later |
| Notifier Chain | Broadcast event |
Typical Kernel Usage¶
CPUFreq¶
Reboot Notifier¶
Power Management¶
Network Subsystem¶
USB Subsystem¶
Related Notes¶
- notifier-chain-framework.md
- wait-queue.md
- completion.md
- workqueue.md
Related Labs¶
- Day67 - Workqueue Fundamentals
- Day68 - Kernel Thread Fundamentals
- Day69 - Completion Synchronization
- Day70 - Notifier Chain
Related APIs¶
Structures¶
Registration¶
Event Propagation¶
Notifier Types¶
Summary¶
Notifier Chain is the Linux kernel's generic event broadcast framework.
It enables:
- One-to-many communication
- Dynamic subscriber management
- Priority-based callback execution
- Event payload delivery
- Loose coupling between subsystems
The framework is heavily used throughout the kernel and serves as a foundation for many subsystem event propagation mechanisms.