Day70 - Notifier Chain¶
Objective¶
Learn the Linux kernel notifier chain framework and understand how kernel subsystems propagate events to multiple subscribers.
Topics covered:
- notifier_block
- callback registration
- callback unregistration
- priority ordering
- NOTIFY_STOP
- event payload delivery
- blocking notifier chain
- atomic notifier chain
Lab Environment¶
Platform:
Module:
Directory:
Lab1 - Basic Blocking Notifier¶
Goal¶
Create a blocking notifier chain and register multiple subscribers.
APIs¶
BLOCKING_NOTIFIER_HEAD()
blocking_notifier_chain_register()
blocking_notifier_chain_unregister()
blocking_notifier_call_chain()
Test Flow¶
Result¶
CLIENT-A event=1
CLIENT-B event=1
CLIENT-C event=1
CLIENT-A event=2
CLIENT-B event=2
CLIENT-C event=2
Verified:
- callback registration works
- callback execution works
- callback unregistration works
Lab2 - Priority Ordering¶
Goal¶
Verify notifier execution order.
Configuration¶
Test Flow¶
Result¶
Verified:
and not registration order.
Lab3 - NOTIFY_STOP¶
Goal¶
Verify propagation control.
Configuration¶
CLIENT-C returns:
Test Flow¶
Result¶
CLIENT-A was not executed.
Verified:
Lab4 - Event Payload¶
Goal¶
Pass event-specific data through the notifier chain.
Event Structure¶
Event Examples¶
START:
STOP:
Result¶
[CLIENT-B] id=1 value=100 msg=system start
[CLIENT-C] id=1 value=100 msg=system start
[CLIENT-A] id=1 value=100 msg=system start
Verified:
Lab5 - Blocking vs Atomic Notifier¶
Goal¶
Compare blocking and atomic notifier chains.
Chains¶
Blocking:
Atomic:
Registration APIs¶
Blocking:
Atomic:
Callback Observation¶
Result¶
for both chains when called from module_init().
Key Observation¶
Atomic notifier does not imply:
Instead:
Callback implementation must avoid:
when atomic execution is possible.
Lab6 - Dynamic Unregister¶
Goal¶
Verify runtime subscriber removal.
Initial Chain¶
Step 1¶
Unregister:
Result:
Step 2¶
Unregister:
Result:
Result¶
Verified:
Key Findings¶
Notifier Chain¶
Provides:
without tight coupling.
Priority¶
Execution order:
Event Payload¶
Event context is delivered through:
Propagation Control¶
Callbacks may stop propagation using:
Dynamic Registration¶
Subscribers may be:
at runtime.
Summary¶
This lab demonstrated the core functionality of the Linux kernel notifier chain framework.
Covered:
- callback registration
- callback unregistration
- priority ordering
- propagation control
- event payload delivery
- blocking notifier chains
- atomic notifier chains
The notifier framework is commonly used by kernel subsystems to broadcast events to multiple listeners while keeping publishers and subscribers loosely coupled.