Skip to content

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:

Publisher
 ├─ Subscriber A
 ├─ Subscriber B
 ├─ Subscriber C
 └─ Subscriber D

The publisher must know every consumer.

This creates strong coupling and poor maintainability.


Using a notifier chain:

Publisher
Notifier Chain
 ┌──┼──┬──┐
 ▼  ▼  ▼  ▼
A  B  C  D

The publisher only interacts with the notifier chain.

Subscribers register independently.

This creates a loosely coupled event propagation model.


Core Idea

Notifier Chain implements:

One Publisher
Multiple Subscribers

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:

Register Subscriber
Publish Event
Notifier Chain
Callback Execution

Priority Ordering

Subscribers may define priorities.

Example:

Priority 100
Priority 50
Priority 0

Execution order:

100
50
0

Higher priority callbacks execute first.


Event Payload

Events may carry additional information.

Example:

Action
+
Event Data

Subscribers receive:

What happened
+
Associated context

through the callback interface.


Propagation Control

Subscribers may stop further event propagation.

Example:

Subscriber A
Subscriber B
STOP

Subscribers after B are not executed.


Notifier Chain Variants

Linux provides several notifier implementations.

Blocking Notifier

Characteristics:

Sleep Allowed
Process Context

Common usage:

CPUFreq
Power Management
Reboot Events

Atomic Notifier

Characteristics:

Sleep Not Allowed
Atomic-safe Callback Required

Common usage:

Interrupt-related events
Low-latency notifications

Raw Notifier

Characteristics:

No Internal Synchronization

Used when the caller manages synchronization explicitly.


Relationship to Other Synchronization Mechanisms

Wait Queue

Purpose:

Condition-based waiting

Used when a task waits until a condition becomes true.


Completion

Purpose:

Operation completion synchronization

Used when one task waits for another task to finish an operation.


Workqueue

Purpose:

Deferred execution

Used to move work into process context.


Notifier Chain

Purpose:

Event propagation

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

Frequency change notification

Reboot Notifier

System reboot notification

Power Management

Suspend and resume notification

Network Subsystem

Network device state changes

USB Subsystem

Device insertion and removal

  • notifier-chain-framework.md
  • wait-queue.md
  • completion.md
  • workqueue.md

  • Day67 - Workqueue Fundamentals
  • Day68 - Kernel Thread Fundamentals
  • Day69 - Completion Synchronization
  • Day70 - Notifier Chain

Structures

struct notifier_block

Registration

blocking_notifier_chain_register()
blocking_notifier_chain_unregister()

Event Propagation

blocking_notifier_call_chain()

Notifier Types

BLOCKING_NOTIFIER_HEAD()
ATOMIC_NOTIFIER_HEAD()
RAW_NOTIFIER_HEAD()

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.