Skip to content

Latest commit

 

History

History
764 lines (645 loc) · 23.9 KB

a10c_123.md

File metadata and controls

764 lines (645 loc) · 23.9 KB
ARM10C : 123 주차
일시 : 2015.11.14 (123 주차 스터디 진행)
모임명 : NAVER_개발자커뮤니티지원_10차ARM-C
장소 : 토즈 타워점
장소지원 : NAVER 개발자 커뮤니티 지원 프로그램
참여인원 : 3명

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

123 주차 진도

  • 122주차 진도를 복습하였습니다.

  • vfs_caches_init()

  • start_kernel 1 ~/kernel/iamroot/linux-stable/init/main.c
    • vfs_caches_init 925 ~/kernel/iamroot/linux-stable/init/main.c
    • files_init 3485 ~/kernel/iamroot/linux-stable/fs/dcache.c

main.c::start_kernel()

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

...

	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();

	// dcache_init에서 한일:
	//
	// struct dentry를 위한 kmem_cache 생성
	// dentry_cache: kmem_cache#5

	inode_init();

	// inode_init에서 한일:
	//
	// struct inode를 위한 kmem_cache 생성
	// inode_cachep: kmem_cache#4

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

	// files_init에서 한일:
	//
	// filp_cachep: kmem_cache#3
	// files_stat.max_files: (총 free된 page 수 - XXX) * 4 / 10
	// sysctl_nr_open_max: 0x3FFFFFE0
	//
	// (&(&(&(&nr_files)->lock)->wait_lock)->rlock)->raw_lock: { { 0 } }
	// (&(&(&(&nr_files)->lock)->wait_lock)->rlock)->magic: 0xdead4ead
	// (&(&(&(&nr_files)->lock)->wait_lock)->rlock)->owner: 0xffffffff
	// (&(&(&(&nr_files)->lock)->wait_lock)->rlock)->owner_cpu: 0xffffffff
	// (&(&nr_files)->list)->next: &(&nr_files)->list
	// (&(&nr_files)->list)->prev: &(&nr_files)->list
	// (&nr_files)->count: 0
	// (&nr_files)->counters: kmem_cache#26-o0 에서 할당된 4 bytes 메모리 주소
	// list head 인 &percpu_counters에 &(&nr_files)->list를 연결함
	
	mnt_init();

namespace.c::mnt_init()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • mnt_cahce를 할당받는다.
// 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만큼 할당받은 메모리 주소

// 2015/10/24 종료
// 2015/10/31 시작

	// 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 수행
		
	err = sysfs_init();

