140주차 (2016.04.16) vfs_caches_init()


#1
KernelStudy : 140 주차
일시 : 2016.04.16 (140주차 스터디 진행)
모임명 : KernelStudy_ARM
장소 : 토즈 서현점
장소지원 : 공개 소프트웨어 개발자 커뮤니티 지원 프로그램
참여인원 : 3명

============

140주차 진도

  • 140차 시작 위치
  • start_kernel 1 ~/init/main.c
  • vfs_caches_init 925 ~/init/main.c
  • mnt_init 3809 ~/fs/dcache.c
  • init_mount_tree 5046 ~/fs/namespace.c
  • get_fs_type 3994 ~/fs/namespace.c
  • request_module 442 ~/fs/filesystems.c
  • __request_module 42 ~/include/linux/kmod.h
  • call_modprobe 295 ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
  • call_usermodehelper_exec 164 return call_usermodehelper_exec(info, wait | UMH_KILLABLE);
  • 139주차 함수 호출 구조
  • 주석이 잘못 된부분을 발견해서 sysfs_init()를 수정.
  • calll: start_kernel()-> vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create(): mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
  • call: get_fs_type()
  • strchr(): rootfs
  • strlen(): rootfs: 6 call_modprobe() - __get_fs_type()
  • request_module(): fs-rootfs
  • call: request_moudule(): __request_moudule()

  • call: __request_moudule()

  • ATOMIC_INIT()
  • WARN_ON_ONCE(): current_is_async()
  • va_start()
  • vsnprintf()
  • va_end()
  • security_kernel_module_request(): fs-rootfs
  • min(): max_threads/2, MAX_KMOD_CONCURRENT
  • atomic_inc(): kmod_concurrent
  • atomic_read(): kmod_concurrent
  • trace_module_request()
  • call_modprobe(): fs-rootfs
  • call: call_modprobe()
  • kmalloc(): kmem_cache#30-oX
  • kstrdup(): fs-rootfs
  • call_usermodehelper_setup()
  • call_usermodehelper_exec()
  • call: call_usermodehelper_exec()
  • DECLARE_COMPLETION_ONSTACK()

main.c::start_kernel()

  • call: start_kernel()->vfs_caches_init()
