Monday, April 30, 2012

AMD's Hammer Architecture - Making Sense of it All


Integrated Memory Controller & North Bridge



http://www.anandtech.com/show/838/6

Wednesday, April 25, 2012

Notifier chain update: API changes

http://lwn.net/Articles/171560/

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