Monday, November 12, 2012

svn list logs between two tags

http://www.bernzilla.com/item.php?id=613

In short:

svn log -v --stop-on-copy file:///dev/svn/tags/MY_FIRST_TAG

(get r1)

svn log -v --stop-on-copy file:///dev/svn/tags/MY_SECOND_TAG
(get r2)


svn log -v -r42:79 file:///dev/svn/trunk
(r42 is r1, 79 is r2).

Friday, November 9, 2012

lock detection in Linux kernel

Lockdep:

http://lwn.net/Articles/321663/

http://lwn.net/Articles/185666/


Tuesday, August 14, 2012

Buddy info on Linux

cat /proc/buddyinfo

shows the number of free entries. The order increased from left to right.

E.g


cat /proc/buddyinfo
Node 0, zone      DMA      0      1      1      2      2      1      0      0   1      1      3
Node 0, zone    DMA32   6251   5987   1236    279     36      2     13      0   0      0      0
Node 0, zone   Normal    848     96      4      4      3      1      1      1   0      0      0
Node 1, zone   Normal   2578    920    335   1563   1890   2239    569    393   116    4      0
Node 2, zone   Normal   5691   4461   4559    712    516     63     38    535   330    99     26
Node 3, zone   Normal   1874   1092    384    140     48     21     15     11   0      0      0


Wednesday, April 18, 2012

搞定一个kobjects, sysfs相关的问题

最近在把一个功能从“新”的2.6.38内核BACK PORT到2.6.9上面。碰到了很多稀奇古怪的问题。比如有的函数,在EXPORT_SYMBOL之后,可以被其他函数调用,但是返回的指针的高32位会被自动清零(目标是 X86/64BIT SMP). 搞了半天,发现一定要在.H里面声明一下才行。

今天搞的SYSFS的一个问题。在我把新代码复制到老的内核上面之后,发现少了一部分SYSFS文件,但是其他几个又在的。于是看了半天SYSFS, KOBJECT. 总算搞清楚了一点。

KOBJECTS可以指定一个KTYPES,在KTYPES里面包括有SYSFS_OP 和DEFAULT_ATTRS。如果这些都设置好了,在KOBJECT_ADD的时候,就会自动在 SYSFS下面生成相应的 SYSFS 文件。另外一个方法是调用sysfs_create_file. 这样可以添加新的文件。

在新的内核里面,KTYPES是在 调用KOBJECT_INIT 或者类似函数的时候,就要传过去的。然后在函数内部设置好。老的内核还是要自己设置。

需要注意的是,设置 KTYPES 一定要在调用 KOBJECT_ADD(或者类似函数)之前。否则设了也没用。我今天就是调试了半天才发现这点。

另外比较奇怪的是,开始我把ktypes设置放到了后面,然后跑了下,发现多了几个sysfs文件。于是让我误以为ktypes已经设置好了。后来才发现根本没放对地方。不过为啥放在后面也会多出几个sysfs文件呢?这个就搞不清楚了。先回家去再说。

A quicker way to get vmlinuz

Sometimes, I just want a linux kernel (such as for debugging). "make" command can get it, but it waste a lot of time because it also compiles all the modules which I don't need.

So I did some google search and find out "make bzImage" is the right command to use. After that, the kernel file is in arch/x86/boot/bzImage. bzImage is the same as vmlinuz .

btw: all these vmlinuz, bzImage names are very confusing. :(

4.25.2012 update: just change vmlinux to vmlinuz. The former is uncompressed and with all the symbols; it normally used for debugging. The latter is actually used for boot.

Wednesday, April 4, 2012

vi/vim cheatsheet

http://www.worldtimzone.com/res/vi.html


back porting native_rdmsr_safe_regs

This function is used by new Linux kernels and I need to port it back to an old 2.6.9 kernel. The compiler complains that cannot find the reference to this function and its brother ( native_wrmsr_safe_regs).

Then I used vim/cscope to search symbols/text for native_wrmsr_safe_regs, but cannot find anything about it. Google it gave the same result. After some time, I used gitk to check the log of a related c file and found out these two functions are defined in an assembly file, by using macros.

Then I happily copied that assembly file (msr-reg.S) to the old kernel source. But this time I got some weird errors as "invalid character '(' in mnemonic". Then I google for this for some time and noticed that there is some definitions in "link/linkage.h". For example, ENTRY used in the msr-reg.S is defined there.

Finally I found out "ENDPROC" used in msr-reg.S is not in my version of linkage.h. After copy that definition, the compiler does not complain about these functions again.

Fixed a problem of cscope_maps.vim

The introduction for cscope_maps.vim is here: http://cscope.sourceforge.net/cscope_vim_tutorial.html

It is a good plugin for VIM, but I could not use it on my machine somehow. After google search and tried some method to debug the plugin, the problem still exists.

Finally, I noticed that when I launch vim, there is an error message complaining about the line 42 of cscope_maps.vim. Maybe that error prevents the plugin to be loaded. So I just go ahead, open the cscope_maps.vim and comment out the line 42 and some related lines, then the plugin works! I can use all the shortcut keys to search the source code now. :)

Saturday, March 31, 2012

Create a PDF With embedded fonts using Preview

On Mac OS X

http://hints.macworld.com/article.php?story=20060203175741232

Note: with above method, the fonts are embedded, but it will not pass IEEE conference paper pdf checks, because the pdf version is older than adobe 5.x. I tried many other methods but all of them cannot embedded all fonts due to some errors.

Finally, I use similar steps as the link to create a PS file instead a pdf file. Then convert this ps file with Adobe distiller on a Windows machine.

Friday, March 30, 2012

ctrl+s on Linux

http://raamdev.com/2007/recovering-from-ctrls-in-putty/

follow ctrl+s, press ctrl+q to recover when on a Linux console.

Per CPU data

http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/x536.html

http://lwn.net/Articles/22911/

LKD2
http://www.makelinux.net/books/lkd2/ch11lev1sec10 (and following pages)

Tuesday, February 21, 2012