2014/10/08(水)procfsの辿り方

kernel coding:

http://www.linuxplanet.org/blogs/?cat=4558
http://tuxthink.blogspot.jp/2013/10/creating-read-write-proc-entry-in.html

proc_create("name", 0, NULL, &proc_fops);

Ex. fs/proc/cmdline.c
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>

static int cmdline_proc_show(struct seq_file *m, void *v)
{
        seq_printf(m, "%s\n", saved_command_line);
        return 0;
}

static int cmdline_proc_open(struct inode *inode, struct file *file)
{
        return single_open(file, cmdline_proc_show, NULL);
}

static const struct file_operations cmdline_proc_fops = {
        .open           = cmdline_proc_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
        .release        = single_release,
};

static int __init proc_cmdline_init(void)
{
        proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
        return 0;
}
module_init(proc_cmdline_init);
非常に判りよい例.. ;)

linux kernel debug(小技)

2014/07/25linux::debugimport

kernel debug

driver毎のデバッグ出力

pr_debug()は"DEBUG"が定義されているときしか出力されない。
全域で表示させると、UBIなどの大量に吐き出してしまうモノがいるので厄介。
ファイルごとであれば、includeまえに
#define DEBUG (1)
とか、宣言を追加しても良いし、Makefileを編集しても良い。

ブロック単位?であれば、"FILE: driver/of/Makefile"に以下の一行を追加する。
ccflags-y := -DDEBUG
Flattened device tree関連のデバッグ出力が付与されて気持ちよく動作が見える。

参考資料

Documentation/kbuild/makefiles.txt
*1

*1 : このへんとか.. http://lxr.free-electrons.com/source/Documentation/kbuild/makefiles.txt

2013/04/19(金)2013-04-19

memory leakの調査がしたい.

http://blog.thewebsitepeople.org/2011/03/linux-memory-leak-detection/
http://elinux.org/Runtime_Memory_Measurement

proc配下の情報

https://www.kernel.org/doc/Documentation/filesystems/proc.txt

kernel versionやarchitectureによって、有効無効があるみたい。
互換性は維持するようにはしているようだけれど、
確実なのは使用しているkernel sourceを読むこと。