[[!tag linux idea]]

I recently attended a talk where a kernel hacker told about debugging techniques when the Linux kernel is having problems. One of the things he mentioned was that kernel oops messages can sometimes be so long they won't fit on a screen. When users submit them, e.g. by photographing the screen, they don't show enough information to be useful.

It struck me that it might be possible to encode the message in various ways to make them use less space so they don't scroll off the screen. My first idea was a 2D bar graph, but those can be difficult in a text-only situation. A second idea is to use gzip and base64 encoding, and a refinement of that is to use base85 encoding.

This has probably been thought of before, but I thought it'd be fun to prototype it anyway. I used a free ascii85 library for Python:

#!/usr/bin/python

import zlib, bz2, base64, sys, tempfile, os, ascii85

msg = sys.stdin.read()
print "msg:", len(msg)
compressed = zlib.compress(msg, 9)
print "compressed:", len(compressed)
fd, compressed_name = tempfile.mkstemp()
os.write(fd, compressed)
os.close(fd)
compressed_f = file(compressed_name)
ascii85.encode(compressed_f, sys.stdout)

The output looks like this:

msg: 1634
compressed: 875
<~GhS.A>Ar7S'Z],0.1WSK(0_bV2p94FTa66f6^JQWJ.4:CK&Xc39T^5bfu^_\Tq&&u<XaD\6
lu::c_'C[5Mge#qt9CE#'^1ebXmM5]cY70)>\-TVY0RhHe#H5XE"-6f[R9^fc!k:qXQdpBILR
6-RZ.C_!]`gG]i0_,]6jbo(CuY*or^o"ci=l"*@htS%n/RF(:Jgj<5p6&:F5]&dboUE&elsfd
(Q>r9iZ[<<TZLdD7flXWfQDgJ!O=E[hn,#9sJ0_F*M9!*pLQ#:GL4bWjmeR!dh="[NORpL"BF
OgCfThPUJ>0e2C=Obgq4J@,HKB#6Wr!Z+@=_@(ucapa-?HiFl=c"6F,Qo2QK(X'kRhemB#?^r
pBRcu?kXCBo9UdEqEaUhnW/r!4.oagXhWh)9Y>RZ?M=[Db_+)Nb88)_KecZ61*?GU=10IDTNZ
@h3T<[tqqj4<[3j+[I6!?OXO0qBWQ0<YT-K+]1e.[N,Q?6$4F(pQ7kcUCJ69(R48PNhTQ6LQR
>;[?u=6M!-4PRrFlO$PJ_>td@h^!-H"HZk_>Z8a9\I:.%7"s6[U+.X)e]4M\-ARjM!0-D:>%0
eFfc3Fc1<$sYqHgbA#+hOK6k9X1*BWOX^I.!.@D^OAsXk<XOUm9]JB3hYYDPjok,F&KuVOYo5
jUn!'=jNq-Rp8b0dr+]li21>EeIRagC'/t^Y_UQY+,XX9/EmmP;VEaUW0^]7@VM:>=akU:$fB
@N%:0J2YqsmA!S\\"W@G`pph9sm23(,kcah7N#Oi3NDUm^]nM8!#ZV<8R#ljg^o/XkT9)5(r\
khNf<p3Dg0*6OunTq%DR]IEL_Yc1L7C%^bPTs@>Rr-QcRu_Kqr#bmu/*cGH<O?:W;@fbN1SiY
`R&"a>KcXOi6kW\+ee9JqMiUWW>UPW.UjWGIh/ipoFIX()/L'M$-9>>k4*gN[<-8@B2460k.l
p,KdJ7>F,O<%]=$A=5.lEMZ-bl[@Hmt&XFYRkrm]9bjOF2f6ZKNWKW[)b)c:,H4.6h+2CCuDa
T@DIM&oI6i'nj&5G9Lqf<F@4K@"0@kZh1P/>[:WP!J_E\T:#c;Y)"?g.\t#.Xt&'IYkT##I2]
T~>

Gzip seems to compress things to about half the original size, and ascii85 inflates that by about 25%. However, the result is then all mashed up on long lines, so use of vertical space if fairly small. Thus, this might be acceptable, perhaps as an optional feature.

Decoding that using OCR from a digital photograph should be possible, and is left as an excercise for the reader, as is an implementation of the encoder that is actually suitable for the kernel. (Read: not in Python.)

It might be possible to write a custom compressor: oops messages seem fairly regular in shape, after all.

There you are. If this is useful for anyone, at any time, please do use the idea.