[lkml]   [2000]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectMagic Sysrq Registration Patch
This is my first kernel patch, and I will try to be careful about the ettiqute.
Sorry if I hork it up.

A rework of the magic sysrq code to use a registration system for key events
in the ranges '0-9', 'a-z'; keeping all existing sysrq actions as new,
registered actions, and exporting the registration interface to modules,
allowing modules to easily register magic sysrq events.

Patches currently apply to the 2.2.16, 2.2.17, and 2.4.0-pre9 trees.

In the course of learning the various systems pertinent to character devices,
and learning about memory paging, I found myself in a situation where my
experimental module would sometimes lock my system up, but I would know why it
had happened, and what state the machine was in. It would have been easy for
me to write a 'uncrash' funtion at this point, but I had no way to call it.

Talking this over with residents of the:
irc channel, someone suggested that I hack a call into the magic sysrq system.
I didn't want to put in a horked up call in the kernel, just to debug a module,
and upon talks with saner heads, and close examination of the sysrq code,
decided that the only appropriate approach would be to rework the sysrq code
to not only allow registration, but to be based upon it.

This would allow kernel and module developers, when in need, to simply register
a sysrq key event against the kernel at run time, and would provide an easier
module development path on production kernels, without the need to use kdb.

The registration system is based upon a table of pointers to a struct of type
'sysrq_key_op', which contains a pointer to the appropriate handler, as well
as pointers to the help message string, and the action string. This table is
protected by a spinlock, and handle_sysrq calls are locking, as are calls to
the register/unregister function.

At event time, the main handler disects the keycode given it, calculates its
index into the array (if it applies) and prints the action message, and
launches the appropriate handeler, if there is a key op registered at that
point; otherwise, it prints the help message.

In addition, the power off funciton has been completely removed, replaced
by a handler and registration call in arch/i386/kernel/apm.c

At the moment, the patch tar ball (containing the 3 patches, and an example
module) is available at:

I really think that this is a useful change, I think it provides needed
functionality, does not break existing functionality, and has a more robust
structure than the existing system.

Please consider this patch
"I may be a monkey, Crutcher Dunnavant
but I'm a monkey <>
with ambition!" Red Hat OS Development

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:41    [W:0.034 / U:6.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site