Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Documentation/sysrq.txt: convert to ReST markup

- Fix document title;
- use a table for the valid commands;
- use quote blocks where needed;
- use monotonic fonts for config options and file names;
- adjust whitespaces and blank lines;
- add it to the user's book.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

+149 -117
+149 -117
Documentation/sysrq.txt
··· 1 1 Linux Magic System Request Key Hacks 2 + ==================================== 3 + 2 4 Documentation for sysrq.c 3 5 4 - * What is the magic SysRq key? 5 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 + What is the magic SysRq key? 7 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 + 6 9 It is a 'magical' key combo you can hit which the kernel will respond to 7 10 regardless of whatever else it is doing, unless it is completely locked up. 8 11 9 - * How do I enable the magic SysRq key? 10 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 + How do I enable the magic SysRq key? 13 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14 + 11 15 You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' when 12 16 configuring the kernel. When running a kernel with SysRq compiled in, 13 17 /proc/sys/kernel/sysrq controls the functions allowed to be invoked via 14 18 the SysRq key. The default value in this file is set by the 15 19 CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE config symbol, which itself defaults 16 20 to 1. Here is the list of possible values in /proc/sys/kernel/sysrq: 17 - 0 - disable sysrq completely 18 - 1 - enable all functions of sysrq 19 - >1 - bitmask of allowed sysrq functions (see below for detailed function 20 - description): 21 + 22 + - 0 - disable sysrq completely 23 + - 1 - enable all functions of sysrq 24 + - >1 - bitmask of allowed sysrq functions (see below for detailed function 25 + description):: 26 + 21 27 2 = 0x2 - enable control of console logging level 22 28 4 = 0x4 - enable control of keyboard (SAK, unraw) 23 29 8 = 0x8 - enable debugging dumps of processes etc. ··· 33 27 128 = 0x80 - allow reboot/poweroff 34 28 256 = 0x100 - allow nicing of all RT tasks 35 29 36 - You can set the value in the file by the following command: 30 + You can set the value in the file by the following command:: 31 + 37 32 echo "number" >/proc/sys/kernel/sysrq 38 33 39 34 The number may be written here either as decimal or as hexadecimal 40 35 with the 0x prefix. CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE must always be 41 36 written in hexadecimal. 42 37 43 - Note that the value of /proc/sys/kernel/sysrq influences only the invocation 44 - via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always 45 - allowed (by a user with admin privileges). 38 + Note that the value of ``/proc/sys/kernel/sysrq`` influences only the invocation 39 + via a keyboard. Invocation of any operation via ``/proc/sysrq-trigger`` is 40 + always allowed (by a user with admin privileges). 46 41 47 - * How do I use the magic SysRq key? 48 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 49 - On x86 - You press the key combo 'ALT-SysRq-<command key>'. Note - Some 42 + How do I use the magic SysRq key? 43 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 44 + 45 + On x86 - You press the key combo :kbd:`ALT-SysRq-<command key>`. 46 + 47 + .. note:: 48 + Some 50 49 keyboards may not have a key labeled 'SysRq'. The 'SysRq' key is 51 50 also known as the 'Print Screen' key. Also some keyboards cannot 52 51 handle so many keys being pressed at the same time, so you might 53 - have better luck with "press Alt", "press SysRq", "release SysRq", 54 - "press <command key>", release everything. 52 + have better luck with press :kbd:`Alt`, press :kbd:`SysRq`, 53 + release :kbd:`SysRq`, press :kbd:`<command key>`, release everything. 55 54 56 - On SPARC - You press 'ALT-STOP-<command key>', I believe. 55 + On SPARC - You press :kbd:`ALT-STOP-<command key>`, I believe. 57 56 58 - On the serial console (PC style standard serial ports only) - 59 - You send a BREAK, then within 5 seconds a command key. Sending 60 - BREAK twice is interpreted as a normal BREAK. 57 + On the serial console (PC style standard serial ports only) 58 + You send a ``BREAK``, then within 5 seconds a command key. Sending 59 + ``BREAK`` twice is interpreted as a normal BREAK. 61 60 62 - On PowerPC - Press 'ALT - Print Screen (or F13) - <command key>, 63 - Print Screen (or F13) - <command key> may suffice. 61 + On PowerPC 62 + Press :kbd:`ALT - Print Screen` (or :kbd:`F13`) - :kbd:`<command key>`, 63 + :kbd:`Print Screen` (or :kbd:`F13`) - :kbd:`<command key>` may suffice. 64 64 65 - On other - If you know of the key combos for other architectures, please 66 - let me know so I can add them to this section. 65 + On other 66 + If you know of the key combos for other architectures, please 67 + let me know so I can add them to this section. 67 68 68 - On all - write a character to /proc/sysrq-trigger. e.g.: 69 + On all 70 + write a character to /proc/sysrq-trigger. e.g.:: 69 71 70 72 echo t > /proc/sysrq-trigger 71 73 72 - * What are the 'command' keys? 73 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 74 - 'b' - Will immediately reboot the system without syncing or unmounting 75 - your disks. 74 + What are the 'command' keys? 75 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 76 76 77 - 'c' - Will perform a system crash by a NULL pointer dereference. 78 - A crashdump will be taken if configured. 77 + =========== =================================================================== 78 + Command Function 79 + =========== =================================================================== 80 + ``b`` Will immediately reboot the system without syncing or unmounting 81 + your disks. 79 82 80 - 'd' - Shows all locks that are held. 83 + ``c`` Will perform a system crash by a NULL pointer dereference. 84 + A crashdump will be taken if configured. 81 85 82 - 'e' - Send a SIGTERM to all processes, except for init. 86 + ``d`` Shows all locks that are held. 83 87 84 - 'f' - Will call the oom killer to kill a memory hog process, but do not 85 - panic if nothing can be killed. 88 + ``e`` Send a SIGTERM to all processes, except for init. 86 89 87 - 'g' - Used by kgdb (kernel debugger) 90 + ``f`` Will call the oom killer to kill a memory hog process, but do not 91 + panic if nothing can be killed. 88 92 89 - 'h' - Will display help (actually any other key than those listed 90 - here will display help. but 'h' is easy to remember :-) 93 + ``g`` Used by kgdb (kernel debugger) 91 94 92 - 'i' - Send a SIGKILL to all processes, except for init. 95 + ``h`` Will display help (actually any other key than those listed 96 + here will display help. but ``h`` is easy to remember :-) 93 97 94 - 'j' - Forcibly "Just thaw it" - filesystems frozen by the FIFREEZE ioctl. 98 + ``i`` Send a SIGKILL to all processes, except for init. 95 99 96 - 'k' - Secure Access Key (SAK) Kills all programs on the current virtual 97 - console. NOTE: See important comments below in SAK section. 100 + ``j`` Forcibly "Just thaw it" - filesystems frozen by the FIFREEZE ioctl. 98 101 99 - 'l' - Shows a stack backtrace for all active CPUs. 102 + ``k`` Secure Access Key (SAK) Kills all programs on the current virtual 103 + console. NOTE: See important comments below in SAK section. 100 104 101 - 'm' - Will dump current memory info to your console. 105 + ``l`` Shows a stack backtrace for all active CPUs. 102 106 103 - 'n' - Used to make RT tasks nice-able 107 + ``m`` Will dump current memory info to your console. 104 108 105 - 'o' - Will shut your system off (if configured and supported). 109 + ``n`` Used to make RT tasks nice-able 106 110 107 - 'p' - Will dump the current registers and flags to your console. 111 + ``o`` Will shut your system off (if configured and supported). 108 112 109 - 'q' - Will dump per CPU lists of all armed hrtimers (but NOT regular 110 - timer_list timers) and detailed information about all 111 - clockevent devices. 113 + ``p`` Will dump the current registers and flags to your console. 112 114 113 - 'r' - Turns off keyboard raw mode and sets it to XLATE. 115 + ``q`` Will dump per CPU lists of all armed hrtimers (but NOT regular 116 + timer_list timers) and detailed information about all 117 + clockevent devices. 114 118 115 - 's' - Will attempt to sync all mounted filesystems. 119 + ``r`` Turns off keyboard raw mode and sets it to XLATE. 116 120 117 - 't' - Will dump a list of current tasks and their information to your 118 - console. 121 + ``s`` Will attempt to sync all mounted filesystems. 119 122 120 - 'u' - Will attempt to remount all mounted filesystems read-only. 123 + ``t`` Will dump a list of current tasks and their information to your 124 + console. 121 125 122 - 'v' - Forcefully restores framebuffer console 123 - 'v' - Causes ETM buffer dump [ARM-specific] 126 + ``u`` Will attempt to remount all mounted filesystems read-only. 124 127 125 - 'w' - Dumps tasks that are in uninterruptable (blocked) state. 128 + ``v`` Forcefully restores framebuffer console 129 + ``v`` Causes ETM buffer dump [ARM-specific] 126 130 127 - 'x' - Used by xmon interface on ppc/powerpc platforms. 128 - Show global PMU Registers on sparc64. 129 - Dump all TLB entries on MIPS. 131 + ``w`` Dumps tasks that are in uninterruptable (blocked) state. 130 132 131 - 'y' - Show global CPU Registers [SPARC-64 specific] 133 + ``x`` Used by xmon interface on ppc/powerpc platforms. 134 + Show global PMU Registers on sparc64. 135 + Dump all TLB entries on MIPS. 132 136 133 - 'z' - Dump the ftrace buffer 137 + ``y`` Show global CPU Registers [SPARC-64 specific] 134 138 135 - '0'-'9' - Sets the console log level, controlling which kernel messages 136 - will be printed to your console. ('0', for example would make 137 - it so that only emergency messages like PANICs or OOPSes would 138 - make it to your console.) 139 + ``z`` Dump the ftrace buffer 139 140 140 - * Okay, so what can I use them for? 141 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 141 + ``0``-``9`` Sets the console log level, controlling which kernel messages 142 + will be printed to your console. (``0``, for example would make 143 + it so that only emergency messages like PANICs or OOPSes would 144 + make it to your console.) 145 + =========== =================================================================== 146 + 147 + Okay, so what can I use them for? 148 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 149 + 142 150 Well, unraw(r) is very handy when your X server or a svgalib program crashes. 143 151 144 152 sak(k) (Secure Access Key) is useful when you want to be sure there is no ··· 160 140 when you would try to login. It will kill all programs on given console, 161 141 thus letting you make sure that the login prompt you see is actually 162 142 the one from init, not some trojan program. 163 - IMPORTANT: In its true form it is not a true SAK like the one in a :IMPORTANT 164 - IMPORTANT: c2 compliant system, and it should not be mistaken as :IMPORTANT 165 - IMPORTANT: such. :IMPORTANT 166 - It seems others find it useful as (System Attention Key) which is 143 + 144 + .. important:: 145 + 146 + In its true form it is not a true SAK like the one in a 147 + c2 compliant system, and it should not be mistaken as 148 + such. 149 + 150 + It seems others find it useful as (System Attention Key) which is 167 151 useful when you want to exit a program that will not let you switch consoles. 168 152 (For example, X or a svgalib program.) 169 153 170 - reboot(b) is good when you're unable to shut down. But you should also 171 - sync(s) and umount(u) first. 154 + ``reboot(b)`` is good when you're unable to shut down. But you should also 155 + ``sync(s)`` and ``umount(u)`` first. 172 156 173 - crash(c) can be used to manually trigger a crashdump when the system is hung. 157 + ``crash(c)`` can be used to manually trigger a crashdump when the system is hung. 174 158 Note that this just triggers a crash if there is no dump mechanism available. 175 159 176 - sync(s) is great when your system is locked up, it allows you to sync your 160 + ``sync(s)`` is great when your system is locked up, it allows you to sync your 177 161 disks and will certainly lessen the chance of data loss and fscking. Note 178 162 that the sync hasn't taken place until you see the "OK" and "Done" appear 179 163 on the screen. (If the kernel is really in strife, you may not ever get the 180 164 OK or Done message...) 181 165 182 - umount(u) is basically useful in the same ways as sync(s). I generally sync(s), 183 - umount(u), then reboot(b) when my system locks. It's saved me many a fsck. 184 - Again, the unmount (remount read-only) hasn't taken place until you see the 185 - "OK" and "Done" message appear on the screen. 166 + ``umount(u)`` is basically useful in the same ways as ``sync(s)``. I generally 167 + ``sync(s)``, ``umount(u)``, then ``reboot(b)`` when my system locks. It's saved 168 + me many a fsck. Again, the unmount (remount read-only) hasn't taken place until 169 + you see the "OK" and "Done" message appear on the screen. 186 170 187 - The loglevels '0'-'9' are useful when your console is being flooded with 188 - kernel messages you do not want to see. Selecting '0' will prevent all but 171 + The loglevels ``0``-``9`` are useful when your console is being flooded with 172 + kernel messages you do not want to see. Selecting ``0`` will prevent all but 189 173 the most urgent kernel messages from reaching your console. (They will 190 174 still be logged if syslogd/klogd are alive, though.) 191 175 192 - term(e) and kill(i) are useful if you have some sort of runaway process you 193 - are unable to kill any other way, especially if it's spawning other 176 + ``term(e)`` and ``kill(i)`` are useful if you have some sort of runaway process 177 + you are unable to kill any other way, especially if it's spawning other 194 178 processes. 195 179 196 - "just thaw it(j)" is useful if your system becomes unresponsive due to a frozen 197 - (probably root) filesystem via the FIFREEZE ioctl. 180 + "just thaw ``it(j)``" is useful if your system becomes unresponsive due to a 181 + frozen (probably root) filesystem via the FIFREEZE ioctl. 198 182 199 - * Sometimes SysRq seems to get 'stuck' after using it, what can I do? 200 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 183 + Sometimes SysRq seems to get 'stuck' after using it, what can I do? 184 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 185 + 201 186 That happens to me, also. I've found that tapping shift, alt, and control 202 187 on both sides of the keyboard, and hitting an invalid sysrq sequence again 203 - will fix the problem. (i.e., something like alt-sysrq-z). Switching to another 204 - virtual console (ALT+Fn) and then back again should also help. 188 + will fix the problem. (i.e., something like :kbd:`alt-sysrq-z`). Switching to 189 + another virtual console (:kbd:`ALT+Fn`) and then back again should also help. 205 190 206 - * I hit SysRq, but nothing seems to happen, what's wrong? 207 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 191 + I hit SysRq, but nothing seems to happen, what's wrong? 192 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 193 + 208 194 There are some keyboards that produce a different keycode for SysRq than the 209 - pre-defined value of 99 (see KEY_SYSRQ in include/linux/input.h), or which 210 - don't have a SysRq key at all. In these cases, run 'showkey -s' to find an 211 - appropriate scancode sequence, and use 'setkeycodes <sequence> 99' to map 212 - this sequence to the usual SysRq code (e.g., 'setkeycodes e05b 99'). It's 195 + pre-defined value of 99 (see ``KEY_SYSRQ`` in ``include/linux/input.h``), or 196 + which don't have a SysRq key at all. In these cases, run ``showkey -s`` to find 197 + an appropriate scancode sequence, and use ``setkeycodes <sequence> 99`` to map 198 + this sequence to the usual SysRq code (e.g., ``setkeycodes e05b 99``). It's 213 199 probably best to put this command in a boot script. Oh, and by the way, you 214 - exit 'showkey' by not typing anything for ten seconds. 200 + exit ``showkey`` by not typing anything for ten seconds. 215 201 216 - * I want to add SysRQ key events to a module, how does it work? 217 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 202 + I want to add SysRQ key events to a module, how does it work? 203 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 204 + 218 205 In order to register a basic function with the table, you must first include 219 - the header 'include/linux/sysrq.h', this will define everything else you need. 220 - Next, you must create a sysrq_key_op struct, and populate it with A) the key 206 + the header ``include/linux/sysrq.h``, this will define everything else you need. 207 + Next, you must create a ``sysrq_key_op`` struct, and populate it with A) the key 221 208 handler function you will use, B) a help_msg string, that will print when SysRQ 222 209 prints help, and C) an action_msg string, that will print right before your 223 210 handler is called. Your handler must conform to the prototype in 'sysrq.h'. 224 211 225 - After the sysrq_key_op is created, you can call the kernel function 226 - register_sysrq_key(int key, struct sysrq_key_op *op_p); this will 227 - register the operation pointed to by 'op_p' at table key 'key', 212 + After the ``sysrq_key_op`` is created, you can call the kernel function 213 + ``register_sysrq_key(int key, struct sysrq_key_op *op_p);`` this will 214 + register the operation pointed to by ``op_p`` at table key 'key', 228 215 if that slot in the table is blank. At module unload time, you must call 229 - the function unregister_sysrq_key(int key, struct sysrq_key_op *op_p), which 216 + the function ``unregister_sysrq_key(int key, struct sysrq_key_op *op_p)``, which 230 217 will remove the key op pointed to by 'op_p' from the key 'key', if and only if 231 218 it is currently registered in that slot. This is in case the slot has been 232 219 overwritten since you registered it. ··· 241 214 The Magic SysRQ system works by registering key operations against a key op 242 215 lookup table, which is defined in 'drivers/tty/sysrq.c'. This key table has 243 216 a number of operations registered into it at compile time, but is mutable, 244 - and 2 functions are exported for interface to it: 217 + and 2 functions are exported for interface to it:: 218 + 245 219 register_sysrq_key and unregister_sysrq_key. 220 + 246 221 Of course, never ever leave an invalid pointer in the table. I.e., when 247 222 your module that called register_sysrq_key() exits, it must call 248 223 unregister_sysrq_key() to clean up the sysrq key table entry that it used. ··· 253 224 If for some reason you feel the need to call the handle_sysrq function from 254 225 within a function called by handle_sysrq, you must be aware that you are in 255 226 a lock (you are also in an interrupt handler, which means don't sleep!), so 256 - you must call __handle_sysrq_nolock instead. 227 + you must call ``__handle_sysrq_nolock`` instead. 257 228 258 - * When I hit a SysRq key combination only the header appears on the console? 259 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 229 + When I hit a SysRq key combination only the header appears on the console? 230 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 231 + 260 232 Sysrq output is subject to the same console loglevel control as all 261 233 other console output. This means that if the kernel was booted 'quiet' 262 234 as is common on distro kernels the output may not appear on the actual 263 235 console, even though it will appear in the dmesg buffer, and be accessible 264 - via the dmesg command and to the consumers of /proc/kmsg. As a specific 236 + via the dmesg command and to the consumers of ``/proc/kmsg``. As a specific 265 237 exception the header line from the sysrq command is passed to all console 266 238 consumers as if the current loglevel was maximum. If only the header 267 239 is emitted it is almost certain that the kernel loglevel is too low. 268 240 Should you require the output on the console channel then you will need 269 - to temporarily up the console loglevel using alt-sysrq-8 or: 241 + to temporarily up the console loglevel using :kbd:`alt-sysrq-8` or:: 270 242 271 243 echo 8 > /proc/sysrq-trigger 272 244 273 245 Remember to return the loglevel to normal after triggering the sysrq 274 246 command you are interested in. 275 247 276 - * I have more questions, who can I ask? 277 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 + I have more questions, who can I ask? 249 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 250 + 278 251 Just ask them on the linux-kernel mailing list: 279 252 linux-kernel@vger.kernel.org 280 253 281 - * Credits 282 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 254 + Credits 255 + ~~~~~~~ 256 + 283 257 Written by Mydraal <vulpyne@vulpyne.net> 284 258 Updated by Adam Sulmicki <adam@cfar.umd.edu> 285 259 Updated by Jeremy M. Dolan <jmd@turbogeek.org> 2001/01/28 10:15:59