mount.c::sysfs_init()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
// ARM10C 20151031
int __init sysfs_init(void)
{
	// ENOMEM: 12
	int err = -ENOMEM;
	// err: -12

	// sizeof(struct sysfs_dirent): 64 bytes
	// kmem_cache_create("sysfs_dir_cache", 64, 0, 0, NULL): kmem_cache#1
	sysfs_dir_cachep = kmem_cache_create("sysfs_dir_cache",
					      sizeof(struct sysfs_dirent),
					      0, 0, NULL);
	// sysfs_dir_cachep: kmem_cache#1

	// sysfs_dir_cachep: kmem_cache#1
	if (!sysfs_dir_cachep)
		goto out;

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

	// err: 0
	if (err)
		goto out_err;

	// register_filesystem(&sysfs_fs_type): 0
	err = register_filesystem(&sysfs_fs_type);
	// err: 0

	// register_filesystem에서 한일:
	// file_systems: &sysfs_fs_type

	// err: 0
	if (!err) {
		sysfs_mnt = kern_mount(&sysfs_fs_type);

namespace.c::kern_mount_data()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
    • kmem_cache_create()
    • sysfs_inode_init()
    • register_filesystem()
    • kern_mount()
// ARM10C 20151031
// &sysfs_fs_type
#define kern_mount(type) kern_mount_data(type, NULL)
// ARM10C 20151031
// &sysfs_fs_type, NULL
struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
{
	struct vfsmount *mnt;

	// type: &sysfs_fs_type, MS_KERNMOUNT: 0x400000, type->name: (&sysfs_fs_type)->name: "sysfs", data: NULL
	mnt = vfs_kern_mount(type, MS_KERNMOUNT, type->name, data);

vfs_kern_mount()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
    • kmem_cache_create()
    • sysfs_inode_init()
    • register_filesystem()
    • kern_mount()
    • vfs_kern_mount()
// ARM10C 20151031
// type: &sysfs_fs_type, MS_KERNMOUNT: 0x400000, type->name: (&sysfs_fs_type)->name: "sysfs", data: NULL
struct vfsmount *
vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
{
	struct mount *mnt;
	struct dentry *root;

	// type: &sysfs_fs_type
	if (!type)
		return ERR_PTR(-ENODEV);

	// name: "sysfs", alloc_vfsmnt("sysfs"): kmem_cache#2-oX (struct mount)
	mnt = alloc_vfsmnt(name);
	// mnt: kmem_cache#2-oX (struct mount)

	// mnt: kmem_cache#2-oX (struct mount)
	if (!mnt)
		return ERR_PTR(-ENOMEM);
		
// 2015/11/07 종료
// 2015/11/14 시작

	// flags: 0x400000, MS_KERNMOUNT: 0x400000
	if (flags & MS_KERNMOUNT)
		// mnt->mnt.mnt_flags: (kmem_cache#2-oX (struct mount))->mnt.mnt_flags, MNT_INTERNAL: 0x4000
		mnt->mnt.mnt_flags = MNT_INTERNAL;
		// mnt->mnt.mnt_flags: (kmem_cache#2-oX (struct mount))->mnt.mnt_flags: 0x4000

	// type: &sysfs_fs_type, flags: 0x400000, name: "sysfs", data: NULL
	root = mount_fs(type, flags, name, data);
  • alloc_vfsmnt()에서 한일:
  • struct mount의 메모리를 할당 받음 kmem_cache#2-oX (struct mount)
  • idr_layer_cache를 사용하여 struct idr_layer 의 메모리 kmem_cache#21-o0...7를 8 개를 할당 받음
  • (kmem_cache#21-o0...7)->ary[0]: NULL
  • (&(&mnt_id_ida)->idr)->id_free: kmem_cache#21-o7
  • (&(&mnt_id_ida)->idr)->id_free_cnt: 7
  • struct ida_bitmap 의 메모리 kmem_cache#27-oX 할당 받음
  • (&mnt_id_ida)->free_bitmap: kmem_cache#27-oX
  • (&(&mnt_id_ida)->idr)->id_free: NULL
  • (&(&mnt_id_ida)->idr)->id_free_cnt: 6
  • (&(&mnt_id_ida)->idr)->top: kmem_cache#21-o7 (struct idr_layer)
  • (&(&mnt_id_ida)->idr)->layers: 1
  • (&mnt_id_ida)->free_bitmap: NULL
  • (kmem_cache#21-o7 (struct idr_layer))->ary[0]: NULL
  • (kmem_cache#21-o7 (struct idr_layer))->layer: 0
  • (kmem_cache#21-o7 (struct idr_layer))->ary[0]: kmem_cache#27-oX (struct ida_bitmap)
  • (kmem_cache#21-o7 (struct idr_layer))->count: 1
  • (kmem_cache#27-oX (struct ida_bitmap))->bitmap 의 0 bit를 1로 set 수행
  • (kmem_cache#2-oX (struct mount))->mnt_id: 0
  • mnt_id_start: 1
  • (kmem_cache#2-oX (struct mount))->mnt_devname: kmem_cache#30-oX: "sysfs"
  • (kmem_cache#2-oX (struct mount))->mnt_pcp: kmem_cache#26-o0 에서 할당된 8 bytes 메모리 주소
  • [pcp0] (kmem_cache#2-oX (struct mount))->mnt_pcp->mnt_count: 1
  • ((kmem_cache#2-oX (struct mount))->mnt_hash)->next: NULL
  • ((kmem_cache#2-oX (struct mount))->mnt_hash)->pprev: NULL
  • ((kmem_cache#2-oX (struct mount))->mnt_child)->next: (kmem_cache#2-oX (struct mount))->mnt_child
  • ((kmem_cache#2-oX (struct mount))->mnt_child)->prev: (kmem_cache#2-oX (struct mount))->mnt_child
  • ((kmem_cache#2-oX (struct mount))->mnt_mounts)->next: (kmem_cache#2-oX (struct mount))->mnt_mounts
  • ((kmem_cache#2-oX (struct mount))->mnt_mounts)->prev: (kmem_cache#2-oX (struct mount))->mnt_mounts
  • ((kmem_cache#2-oX (struct mount))->mnt_list)->next: (kmem_cache#2-oX (struct mount))->mnt_list
  • ((kmem_cache#2-oX (struct mount))->mnt_list)->prev: (kmem_cache#2-oX (struct mount))->mnt_list
  • ((kmem_cache#2-oX (struct mount))->mnt_expire)->next: (kmem_cache#2-oX (struct mount))->mnt_expire
  • ((kmem_cache#2-oX (struct mount))->mnt_expire)->prev: (kmem_cache#2-oX (struct mount))->mnt_expire
  • ((kmem_cache#2-oX (struct mount))->mnt_share)->next: (kmem_cache#2-oX (struct mount))->mnt_share
  • ((kmem_cache#2-oX (struct mount))->mnt_share)->prev: (kmem_cache#2-oX (struct mount))->mnt_share
  • ((kmem_cache#2-oX (struct mount))->mnt_slave_list)->next: (kmem_cache#2-oX (struct mount))->mnt_slave_list
  • ((kmem_cache#2-oX (struct mount))->mnt_slave_list)->prev: (kmem_cache#2-oX (struct mount))->mnt_slave_list
  • ((kmem_cache#2-oX (struct mount))->mnt_slave)->next: (kmem_cache#2-oX (struct mount))->mnt_slave
  • ((kmem_cache#2-oX (struct mount))->mnt_slave)->prev: (kmem_cache#2-oX (struct mount))->mnt_slave
  • ((kmem_cache#2-oX (struct mount))->mnt_fsnotify_marks)->first: NULL

super.c::mount_fs()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
    • kmem_cache_create()
    • sysfs_inode_init()
    • register_filesystem()
    • kern_mount()
    • vfs_kern_mount()
      • alloc_vfsmnt()
      • mount_fs()
// ARM10C 20151114
// type: &sysfs_fs_type, flags: 0x400000, name: "sysfs", data: NULL
struct dentry *
mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
{
	struct dentry *root;
	struct super_block *sb;
	char *secdata = NULL;
	// secdata: NULL

	// ENOMEM: 12
	int error = -ENOMEM;
	// error: -12

	// data: NULL, type->fs_flags: (&sysfs_fs_type)->fs_flags: 8, FS_BINARY_MOUNTDATA: 2
	if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) {
		secdata = alloc_secdata();
		if (!secdata)
			goto out;

		error = security_sb_copy_data(data, secdata);
		if (error)
			goto out_free_secdata;
	}

	// type->mount: (&sysfs_fs_type)->mount: sysfs_mount
	// type: &sysfs_fs_type, flags: 0x400000, name: "sysfs", data: NULL
	// sysfs_mount(&sysfs_fs_type, 0x400000, "sysfs", NULL):
	root = type->mount(type, flags, name, data);

mount.c::sysfs_mount()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
    • kmem_cache_create()
    • sysfs_inode_init()
    • register_filesystem()
    • kern_mount()
    • vfs_kern_mount()
      • alloc_vfsmnt()
      • mount_fs()
        • mount(): sysfs_mount()
// ARM10C 20151114
// type: &sysfs_fs_type, flags: 0x400000, name: "sysfs", data: NULL
static struct dentry *sysfs_mount(struct file_system_type *fs_type,
	int flags, const char *dev_name, void *data)
{
	struct sysfs_super_info *info;
	enum kobj_ns_type type;
	struct super_block *sb;
	int error;

	// flags: 0x400000, MS_KERNMOUNT: 0x400000
	if (!(flags & MS_KERNMOUNT)) {
		if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type))
			return ERR_PTR(-EPERM);

		for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++) {
			if (!kobj_ns_current_may_mount(type))
				return ERR_PTR(-EPERM);
		}
	}

	// sizeof(struct sysfs_super_info): 8 bytes, GFP_KERNEL: 0xD0
	// kzalloc(8, GFP_KERNEL: 0xD0): kmem_cache#30-oX
	info = kzalloc(sizeof(*info), GFP_KERNEL);
	// info: kmem_cache#30-oX (struct sysfs_super_info)

	// info: kmem_cache#30-oX (struct sysfs_super_info)
	if (!info)
		return ERR_PTR(-ENOMEM);

	// KOBJ_NS_TYPE_NONE: 0, KOBJ_NS_TYPES: 2
	for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++)
		// type: 0, info->ns[0]: (kmem_cache#30-oX (struct sysfs_super_info))->ns[0],
		// kobj_ns_grab_current(0): NULL
		info->ns[type] = kobj_ns_grab_current(type);
		// info->ns[0]: (kmem_cache#30-oX (struct sysfs_super_info))->ns[0]: NULL

	// fs_type: &sysfs_fs_type, flags: 0x400000, info: kmem_cache#30-oX (struct sysfs_super_info)
	sb = sget(fs_type, sysfs_test_super, sysfs_set_super, flags, info);

super.c::sget()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
    • kmem_cache_create()
    • sysfs_inode_init()
    • register_filesystem()
    • kern_mount()
    • vfs_kern_mount()
      • alloc_vfsmnt()
      • mount_fs()
        • mount(): sysfs_mount()
        • sget()
// ARM10C 20151114
// fs_type: &sysfs_fs_type, sysfs_test_super, sysfs_set_super, flags: 0x400000, info: kmem_cache#30-oX (struct sysfs_super_info)
struct super_block *sget(struct file_system_type *type,
			int (*test)(struct super_block *,void *),
			int (*set)(struct super_block *,void *),
			int flags,
			void *data)
{
	struct super_block *s = NULL;
	// s: NULL

	struct super_block *old;
	int err;

retry:
	spin_lock(&sb_lock);

	// spin_lock에서 한일:
	// &sb_lock 을 사용한 spin lock 수행

	// [re] spin_lock에서 한일:
	// [re] &sb_lock 을 사용한 spin lock 수행

	// test: sysfs_test_super
	// [re] test: sysfs_test_super
	if (test) {
		// &type->fs_supers: &(&sysfs_fs_type)->fs_supers
		// hlist_entry_safe((&(&sysfs_fs_type)->fs_supers)->first, struct super_block, s_instances): NULL
		// [re] &type->fs_supers: &(&sysfs_fs_type)->fs_supers
		// [re] hlist_entry_safe((&(&sysfs_fs_type)->fs_supers)->first, struct super_block, s_instances): NULL
		hlist_for_each_entry(old, &type->fs_supers, s_instances) {
		// for (old = hlist_entry_safe((&type->fs_supers)->first, typeof(*(old)), s_instances);
		//      old; old = hlist_entry_safe((old)->s_instances.next, typeof(*(old)), s_instances))

			if (!test(old, data))
				continue;
			if (!grab_super(old))
				goto retry;
			if (s) {
				up_write(&s->s_umount);
				destroy_super(s);
				s = NULL;
			}
			return old;
		}
	}

	// s: NULL
	// [re] s: kmem_cache#25-oX (struct super_block)
	if (!s) {
		spin_unlock(&sb_lock);

		// spin_unlock에서 한일:
		// &sb_lock 을 사용한 spin unlock 수행

		// type: &sysfs_fs_type, flags: 0x400000
		// alloc_super(&sysfs_fs_type, 0x400000): kmem_cache#25-oX (struct super_block)
		s = alloc_super(type, flags);
// ARM10C 20151114
// #define hlist_for_each_entry(old, &type->fs_supers, s_instances):
// for (old = hlist_entry_safe((&type->fs_supers)->first, typeof(*(old)), s_instances);
//      old; old = hlist_entry_safe((old)->s_instances.next, typeof(*(old)), s_instances))
#define hlist_for_each_entry(pos, head, member)				\
	for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
	     pos;							\
	     pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))

super.c::alloc_super()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
    • kmem_cache_create()
    • sysfs_inode_init()
    • register_filesystem()
    • kern_mount()
    • vfs_kern_mount()
      • alloc_vfsmnt()
      • mount_fs()
        • mount(): sysfs_mount()
          • sget()
            • spin_lock()
            • hlist_for_eash_entry()
            • sping_unlock()
            • alloc_super()
/**
 *	alloc_super	-	create new superblock
 *	@type:	filesystem type superblock should belong to
 *	@flags: the mount flags
 *
 *	Allocates and initializes a new &struct super_block.  alloc_super()
 *	returns a pointer new superblock or %NULL if allocation had failed.
 */
// ARM10C 20151114
// type: &sysfs_fs_type, flags: 0x400000
static struct super_block *alloc_super(struct file_system_type *type, int flags)
{
	// sizeof(struct super_block): 709 bytes, GFP_USER: 0x200D0
	// kzalloc(709, GFP_USER: 0x200D0): kmem_cache#25-oX (struct super_block)
	struct super_block *s = kzalloc(sizeof(struct super_block),  GFP_USER);
	// s: kmem_cache#25-oX (struct super_block)

	static const struct super_operations default_op;
	int i;

	// s: kmem_cache#25-oX (struct super_block)
	if (!s)
		return NULL;

	// s: kmem_cache#25-oX (struct super_block), security_sb_alloc(kmem_cache#25-oX (struct super_block)): 0
	if (security_sb_alloc(s))

	// SB_FREEZE_LEVELS: 3
	for (i = 0; i < SB_FREEZE_LEVELS; i++) {
		// i: 0, &s->s_writers.counter[0]: &(kmem_cache#25-oX (struct super_block))->s_writers.counter[0]
		// percpu_counter_init(&(kmem_cache#25-oX (struct super_block))->s_writers.counter[0], 0): 0
		if (percpu_counter_init(&s->s_writers.counter[i], 0) < 0)
// ARM10C 20151114
// sizeof(struct super_block): 709 bytes, GFP_USER: 0x200D0
static inline void *kzalloc(size_t size, gfp_t flags)
{
	// size: 3076, GFP_KERNEL: 0xD0, __GFP_ZERO: 0x8000u
	// size: 66, GFP_KERNEL: 0xD0, __GFP_ZERO: 0x8000u
	return kmalloc(size, flags | __GFP_ZERO);
	// return kmem_cache#23-o0
}
// ARM10C 20151114
// s: kmem_cache#25-oX (struct super_block)
static inline int security_sb_alloc(struct super_block *sb)
{
	return 0;
	// return 0
}

percpu_counter.h::percpu_counter_init()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
    • kmem_cache_create()
    • sysfs_inode_init()
    • register_filesystem()
    • kern_mount()
    • vfs_kern_mount()
      • alloc_vfsmnt()
      • mount_fs()
        • mount(): sysfs_mount()
          • sget()
            • spin_lock()
            • hlist_for_eash_entry()
            • sping_unlock()
            • alloc_super()
              • percpu_counter_init()
                • __percpu_counter_init()
// ARM10C 20151114
// &s->s_writers.counter[0]: &(kmem_cache#25-oX (struct super_block))->s_writers.counter[0], 0
#define percpu_counter_init(fbc, value)					\
	({								\
		static struct lock_class_key __key;			\
									\
		__percpu_counter_init(fbc, value, &__key);		\
	})

percpu_counter.c::__percpu_counter_init()

  • start_kernel()->vfs_caches_init()
  • mnt_init()
  • sysfs_init()
    • kmem_cache_create()
    • sysfs_inode_init()
    • register_filesystem()
    • kern_mount()
    • vfs_kern_mount()
      • alloc_vfsmnt()
      • mount_fs()
        • mount(): sysfs_mount()
          • sget()
            • spin_lock()
            • hlist_for_eash_entry()
            • sping_unlock()
            • alloc_super()
              • percpu_counter_init()
                • __percpu_counter_init()
// ARM10C 20151114
// &s->s_writers.counter[0]: &(kmem_cache#25-oX (struct super_block))->s_writers.counter[0], 0, &__key
int __percpu_counter_init(struct percpu_counter *fbc, s64 amount,
			  struct lock_class_key *key)
{
	// &fbc->lock: &(&vm_committed_as)->lock
	raw_spin_lock_init(&fbc->lock);

	// raw_spin_lock_init에서 한일:
	// (&(&(&(&vm_committed_as)->lock)->wait_lock)->rlock)->raw_lock: { { 0 } }
	// (&(&(&(&vm_committed_as)->lock)->wait_lock)->rlock)->magic: 0xdead4ead
	// (&(&(&(&vm_committed_as)->lock)->wait_lock)->rlock)->owner: 0xffffffff
	// (&(&(&(&vm_committed_as)->lock)->wait_lock)->rlock)->owner_cpu: 0xffffffff

	// &fbc->lock: &(&vm_committed_as)->lock, key: &__key
	lockdep_set_class(&fbc->lock, key); // null function

	// fbc->count: (&vm_committed_as)->count, amount: 0
	fbc->count = amount;
	// fbc->count: (&vm_committed_as)->count: 0

	// fbc->counters: (&vm_committed_as)->counters,
	// alloc_percpu(s32): kmem_cache#26-o0 에서 할당된 4 bytes 메모리 주소
	fbc->counters = alloc_percpu(s32);

log

  • log
67b58f9..e0d5cf1  master     -> origin/master
Updating 67b58f9..e0d5cf1
Fast-forward
arch/arm/include/asm/atomic.h           |   4 +
arch/arm/include/asm/bitops.h           |   2 +
arch/arm/lib/findbit.S                  |   2 +
fs/filesystems.c                        |   3 +
fs/mount.h                              |   2 +
fs/namespace.c                          | 204 ++++++++++++++++++++++-
fs/super.c                              | 550 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
fs/sysfs/mount.c                        |  55 +++++++
fs/sysfs/sysfs.h                        |   3 +
include/asm-generic/atomic-long.h       |  11 ++
include/asm-generic/bitops/non-atomic.h |   2 +
include/asm-generic/rwsem.h             |  31 +++-
include/linux/backing-dev.h             |   1 +
include/linux/bitmap.h                  |   2 +
include/linux/bitops.h                  |   3 +
include/linux/dcache.h                  |   1 +
include/linux/fs.h                      |  22 ++-
include/linux/gfp.h                     |   4 +
include/linux/idr.h                     |  21 +++
include/linux/kdev_t.h                  |   8 +
include/linux/kernel.h                  |   2 +
include/linux/kobject_ns.h              |   4 +
include/linux/list.h                    |  37 +++++
include/linux/list_bl.h                 |   6 +-
include/linux/list_lru.h                |   4 +
include/linux/lockdep.h                 |  17 ++
include/linux/module.h                  |   1 +
include/linux/mount.h                   |   2 +
include/linux/mutex-debug.h             |   6 +
include/linux/mutex.h                   |   1 +
include/linux/nodemask.h                |  14 ++
include/linux/numa.h                    |   3 +
include/linux/percpu.h                  |  21 +++
include/linux/percpu_counter.h          |   4 +
include/linux/quota.h                   |   8 +
include/linux/rcupdate.h                |   8 +
include/linux/rwsem-spinlock.h          |   1 +
include/linux/rwsem.h                   |   8 +-
include/linux/security.h                |   3 +
include/linux/shrinker.h                |   6 +
include/linux/slab.h                    |  13 ++
include/linux/spinlock.h                |  20 +++
include/linux/spinlock_types.h          |  52 +++++-
include/linux/types.h                   |  10 ++
include/linux/wait.h                    |   5 +
include/uapi/asm-generic/errno-base.h   |   4 +
include/uapi/asm-generic/posix_types.h  |   1 +
include/uapi/linux/fs.h                 |   1 +
include/uapi/linux/quota.h              |   2 +
kernel/locking/mutex.c                  |   6 +
kernel/locking/rwsem-spinlock.c         |  19 ++-
kernel/locking/rwsem.c                  |  14 +-
kernel/locking/spinlock_debug.c         |   2 +
kernel/module.c                         |   3 +
kernel/sched/wait.c                     |   4 +
lib/idr.c                               | 174 ++++++++++++++++++--
lib/kobject.c                           |  27 +++
lib/percpu_counter.c                    |   2 +
lib/string.c                            |   3 +
mm/backing-dev.c                        |   2 +
mm/list_lru.c                           |  37 +++++
mm/percpu.c                             |   2 +
mm/util.c                               |   2 +
mm/vmscan.c                             |   2 +
64 files changed, 1462 insertions(+), 32 deletions(-)