asmlinkage void __init start_kernel(void)
{
	char * command_line;
	extern const struct kernel_param __start___param[], __stop___param[];
	// ATAG,DTB 정보로 사용

...

    proc_caches_init();
	// sighand_struct, signal_struct, files_struct, fs_struct, mm_struct, vm_area_struct, nsproxy
	// 를 사용하기 위한 kmem_cache 할당자 및 percpu list 초기화 수행

	buffer_init();
	// buffer_head 를 사용하기 위한 kmem_cache 할당자 및 max_buffer_heads 값 초기화 수행

	key_init(); // null funtion
	security_init(); // null funtion
	dbg_late_init(); // null funtion

	// totalram_pages: 총 free된 page 수
	vfs_caches_init(totalram_pages);

dcache.c::vfs_caches_init()

  • call: start_kernel()
  • vfs_caches_init()
// ARM10C 20151003
// totalram_pages: 총 free된 page 수
void __init vfs_caches_init(unsigned long mempages)
{
	unsigned long reserve;

	/* Base hash sizes on available memory, with a reserve equal to
           150% of current kernel size */

	// NOTE:
	// mempages 값과 nr_free_pages() 의 값을 정확히 알 수 없음
	// 계산된 reserve의 값을 XXX 로 함

	// mempages: 총 free된 page 수, nr_free_pages(): 현재의 free pages 수
	reserve = min((mempages - nr_free_pages()) * 3/2, mempages - 1);
	// reserve: XXX

	// mempages: 총 free된 page 수, reserve: XXX
	mempages -= reserve;
	// mempages: 총 free된 page 수 - XXX

	// PATH_MAX: 4096
	// SLAB_HWCACHE_ALIGN: 0x00002000UL, SLAB_PANIC: 0x00040000UL
	// kmem_cache_create("names_cache", 4096, 0, 0x42000, NULL): kmem_cache#6
	names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
			SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
	// names_cachep: kmem_cache#6

	dcache_init();

	inode_init();

	// mempages: 총 free된 page 수 - XXX
	files_init(mempages);

	mnt_init();

namespace.c::mnt_init()

  • call: start_kernel()

    • vfs_caches_init()
  • call: vfs_caches_init()

    • kmem_cache_create(): names_cache
    • dcache_init()
    • inode_init()
    • files_init()
    • mnt_init()
// ARM10C 20151024
void __init mnt_init(void)
{
	unsigned u;
	int err;
	// sizeof(struct mount): 152 bytes, SLAB_HWCACHE_ALIGN: 0x00002000UL, SLAB_PANIC: 0x00040000UL
	// kmem_cache_create("mnt_cache", 152, 0, 0x42000, NULL): kmem_cache#2
	mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),
			0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
	// mnt_cache: kmem_cache#2

	// sizeof(struct hlist_head): 4 bytes, mhash_entries: 0
	// alloc_large_system_hash("Mount-cache", 4, 0, 19, 0, &m_hash_shift, &m_hash_mask, 0, 0): 16kB만큼 할당받은 메모리 주소
	mount_hashtable = alloc_large_system_hash("Mount-cache",
				sizeof(struct hlist_head),
				mhash_entries, 19,
				0,
				&m_hash_shift, &m_hash_mask, 0, 0);
	// mount_hashtable: 16kB만큼 할당받은 메모리 주소

	// sizeof(struct hlist_head): 4 bytes, mphash_entries: 0
	// alloc_large_system_hash("Mountpoint-cache", 4, 0, 19, 0, &m_hash_shift, &m_hash_mask, 0, 0): 16kB만큼 할당받은 메모리 주소
	mountpoint_hashtable = alloc_large_system_hash("Mountpoint-cache",
				sizeof(struct hlist_head),
				mphash_entries, 19,
				0,
				&mp_hash_shift, &mp_hash_mask, 0, 0);
	// mountpoint_hashtable: 16kB만큼 할당받은 메모리 주소

	// mount_hashtable: 16kB만큼 할당받은 메모리 주소, mountpoint_hashtable: 16kB만큼 할당받은 메모리 주소
	if (!mount_hashtable || !mountpoint_hashtable)
		panic("Failed to allocate mount hash table\n");

	// m_hash_mask: 0xFFF
	for (u = 0; u <= m_hash_mask; u++)
		// u: 0
		INIT_HLIST_HEAD(&mount_hashtable[u]);

		// INIT_HLIST_HEAD 에서 한일:
		// ((&mount_hashtable[0])->first = NULL)

		// u: 1...4095 까지 loop 수행

	// mp_hash_mask: 0xFFF
	for (u = 0; u <= mp_hash_mask; u++)
		// u: 0
		INIT_HLIST_HEAD(&mountpoint_hashtable[u]);

		// INIT_HLIST_HEAD 에서 한일:
		// ((&mountpoint_hashtable[0])->first = NULL)

		// u: 1...4095 까지 loop 수행

	// sysfs_init(): 0
	err = sysfs_init();
	// err: 0

	// err: 0
	if (err)
		printk(KERN_WARNING "%s: sysfs_init error: %d\n",
			__func__, err);

	// kobject_create_and_add("fs", NULL): kmem_cache#30-oX (struct kobject)
	fs_kobj = kobject_create_and_add("fs", NULL);
	// fs_kobj: kmem_cache#30-oX (struct kobject)

	// fs_kobj: kmem_cache#30-oX (struct kobject)
	if (!fs_kobj)
		printk(KERN_WARNING "%s: kobj create error\n", __func__);

	init_rootfs();

    init_mount_tree();

namespace.c::init_mount_tree()

  • call: start_kernel()
  • vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create()
    • alloc_large_system_hash() : mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
// ARM10C 20160326
static void __init init_mount_tree(void)
{
	struct vfsmount *mnt;
	struct mnt_namespace *ns;
	struct path root;
	struct file_system_type *type;

	type = get_fs_type("rootfs");

filesystems.cc::get_fs_type()

  • call: start_kernel()
  • vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create()
    • alloc_large_system_hash() : mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
// ARM10C 20160326
static void __init init_mount_tree(void)
{
	struct vfsmount *mnt;
	struct mnt_namespace *ns;
	struct path root;
	struct file_system_type *type;

	type = get_fs_type("rootfs");

filesystems.c::get_fs_type()

  • call: start_kernel()
  • vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create()
    • alloc_large_system_hash() : mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
// ARM10C 20160326
// "rootfs"
struct file_system_type *get_fs_type(const char *name)
{
	struct file_system_type *fs;

	// name: "rootfs", strchr("rootfs". '.'): NULL
	const char *dot = strchr(name, '.');
	// dot: NULL

	// dot: NULL, name: "rootfs", strlen("rootfs"): 6
	int len = dot ? dot - name : strlen(name);
	// len: 6

	// name: "rootfs", len: 6, __get_fs_type("rootfs", 6): NULL
	fs = __get_fs_type(name, len);
	// fs: NULL

	// __get_fs_type 에서 한일:
	// fs: NULL

	// fs: NULL, len: 6, name: "rootfs"
	if (!fs && (request_module("fs-%.*s", len, name) == 0))

kmod.h::request_module()

  • calll: start_kernel()-> vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create(): mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
  • call: get_fs_type()
  • strchr(): rootfs
  • strlen(): rootfs: 6 call_modprobe() - __get_fs_type()
  • request_module(): fs-rootfs
  • call: request_moudule(): __request_moudule()
// ARM10C 20160402
// "fs-%.*s", len: 6, name: "rootfs"
#define request_module(mod...) __request_module(true, mod)

kmod.c::__request_module()

  • calll: start_kernel()-> vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create(): mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
  • call: get_fs_type()
  • strchr(): rootfs
  • strlen(): rootfs: 6 call_modprobe() - __get_fs_type()
  • request_module(): fs-rootfs
  • call: request_moudule(): __request_moudule()
// ARM10C 20160402
// true, "fs-%.*s", len: 6, name: "rootfs"
int __request_module(bool wait, const char *fmt, ...)
{
	va_list args;

	// MODULE_NAME_LEN: 60
	char module_name[MODULE_NAME_LEN];
	unsigned int max_modprobes;
	int ret;

	// ATOMIC_INIT(0): { (0) }
	static atomic_t kmod_concurrent = ATOMIC_INIT(0);
	// kmod_concurrent.counter: 0

// ARM10C 20160402
// MAX_KMOD_CONCURRENT: 50
#define MAX_KMOD_CONCURRENT 50	/* Completely arbitrary value - KAO */
	static int kmod_loop_msg;

	/*
	 * We don't allow synchronous module loading from async.  Module
	 * init may invoke async_synchronize_full() which will end up
	 * waiting for this task which already is waiting for the module
	 * loading to complete, leading to a deadlock.
	 */
	// wait: true, current_is_async(): NULL
	WARN_ON_ONCE(wait && current_is_async());

	// modprobe_path[0]: '/'
	if (!modprobe_path[0])
		return 0;

	// fmt: "fs-%.*s",
	va_start(args, fmt);

	// va_start에서 한일:
	// args: (((char *) &("fs-%.*s")) + 4)

	// MODULE_NAME_LEN: 60, fmt: "fs-%.*s", args: (((char *) &("fs-%.*s")) + 4)
	// vsnprintf(module_name, 60, "fs-%.*s", (((char *) &("fs-%.*s")) + 4)): 9
	ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
	// ret: 9

	// vsnprintf 에서 한일:
	// module_name: "fs-rootfs"

	// args: (((char *) &("fs-%.*s")) + 4)
	va_end(args);

	// va_end에서 한일:
	// args: NULL

	// ret: 9, MODULE_NAME_LEN: 60
	if (ret >= MODULE_NAME_LEN)
		return -ENAMETOOLONG;

	// module_name: "fs-rootfs"
	// security_kernel_module_request("fs-rootfs"): 0
	ret = security_kernel_module_request(module_name); // null function
	// ret: 0

	// ret: 0
	if (ret)
		return ret;

	/* If modprobe needs a service that is in a module, we get a recursive
	 * loop.  Limit the number of running kmod threads to max_threads/2 or
	 * MAX_KMOD_CONCURRENT, whichever is the smaller.  A cleaner method
	 * would be to run the parents of this process, counting how many times
	 * kmod was invoked.  That would mean accessing the internals of the
	 * process tables to get the command line, proc_pid_cmdline is static
	 * and it is not worth changing the proc code just to handle this case. 
	 * KAO.
	 *
	 * "trace the ppid" is simple, but will fail if someone's
	 * parent exits.  I think this is as good as it gets. --RR
	 */
	// max_threads: 총 free된 page 수 / 16, MAX_KMOD_CONCURRENT: 50
	// min(총 free된 page 수 / 16, 50): 50
	max_modprobes = min(max_threads/2, MAX_KMOD_CONCURRENT);
	// max_modprobes: 50

	// kmod_concurrent.counter: 0
	atomic_inc(&kmod_concurrent);

	// atomic_inc 에서 한일:
	// kmod_concurrent.counter: 1

	// atomic_read(&kmod_concurrent): 1, max_modprobes: 50
	if (atomic_read(&kmod_concurrent) > max_modprobes) {
		/* We may be blaming an innocent here, but unlikely */
		if (kmod_loop_msg < 5) {
			printk(KERN_ERR
			       "request_module: runaway loop modprobe %s\n",
			       module_name);
			kmod_loop_msg++;
		}
		atomic_dec(&kmod_concurrent);
		return -ENOMEM;
	}

	// module_name: "fs-rootfs", wait: true
	trace_module_request(module_name, wait, _RET_IP_);

	// module_name: "fs-rootfs", wait: true, UMH_WAIT_PROC: 2, UMH_WAIT_EXEC: 1
	ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);

kmod.c::call_modprobe()

  • calll: start_kernel()-> vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create(): mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
  • call: get_fs_type()
  • strchr(): rootfs
  • strlen(): rootfs: 6 call_modprobe() - __get_fs_type()
  • request_module(): fs-rootfs
  • call: request_moudule(): __request_moudule()

  • call: __request_moudule()

  • ATOMIC_INIT()
  • WARN_ON_ONCE(): current_is_async()
  • va_start()
  • vsnprintf()
  • va_end()
  • security_kernel_module_request(): fs-rootfs
  • min(): max_threads/2, MAX_KMOD_CONCURRENT
  • atomic_inc(): kmod_concurrent
  • atomic_read(): kmod_concurrent
  • trace_module_request()
  • call_modprobe(): fs-rootfs
// ARM10C 20160402
// module_name: "fs-rootfs", 2
static int call_modprobe(char *module_name, int wait)
{
	struct subprocess_info *info;
	static char *envp[] = {
		"HOME=/",
		"TERM=linux",
		"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
		NULL
	};
	// envp[0]: "HOME=/"
	// envp[1]: "TERM=linux"
	// envp[2]: "PATH=/sbin:/usr/sbin:/bin:/usr/bin"

	// sizeof(char *[5]): 20 bytes, GFP_KERNEL: 0xD0
	// kmalloc(20, GFP_KERNEL: 0xD0): kmem_cache#30-oX
	char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
	// argv: kmem_cache#30-oX

	// argv: kmem_cache#30-oX
	if (!argv)
		goto out;

	// module_name: "fs-rootfs", GFP_KERNEL: 0xD0
	// kstrdup("fs-rootfs", GFP_KERNEL: 0xD0): kmem_cache#30-oX: "fs-rootfs"
	module_name = kstrdup(module_name, GFP_KERNEL);
	// module_name: kmem_cache#30-oX: "fs-rootfs"

	// module_name: kmem_cache#30-oX: "fs-rootfs"
	if (!module_name)
		goto free_argv;

	// argv[0]: (kmem_cache#30-oX)[0], modprobe_path: "/sbin/modprobe"
	argv[0] = modprobe_path;
	// argv[0]: (kmem_cache#30-oX)[0]: "/sbin/modprobe"

	// argv[1]: (kmem_cache#30-oX)[1]
	argv[1] = "-q";
	// argv[1]: (kmem_cache#30-oX)[1]: "-q"

	// argv[2]: (kmem_cache#30-oX)[2]
	argv[2] = "--";
	// argv[2]: (kmem_cache#30-oX)[2]: "--"

	// argv[3]: (kmem_cache#30-oX)[3], module_name: kmem_cache#30-oX: "fs-rootfs"
	argv[3] = module_name;	/* check free_modprobe_argv() */
	// argv[3]: (kmem_cache#30-oX)[3]: kmem_cache#30-oX: "fs-rootfs"

	// argv[4]: (kmem_cache#30-oX)[4]
	argv[4] = NULL;
	// argv[4]: (kmem_cache#30-oX)[4]: NULL

	// modprobe_path: "/sbin/modprobe", argv: kmem_cache#30-oX
	// envp[0]: "HOME=/"
	// envp[1]: "TERM=linux"
	// envp[2]: "PATH=/sbin:/usr/sbin:/bin:/usr/bin", GFP_KERNEL: 0xD0
	// call_usermodehelper_setup("/sbin/modprobe", kmem_cache#30-oX, envp, GFP_KERNEL: 0xD0, NULL, free_modprobe_argv, NULL):
	// kmem_cache#30-oX (struct subprocess_info)
	info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
					 NULL, free_modprobe_argv, NULL);
	// info: kmem_cache#30-oX (struct subprocess_info)

// 2016/04/02 종료

	if (!info)
		goto free_module_name;

	return call_usermodehelper_exec(info, wait | UMH_KILLABLE);

kmod.c::call_usermodehelper_exec()

  • calll: start_kernel()-> vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create(): mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
  • call: get_fs_type()
  • strchr(): rootfs
  • strlen(): rootfs: 6 call_modprobe() - __get_fs_type()
  • request_module(): fs-rootfs
  • call: request_moudule(): __request_moudule()

  • call: __request_moudule()

  • ATOMIC_INIT()
  • WARN_ON_ONCE(): current_is_async()
  • va_start()
  • vsnprintf()
  • va_end()
  • security_kernel_module_request(): fs-rootfs
  • min(): max_threads/2, MAX_KMOD_CONCURRENT
  • atomic_inc(): kmod_concurrent
  • atomic_read(): kmod_concurrent
  • trace_module_request()
  • call_modprobe(): fs-rootfs
  • call: call_modprobe()
  • kmalloc(): kmem_cache#30-oX
  • kstrdup(): fs-rootfs
  • call_usermodehelper_setup()
  • call_usermodehelper_exec()
int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
{
	DECLARE_COMPLETION_ONSTACK(done);

completion.h::DECLARE_COMPLETION_ONSTACK()

  • calll: start_kernel()-> vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create(): mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
  • call: get_fs_type()
  • strchr(): rootfs
  • strlen(): rootfs: 6 call_modprobe() - __get_fs_type()
  • request_module(): fs-rootfs
  • call: request_moudule(): __request_moudule()

  • call: __request_moudule()

  • ATOMIC_INIT()
  • WARN_ON_ONCE(): current_is_async()
  • va_start()
  • vsnprintf()
  • va_end()
  • security_kernel_module_request(): fs-rootfs
  • min(): max_threads/2, MAX_KMOD_CONCURRENT
  • atomic_inc(): kmod_concurrent
  • atomic_read(): kmod_concurrent
  • trace_module_request()
  • call_modprobe(): fs-rootfs
  • call: call_modprobe()
  • kmalloc(): kmem_cache#30-oX
  • kstrdup(): fs-rootfs
  • call_usermodehelper_setup()
  • call_usermodehelper_exec()
  • call: call_usermodehelper_exec()
  • DECLARE_COMPLETION_ONSTACK()
#ifdef CONFIG_LOCKDEP
# define DECLARE_COMPLETION_ONSTACK(work) \
	struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
#else
# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
#endif

completion.h::DECLARE_COMPLETION_ONSTACK()

  • calll: start_kernel()-> vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create(): mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
  • call: get_fs_type()
  • strchr(): rootfs
  • strlen(): rootfs: 6
  • call_modprobe() - __get_fs_type()
  • request_module(): fs-rootfs
  • call: request_moudule(): __request_moudule()

  • call: __request_moudule()

  • ATOMIC_INIT()
  • WARN_ON_ONCE(): current_is_async()
  • va_start()
  • vsnprintf()
  • va_end()
  • security_kernel_module_request(): fs-rootfs
  • min(): max_threads/2, MAX_KMOD_CONCURRENT
  • atomic_inc(): kmod_concurrent
  • atomic_read(): kmod_concurrent
  • trace_module_request()
  • call_modprobe(): fs-rootfs
  • call: call_modprobe()
  • kmalloc(): kmem_cache#30-oX
  • kstrdup(): fs-rootfs
  • call_usermodehelper_setup()
  • call_usermodehelper_exec()
  • call: call_usermodehelper_exec()
  • DECLARE_COMPLETION_ONSTACK()
  • helper_lock()
  • queue_work(): khelper_wq
  • wait_for_completion()
  • call_usermodehelper_freeinfo()
  • helper_unlock()

  • calll: start_kernel()-> vfs_caches_init()
  • kmem_cache_create(): names_cache
  • dcache_init()
  • inode_init()
  • files_init()
  • mnt_init()
  • call: mnt_init()

    • kmem_cache_create(): mnt_cache
    • alloc_large_system_hash() : Mount-cache
    • alloc_large_system_hash() : Mountpoint-cache
    • INIT_HLIST_HEAD() : &mount_hashtable[u]
    • INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
    • sysfs_init()
    • kobject_create_and_add() : fs
    • init_rootfs()
    • init_mount_tree()
  • call: init_mount_tree()

  • get_fs_type 3994 ~/fs/namespace.c
  • return: get_fs_type()
  • strchr(): rootfs
  • strlen(): rootfs: 6
  • get_fs_type(): -16
// ARM10C 20160326
// "rootfs"
struct file_system_type *get_fs_type(const char *name)
{
	struct file_system_type *fs;

	// name: "rootfs", strchr("rootfs". '.'): NULL
	const char *dot = strchr(name, '.');
	// dot: NULL

	// dot: NULL, name: "rootfs", strlen("rootfs"): 6
	int len = dot ? dot - name : strlen(name);
	// len: 6

	// name: "rootfs", len: 6, __get_fs_type("rootfs", 6): NULL
	fs = __get_fs_type(name, len);
	// fs: NULL

	// __get_fs_type 에서 한일:
	// fs: NULL

	// fs: NULL, len: 6, name: "rootfs"
	if (!fs && (request_module("fs-%.*s", len, name) == 0))
		fs = __get_fs_type(name, len);

	if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
		put_filesystem(fs);
		fs = NULL;
	}
	return fs;
}

EXPORT_SYMBOL(get_fs_type);

log

79c2479..90f35b6  master     -> origin/master
Updating 79c2479..90f35b6
Fast-forward
Reference/Breakdown/008_linux-kernel_20130615.md | 140 ++-----
arch/arm/include/asm/bitops.h                    |   5 +
arch/arm/lib/bitops.h                            |   1 +
fs/filesystems.c                                 |   3 +
fs/namespace.c                                   | 215 ++++++++++-
fs/ramfs/inode.c                                 |   1 +
fs/super.c                                       | 444 +++++++++++++++++++++++
include/asm-generic/bitops/non-atomic.h          |   2 +
include/linux/fs.h                               |   1 +
include/linux/kconfig.h                          |   1 +
include/linux/slab.h                             |   4 +
init/do_mounts.c                                 |  13 +
kernel/module.c                                  |   3 +
lib/idr.c                                        | 275 +++++++++++++-
mm/shmem.c                                       |   1 +
mm/util.c                                        |   2 +
mm/vmscan.c                                      |   2 +
17 files changed, 979 insertions(+), 134 deletions(-)