public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matt Helsley <matthltc@us.ibm.com>
To: Linux-Kernel <linux-kernel@vger.kernel.org>
Cc: Jes Sorensen <jes@sgi.com>,
	LSE-Tech <lse-tech@lists.sourceforge.net>,
	Chandra S Seetharaman <sekharan@us.ibm.com>,
	John T Kohl <jtk@us.ibm.com>, Christoph Hellwig <hch@lst.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Steve Grubb <sgrubb@redhat.com>,
	linux-audit@redhat.com, Paul Jackson <pj@sgi.com>
Subject: [RFC][PATCH 00/10] Task watchers v2 Introduction
Date: Thu, 28 Sep 2006 19:02:32 -0700	[thread overview]
Message-ID: <20060929020232.756637000@us.ibm.com> (raw)

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
--

             reply	other threads:[~2006-09-29  2:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-29  2:02 Matt Helsley [this message]
2006-09-29  2:02 ` [RFC][PATCH 01/10] Task watchers v2 Task watchers v2 Matt Helsley
2006-09-29  2:02 ` [RFC][PATCH 02/10] Task watchers v2 Benchmark Matt Helsley
2006-09-29  2:32   ` [Lse-tech] " Paul Jackson
2006-09-29 19:38     ` Matt Helsley
2006-09-29 20:13       ` Paul Jackson
2006-09-30  0:01         ` Matt Helsley
2006-09-30  0:04           ` Paul Jackson
2006-09-29  2:02 ` [RFC][PATCH 03/10] Task watchers v2 Register audit task watcher Matt Helsley
2006-09-29  2:02 ` [RFC][PATCH 04/10] Task watchers v2 Register semundo " Matt Helsley
2006-09-29  2:02 ` [RFC][PATCH 05/10] Task watchers v2 Register cpuset " Matt Helsley
2006-09-29  2:31   ` Paul Jackson
2006-09-29  7:52     ` [Lse-tech] " Matt Helsley
2006-09-29  8:03       ` Paul Jackson
2006-09-29  2:02 ` [RFC][PATCH 06/10] Task watchers v2 Register NUMA mempolicy " Matt Helsley
2006-09-29  2:02 ` [RFC][PATCH 07/10] Task watchers v2 Register IRQ flag tracing " Matt Helsley
2006-09-29  2:02 ` [RFC][PATCH 08/10] Task watchers v2 Register lockdep " Matt Helsley
2006-09-29  2:02 ` [RFC][PATCH 09/10] Task watchers v2 Register process keyrings " Matt Helsley
2006-09-29  2:02 ` [RFC][PATCH 10/10] Task watchers v2 Register process events connector Matt Helsley
2006-09-29  2:41 ` [RFC][PATCH 00/10] Task watchers v2 Introduction Paul Jackson
2006-09-29  8:16   ` [RFC][PATCH] Task watchers and modules (WAS Re: [RFC][PATCH 00/10] Task watchers v2 Introduction) Matt Helsley
2006-09-29 16:22   ` [RFC][PATCH 00/10] Task watchers v2 Introduction Paul Menage

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060929020232.756637000@us.ibm.com \
    --to=matthltc@us.ibm.com \
    --cc=hch@lst.de \
    --cc=jes@sgi.com \
    --cc=jtk@us.ibm.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lse-tech@lists.sourceforge.net \
    --cc=pj@sgi.com \
    --cc=sekharan@us.ibm.com \
    --cc=sgrubb@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox