内核线程的park和unpark 2016-12-31

来自本人的旧博客: http://blog.163.com/awaken_ing/blog/static/120613197201511307274526

上图为smpbootregisterpercputhread(), kthreadcreateoncpu(), kthreadcreateon_node(), kthreadd()和kthread()之间的关系.

上图为cpu hotplug对内核线程的操作, 以smpbootthreadfn()为例.

内核启动时, smpbootregisterpercputhread()创建,绑定并启动primary cpu的内核线程, 并挂到链表hotplugthreads上.

linux-3.10.86/kernel/smpboot.c

smpboot_register_percpu_thread
{
    __smpboot_create_thread(plug_thread, cpu);
    smpboot_unpark_thread(plug_thread, cpu);
    list_add(&plug_thread->list, &hotplug_threads);
}

flush_dcache_page 2016-12-31

1. flushdcachepage的实现

问题:flushdcachepage()到底是 invalid, 还是 clean and invalid, 还是仅清掉dirty bit

linux-3.10.86/arch/arm/mm/flush.c

flush_dcache_page -> __flush_dcache_page
{
    /*
     * Writeback ...
    */

}

是Writeback, 所以, 可以理解为 clean and invalid, 尽管实现上可能采用lazy什么的.

2. 读写中的使用

linux-3.10.86/mm/filemap.c

address_space和buffer_head的一些field 2016-12-30

1. 问题引入

这里从一个地址空间 到另一个地址空间, 是为啥?

generic_file_fsync
{
    struct inode *inode = file->f_mapping->host;
    ret = sync_mapping_buffers(inode->i_mapping);

}

sync_mapping_buffers(struct address_space *mapping)
{
    struct address_space *buffer_mapping = mapping->private_data;

}

2. 解

linux-3.10.86/include/linux/fs.h

ext2 disk layout 2016-12-30

主要为了验证对ext2的 Disk Organization的理解, 诸如Block Group Descriptor, Inode Table之类.
给定一个ext2镜像, 遍历其所有文件, 并显示文件内容.
假定该镜像的文件大小都比较小, 不需要indirect pointer.

读写函数中的lock_page 2016-12-30

do_generic_file_read和generic_perform_write中对锁的处理.
从磁盘读到RAM中的过程中, page需要处于lock状态.
把用户的数据拷贝到page cahe, 该过程也要处理好lock page问题.