RFC Task watchers v2 Introduction
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest10 patches 10 repliesIn review
Changes in v1 from the cover letter
Added ability to cause fork to fail with NOTIFY_STOP_MASK Added WARN_ON() when watchers cause WATCH_TASK_FREE to stop early Moved fork invocation
Moved exec invocation
Added current as argument to exec invocation
Moved exit code assignment
Added id change invocations
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/10 | Task watchers v2 Task watchers v2fs/ include/ include/ +5 more | +114 | 0 replies | |
| 2/10 | Task watchers v2 Benchmarkkernel/ kernel/ lib/ | +116 | 5 replies | |
| 3/10 | Task watchers v2 Register audit task watcherinclude/ kernel/ kernel/ +1 more | +8 | 0 replies | |
| 4/10 | Task watchers v2 Register semundo task watcherinclude/ ipc/ kernel/ +1 more | +9 | 0 replies | |
| 5/10 | Task watchers v2 Register cpuset task watcherinclude/ kernel/ kernel/ +1 more | +6 | 3 replies | |
| 6/10 | Task watchers v2 Register NUMA mempolicy task watcherkernel/ kernel/ mm/ | +25 | 0 replies | |
| 7/10 | Task watchers v2 Register IRQ flag tracing task watcherkernel/ kernel/ | +24 | 0 replies | |
| 8/10 | Task watchers v2 Register lockdep task watcherkernel/ kernel/ | +9 | 0 replies | |
| 9/10 | Task watchers v2 Register process keyrings task watcherinclude/ kernel/ kernel/ +2 more | +13 | 0 replies | |
| 10/10 | Task watchers v2 Register process events connectordrivers/ fs/ include/ +3 more | +37 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC][PATCH 00/10] Task watchers v2 Introduction
This is version 2 of my Task Watchers patches.
Task watchers calls functions whenever a task forks, execs, changes its [re][ug]id, or exits.
Task watchers is primarily useful to existing kernel code as a means making the code in fork and exit more readable. Kernel code uses these paths by marking a function as a task watcher much like modules mark their init functions with module_init(). This reduces the code length and complexity of copy_process().
The first patch adds the basic infrastructure of task watchers: notification function calls in the various paths and a table of function pointers to be called. It uses an ELF section because parts of the table must be gathered from all over the kernel code and using the linker is easier than resolving and maintaining complex header interdependencies. An ELF table is also ideal because its read-only nature means that no locking nor list traversal are required.
Subsequent patches adapt existing parts of the kernel to use a task watcher
-- typically in the fork, clone, and exit paths:
audit
semundo
cpusets
mempolicy
trace irqflags
lockdep
keys (for processes -- not for thread groups)
process events connector
I'm working on three more patches that add support for creating a task watcher from within a module using an ELF section. I've not posted that work because it hasn't successfully booted much less completed the small selection of smoke tests I ran on these.
TODO:
Mark the task watcher table ELF section read-only. I've googled, read man pages, navigated the info pages, tried using PHDR, and according to the output of objdump, had no success. I'd really appreciate a pointer to an example showing what makes ld mark a kernel ELF section read-only.
Changes:
v2:
Dropped use of notifier chains
Dropped per-task watchers
Can be implemented on top of this
Still requires notifier chains
Dropped taskstats conversion
Parts of taskstats had to move away from the regions of copy_process() and do_exit() where task_watchers are notified
Used linker script mechanism suggested by Al Viro
Created one "list" of watchers per event as requested by Andrew Morton
No need to multiplex a single function call
Easier to static register/unregister watchers: 1 line of code val param now used for:
WATCH_TASK_INIT: clone_flags
WATCH_TASK_CLONE: clone_flags
WATCH_TASK_EXIT: exit code
WATCH_TASK_*: <unused>
Renamed notify_watchers() to notify_task_watchers()
Replaced: if (err != 0) --> if (err)
Added patches converting more "features" to use task watchers Added return code handling to WATCH_TASK_INIT
Return code handling elsewhere didn't seem appropriate since there was generally no response necessary
Fixed process keys free to handle failure in fork as originally coded
in copy_process
Added process keys code to watch for [er][ug]id changes
v1:
Added ability to cause fork to fail with NOTIFY_STOP_MASK Added WARN_ON() when watchers cause WATCH_TASK_FREE to stop early Moved fork invocation
Moved exec invocation
Added current as argument to exec invocation
Moved exit code assignment
Added id change invocations
v0:
Based on Jes Sorensen's Task Notifiers patches
Cheers,
-Matt Helsley
--
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV