Magic Sysrq Registration Patch

From: Crutcher Dunnavant (crutcher@redhat.com)
Date: Wed Oct 25 2000 - 09:48:53 EST


Hello,
This is my first kernel patch, and I will try to be careful about the ettiqute.
Sorry if I hork it up.

What:
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.

Why:
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://irc.openprojects.net/#kernelnewbies
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.

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

Where:
At the moment, the patch tar ball (containing the 3 patches, and an example
module) is available at:
http://bama.ua.edu/~dunna001/syrq-register-0.7.tar.bz2

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

-- 
"I may be a monkey,     Crutcher Dunnavant 
 but I'm a monkey       <crutcher@redhat.com>
 with ambition!"        Red Hat OS Development

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Oct 31 2000 - 21:00:15 EST