ARMv8 :
http://www.arm.com/support/training/arm-training-courses/armv8-a-software-development.php
129 주차 진도
- 128 주차 진도를 복습하였습니다.
- vfs_caches_init()
- start_kernel 1 ~/kernel/iamroot/linux-stable/init/main.c
- vfs_caches_init 925 ~/kernel/iamroot/linux-stable/init/main.c
- mnt_init 3807 ~/kernel/iamroot/linux-stable/fs/dcache.c
- sysfs_init 3496 err = sysfs_init();
- kern_mount 824 ~/kernel/iamroot/linux-stable/fs/sysfs/mount.c
- kern_mount_data 1962 ~/kernel/iamroot/linux-stable/include/linux/fs.h
- vfs_kern_mount 3949 mnt = vfs_kern_mount(type, MS_KERNMOUNT, type->name, data);
- 128주차 함수 호출 구조
- call: start_kernel()->vfs_caches_init()
- vfs_caches_init()
- min()
- kmem_cache_create() : names_caches
- dcache_init()
- inode_init()
- files_init(): mempages
- 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()
- sysfs_init()
- kmem_cache_create(): sysfs_dir_cache
- sysfs_inode_init()
- register_filesystem(): sysfs_fs_type
- kern_mount() : kern_mount_data()
- vfs_kern_mount()
- alloc_vfsmnt(): sysfs
- kmem_cache_zalloc()
- mnt_alloc_id()
- alloc_percpu()
- INIT_HLIST_NODE(): mnt_hash
- INIT_LIST_HEAD(): mnt_child
- INIT_LIST_HEAD(): mnt_mounts
- INIT_LIST_HEAD(): mnt_list
- INIT_LIST_HEAD(): mnt_expire
- INIT_LIST_HEAD(): mnt_share
- INIT_LIST_HEAD(): mnt_slave_list
- INIT_LIST_HEAD(): mnt_slave
- INIT_LIST_HEAD(): mnt_fsnotify_marks
- mount_fs(): sysfs
- mount_fs(): sysfs_mount()
- kzalloc(): sysfs_super_info
- sget()
- spin_lock(): sb_lock
- hlist_for_eash_entry()
- spin_unlock()
- alloc_super()
- kzalloc(): super_block
- security_sb_alloc()
- percpu_counter_init()
- lockdep_init_map()
- init_waitqueue_head(): s_writers.wait
- init_waitqueue_head: s_writers.wait_unfrozen
- INIT_HLIST_NODE(): s_instances
- INIT_HLIST_BL_HEAD(): s_anon
- INIT_LIST_HEAD: s_inodes
- list_lru_init(): s_dentry_lru
- list_lru_init(): s_inode_lru
- INIT_LIST_HEAD: s_mounts
- init_rwsem(): s_umount
- lockdep_set_class(): s_umount
- down_write_nested(): s_umount
- atomic_set(): s_active
- mutext_init(): s_vfs_rename_mutex
- lockdep_set_class(): s_vfs_rename_key
- mutex_init(): s_dquot.dpio_mutex
- mutext_init(): s_dquot.dqonoff_mutex
- init_rwsem(): s_dquot.dqptr_sem
- set()
- strlcpy(): s_id, sysfs
- list_add_tail(): s_list
- hlist_add_head(): s_instances
- spin_unlock(): sb_lock
- get_filesystem(type)
- register_shrinker()
- IS_ERR(): sb
- sysfs_fill_super()
- mutex_lock(): sysfs_mutex
- sysfs_get_inode(): super_block
- iget_locked(): super_block
- spin_lock(): inode_hash_lock
- find_inode_fast()
- spin_unlock: inode_hash_lock
- alloc_inode()
- kmem_cache_alloc(): inode
- inode_init_always(): inode
- atomic_set(): i_count
- i_uid_write()
- i_gid_write()
- atomic_set: i_writecount
- security_inode_alloc(): inode
- spin_lock_init(): i_lock
- spinlock_check()
- raw_spin_lock_init()
- lockdep_set_class(): s_type->i_lock_key
- mutex_init(): i_mutex
- lockdep_set_class(): s_type->i_mutex
- atomic_set(): i_dio_count
- mapping_set_gfp_mask(): inode
- INIT_HLIST_HEAD(): inode->i_dentry
- this_cpu_inc()
- spin_lock(): inode_hash_lock
- fine_inode_fast()
- spin_lock(): inode->i_lock
- hlist_add_head(): inode->i_hash
- spin_unlock(): inode->i_lock
- sysfs_init_inode(): sysfs_root
- mutex_unlock()
- d_make_root()
- _dalloc(): super_block
- kmem_cache_alloc(): dentry
- memcpy(): d_iname: name->name, (&name)->name: "/", (&name)->len
- swp_wmb()
- spin_lock_init(): dentry_d_lock
- seqcount_init(): d_seq
- INIT_HLIST_BL_NODE(): dentry->d_fsdata
- INIT_LIST_HEAD(): dentry->d_lru
- INIT_LIST_HEAD(): dentry->d_subdirs
- INIT_HLIST_NODE(): dentry->d_alias
- INIT_LIST_HEAD(): dentry->d_u.d_child
- d_set_d_op(): dentry->d_sb->s_d_op
- this_cpu_inc()
- d_instantiate(): dentry
- BUG_ON: hlist_unhased(): entry->d_alias
- sping_lock(): inode->i_lock
- _dinstantiate()
- spin_lock(): dentry->d_lock
- hlist_add_head(): dentry->d_alias
- dentry_rcuwalk_barrier(): dentry
- assert_spin_locked(): assert_raw_spin_locked() : BUG_ON(!raw_spin_is_locked(x))
- write_seqcount_barrier()
- swp_wmb()
- spin_unlock(): dentry->d_lock
- fsnotify_d_instantiate()
- spin_unlock()
- mutext_lock(): sysfs_mutex
- sysfs_get_inode(): sfsfs_get_inode
- iget_locked(): super_block
- spin_lock(): inode_hash_lock
- find_inode_fast(): super_block
- spin_unlock(): inode_hash_lock
- alloc_inode()
- kmem_cache_alloc(): inode
- inode_init_always(): inode
- atomic_set(): i_count
- i_uid_write()
- i_gid_write()
- atomic_set: i_writecount
- security_inode_alloc(): inode
- spin_lock_init(): i_lock
- spinlock_check()
- raw_spin_lock_init()
- lockdep_set_class(): s_type->i_lock_key
- mutex_init(): i_mutex
- lockdep_set_class(): s_type->i_mutex
- atomic_set(): i_dio_count
- mapping_set_gfp_mask(): inode
- INIT_HLIST_HEAD(): inode->i_dentry
- this_cpu_inc()
- spin_lock(): inode_hash_lock
- find_inode_fast()
- spin_lock(): i_lock
- hlist_add_head(): i_hash
- spin_unlock(): i_lock
- inode_sb_list_add(): inode
- spin_unlock(): inode_hash_lock
- sysfs_init_inode(): sysfs_root
- sysfs_get(): sysfs_root
- set_default_inode_attr()
- sysfs_refresh_inode(): sysfs_root
- sysfs_type(): sysfs_root
- unlock_new_inode(): inode
- dget(): s_root
- lockref_get(): dentry->d_lockref
- vfs_kern_mount()
- alloc_vfsmnt(): sysfs
- kmem_cache_zalloc()
- mnt_alloc_id()
- alloc_percpu()
- INIT_HLIST_NODE(): mnt_hash
- INIT_LIST_HEAD(): mnt_child
- INIT_LIST_HEAD(): mnt_mounts
- INIT_LIST_HEAD(): mnt_list
- INIT_LIST_HEAD(): mnt_expire
- INIT_LIST_HEAD(): mnt_share
- INIT_LIST_HEAD(): mnt_slave_list
- INIT_LIST_HEAD(): mnt_slave
- INIT_LIST_HEAD(): mnt_fsnotify_marks
- mount_fs(): sysfs
- IS_ERR(): root
- BUG_ON(): super_block
- WARN_ON(): super_block->s_bdi
- WARN_ON(): super_block->s_bdi == default_backing_dev_info
- security_sb_kern_mount()
- WARN(): super_block->s_maxbytes
- up_write(): super_block->s_umount
- free_secdata()
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[];
...
proc_caches_init();
buffer_init();
key_init();
security_init();
dbg_late_init();
vfs_caches_init(totalram_pages);
## dcache.c::vfs_cache_init() * call: start_kernel() - vfs_caches_init()
void __init vfs_caches_init(unsigned long mempages)
{
unsigned long reserve;
reserve = min((mempages - nr_free_pages()) * 3/2, mempages - 1);
mempages -= reserve;
names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
dcache_init();
inode_init();
files_init(mempages);
mnt_init();
## namespace.c::mnt_init() * call: start_kernel()->vfs_caches_init() - mnt_init()
void __init mnt_init(void)
{
unsigned u;
int err;
mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),
0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
mount_hashtable = alloc_large_system_hash("Mount-cache",
sizeof(struct hlist_head),
mhash_entries, 19,
0,
&m_hash_shift, &m_hash_mask, 0, 0);
mountpoint_hashtable = alloc_large_system_hash("Mountpoint-cache",
sizeof(struct hlist_head),
mphash_entries, 19,
0,
&mp_hash_shift, &mp_hash_mask, 0, 0);
if (!mount_hashtable || !mountpoint_hashtable)
panic("Failed to allocate mount hash table\n");
for (u = 0; u <= m_hash_mask; u++)
INIT_HLIST_HEAD(&mount_hashtable[u]);
for (u = 0; u <= mp_hash_mask; u++)
INIT_HLIST_HEAD(&mountpoint_hashtable[u]);
err = sysfs_init();
if (err)
printk(KERN_WARNING "%s: sysfs_init error: %d\n",
__func__, err);
fs_kobj = kobject_create_and_add("fs", NULL);
## kobject.c::kobject_create_and_add() * call: start_kernel()->vfs_caches_init()->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
struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
{
struct kobject *kobj;
int retval;
kobj = kobject_create();
## kobject.c::kobject_create() * call: start_kernel()->vfs_caches_init()->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 - kobject_create()
struct kobject *kobject_create(void)
{
struct kobject *kobj;
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
if (!kobj)
return NULL;
kobject_init(kobj, &dynamic_kobj_ktype);
## kobject.c::kobject_create() * call: start_kernel()->vfs_caches_init()->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 - kobject_create()
struct kobject *kobject_create(void)
{
struct kobject *kobj;
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
if (!kobj)
return NULL;
kobject_init(kobj, &dynamic_kobj_ktype);
## kobject.c::kobject_init() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init()
void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
{
char *err_str;
if (!kobj) {
err_str = "invalid kobject pointer!";
goto error;
}
if (!ktype) {
err_str = "must have a ktype to be initialized properly!\n";
goto error;
}
if (kobj->state_initialized) {
printk(KERN_ERR "kobject (%p): tried to init an initialized "
"object, something is seriously wrong.\n", kobj);
dump_stack();
}
kobject_init_internal(kobj);
## kobject.c::kobject_init_internal() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj
static void kobject_init_internal(struct kobject *kobj)
{
if (!kobj)
return;
kref_init(&kobj->kref);
* kref_init()
static inline void kref_init(struct kref *kref)
{
atomic_set(&kref->refcount, 1);
}
* kref_init에서 한일: - (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1 * INIT_LIST_HEAD에서 한일: - (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry - (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry
// ARM10C 20160109
// kobj: kmem_cache
static void kobject_init_internal(struct kobject *kobj)
{
// kobj: kmem_cache
if (!kobj)
return;
// &kobj->kref: &(kmem_cache
kref_init(&kobj->kref);
// kref_init에서 한일:
// (&(kmem_cache
// &kobj->entry: &(kmem_cache
INIT_LIST_HEAD(&kobj->entry);
// INIT_LIST_HEAD에서 한일:
// (&(kmem_cache
// (&(kmem_cache
// kobj->state_in_sysfs: (kmem_cache#30-oX (struct kobject))->state_in_sysfs
kobj->state_in_sysfs = 0;
// kobj->state_in_sysfs: (kmem_cache#30-oX (struct kobject))->state_in_sysfs: 0
// kobj->state_add_uevent_sent: (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent
kobj->state_add_uevent_sent = 0;
// kobj->state_add_uevent_sent: (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent: 0
// kobj->state_remove_uevent_sent: (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent
kobj->state_remove_uevent_sent = 0;
// kobj->state_remove_uevent_sent: (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent: 0
// kobj->state_initialized: (kmem_cache#30-oX (struct kobject))->state_initialized
kobj->state_initialized = 1;
// kobj->state_initialized: (kmem_cache#30-oX (struct kobject))->state_initialized: 1
}
* kobject_init_internal에서 한일: - (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1 - (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry - (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry - (kmem_cache#30-oX (struct kobject))->state_in_sysfs: 0 - (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent: 0 - (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent: 0 - (kmem_cache#30-oX (struct kobject))->state_initialized: 1 ## kobject.c::kobject_init() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj
void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
{
char *err_str;
if (!kobj) {
err_str = "invalid kobject pointer!";
goto error;
}
if (!ktype) {
err_str = "must have a ktype to be initialized properly!\n";
goto error;
}
if (kobj->state_initialized) {
printk(KERN_ERR "kobject (%p): tried to init an initialized "
"object, something is seriously wrong.\n", kobj);
dump_stack();
}
kobject_init_internal(kobj);
kobj->ktype = ktype;
return;
error:
printk(KERN_ERR "kobject (%p): %s\n", kobj, err_str);
dump_stack();
}
EXPORT_SYMBOL(kobject_init);
* kobject_init에서 한일: - (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1 - (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry - (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry - (kmem_cache#30-oX (struct kobject))->state_in_sysfs: 0 - (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent: 0 - (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent: 0 - (kmem_cache#30-oX (struct kobject))->state_initialized: 1 - (kmem_cache#30-oX (struct kobject))->ktype: &dynamic_kobj_ktype ## kobject.c::kobject_create() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj
struct kobject *kobject_create(void)
{
struct kobject *kobj;
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
if (!kobj)
return NULL;
kobject_init(kobj, &dynamic_kobj_ktype);
return kobj;
}
* return kmem_cache#30-oX (struct kobject) * kobject_create에서 한일: - struct kobject의 메모리를 할당받음 kmem_cache#30-oX (struct kobject) - (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1 - (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry - (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry - (kmem_cache#30-oX (struct kobject))->state_in_sysfs: 0 - (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent: 0 - (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent: 0 - (kmem_cache#30-oX (struct kobject))->state_initialized: 1 - (kmem_cache#30-oX (struct kobject))->ktype: &dynamic_kobj_ktype ## kobject.c::kobject_create_and_add() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj
struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
{
struct kobject *kobj;
int retval;
kobj = kobject_create();
if (!kobj)
return NULL;
retval = kobject_add(kobj, parent, "%s", name);
## kobject.c::kobject_create_and_add() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add()
int kobject_add(struct kobject *kobj, struct kobject *parent,
const char *fmt, ...)
{
va_list args;
int retval;
if (!kobj)
return -EINVAL;
if (!kobj->state_initialized) {
printk(KERN_ERR "kobject '%s' (%p): tried to add an "
"uninitialized object, something is seriously wrong.\n",
kobject_name(kobj), kobj);
dump_stack();
return -EINVAL;
}
va_start(args, fmt);
## acenv.h::va_start() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start()
#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
#define va_end(ap) (ap = (va_list) NULL)
* va_start에서 한일: - (args): (((char *) &("%s")) + 4): "fs" ## kobject.c::kobject_add() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start()
int kobject_add(struct kobject *kobj, struct kobject *parent,
const char *fmt, ...)
{
va_list args;
int retval;
if (!kobj)
return -EINVAL;
if (!kobj->state_initialized) {
printk(KERN_ERR "kobject '%s' (%p): tried to add an "
"uninitialized object, something is seriously wrong.\n",
kobject_name(kobj), kobj);
dump_stack();
return -EINVAL;
}
va_start(args, fmt);
retval = kobject_add_varg(kobj, parent, fmt, args);
## kobject.c::kobject_add() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_varg() : kobj, fs
static int kobject_add_varg(struct kobject *kobj, struct kobject *parent,
const char *fmt, va_list vargs)
{
int retval;
retval = kobject_set_name_vargs(kobj, fmt, vargs);
## kobject.c::kobject_set_name_vargs() * call: start_kernel()->vfs_caches_init()->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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_varg() : kobj, fs - kobject_set_name_vargs()
int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
va_list vargs)
{
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL
const char *old_name = kobj->name;
// old_name: NULL
char *s;
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL, fmt: "%s"
if (kobj->name && !fmt)
return 0;
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
// kvasprintf(GFP_KERNEL: 0xD0, "%s", "fs"): kmem_cache
kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
## kasprintf.c::kvasspintf() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf()
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
va_copy(aq, ap);
* va_copy() 에서 한일 - aq: "fs" ## vspirntf.c:: kvasprintf() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf()
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
va_copy(aq, ap);
len = vsnprintf(NULL, 0, fmt, aq);
## vsprintf.c::kvasprintf() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf()
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
unsigned long long num;
char *str, *end;
struct printf_spec spec = {0};
if (WARN_ON_ONCE((int) size < 0))
return 0;
str = buf;
end = buf + size;
if (end < buf) {
end = ((void *)-1);
size = end - buf;
}
while (*fmt) {
const char *old_fmt = fmt;
int read = format_decode(fmt, &spec);
## vsprintf.c::format_decode() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf() - format_decode()
static noinline_for_stack
int format_decode(const char *fmt, struct printf_spec *spec)
{
const char *start = fmt;
if (spec->type == FORMAT_TYPE_WIDTH) {
if (spec->field_width < 0) {
spec->field_width = -spec->field_width;
spec->flags |= LEFT;
}
spec->type = FORMAT_TYPE_NONE;
goto precision;
}
if (spec->type == FORMAT_TYPE_PRECISION) {
if (spec->precision < 0)
spec->precision = 0;
spec->type = FORMAT_TYPE_NONE;
goto qualifier;
}
spec->type = FORMAT_TYPE_NONE;
for (; *fmt ; ++fmt) {
if (*fmt == '%')
break;
}
if (fmt != start || !*fmt)
return fmt - start;
spec->flags = 0;
while (1) {
bool found = true;
++fmt;
switch (*fmt) {
case '-': spec->flags |= LEFT; break;
case '+': spec->flags |= PLUS; break;
case ' ': spec->flags |= SPACE; break;
case '#': spec->flags |= SPECIAL; break;
case '0': spec->flags |= ZEROPAD; break;
default: found = false;
}
if (!found)
break;
}
spec->field_width = -1;
if (isdigit(*fmt))
spec->field_width = skip_atoi(&fmt);
else if (*fmt == '*') {
spec->type = FORMAT_TYPE_WIDTH;
return ++fmt - start;
}
precision:
spec->precision = -1;
if (*fmt == '.') {
++fmt;
if (isdigit(*fmt)) {
spec->precision = skip_atoi(&fmt);
if (spec->precision < 0)
spec->precision = 0;
} else if (*fmt == '*') {
spec->type = FORMAT_TYPE_PRECISION;
return ++fmt - start;
}
}
qualifier:
spec->qualifier = -1;
if (*fmt == 'h' || _tolower(*fmt) == 'l' ||
_tolower(*fmt) == 'z' || *fmt == 't') {
spec->qualifier = *fmt++;
if (unlikely(spec->qualifier == *fmt)) {
if (spec->qualifier == 'l') {
spec->qualifier = 'L';
++fmt;
} else if (spec->qualifier == 'h') {
spec->qualifier = 'H';
++fmt;
}
}
}
spec->base = 10;
switch (*fmt) {
case 'c':
spec->type = FORMAT_TYPE_CHAR;
return ++fmt - start;
case 's':
spec->type = FORMAT_TYPE_STR;
return ++fmt - start;
case 'p':
spec->type = FORMAT_TYPE_PTR;
return fmt - start;
case 'n':
spec->type = FORMAT_TYPE_NRCHARS;
return ++fmt - start;
case '%':
spec->type = FORMAT_TYPE_PERCENT_CHAR;
return ++fmt - start;
case 'o':
spec->base = 8;
break;
case 'x':
spec->flags |= SMALL;
case 'X':
spec->base = 16;
break;
case 'd':
case 'i':
spec->flags |= SIGN;
case 'u':
break;
default:
spec->type = FORMAT_TYPE_INVALID;
return fmt - start;
}
if (spec->qualifier == 'L')
spec->type = FORMAT_TYPE_LONG_LONG;
else if (spec->qualifier == 'l') {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_LONG;
else
spec->type = FORMAT_TYPE_ULONG;
} else if (_tolower(spec->qualifier) == 'z') {
spec->type = FORMAT_TYPE_SIZE_T;
} else if (spec->qualifier == 't') {
spec->type = FORMAT_TYPE_PTRDIFF;
} else if (spec->qualifier == 'H') {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_BYTE;
else
spec->type = FORMAT_TYPE_UBYTE;
} else if (spec->qualifier == 'h') {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_SHORT;
else
spec->type = FORMAT_TYPE_USHORT;
} else {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_INT;
else
spec->type = FORMAT_TYPE_UINT;
}
return ++fmt - start;
}
* format_decode에서 한일: - - (&spec)->type: 0 - (&spec)->flags: 0 - (&spec)->field_width: -1 - (&spec)->precision: -1 - (&spec)->qualifier: -1 - (&spec)->base: 10 ## vsprintf.c::kvasprintf() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf() - format_decode()
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
unsigned long long num;
char *str, *end;
struct printf_spec spec = {0};
if (WARN_ON_ONCE((int) size < 0))
return 0;
str = buf;
end = buf + size;
if (end < buf) {
end = ((void *)-1);
size = end - buf;
}
while (*fmt) {
const char *old_fmt = fmt;
int read = format_decode(fmt, &spec);
fmt += read;
switch (spec.type) {
case FORMAT_TYPE_NONE: {
int copy = read;
if (str < end) {
if (copy > end - str)
copy = end - str;
memcpy(str, old_fmt, copy);
}
str += read;
break;
}
case FORMAT_TYPE_WIDTH:
spec.field_width = va_arg(args, int);
break;
case FORMAT_TYPE_PRECISION:
spec.precision = va_arg(args, int);
break;
case FORMAT_TYPE_CHAR: {
char c;
if (!(spec.flags & LEFT)) {
while (--spec.field_width > 0) {
if (str < end)
*str = ' ';
++str;
}
}
c = (unsigned char) va_arg(args, int);
if (str < end)
*str = c;
++str;
while (--spec.field_width > 0) {
if (str < end)
*str = ' ';
++str;
}
break;
}
case FORMAT_TYPE_STR:
str = string(str, end, va_arg(args, char *), spec);
break;
case FORMAT_TYPE_PTR:
str = pointer(fmt+1, str, end, va_arg(args, void *),
spec);
while (isalnum(*fmt))
fmt++;
break;
case FORMAT_TYPE_PERCENT_CHAR:
if (str < end)
*str = '%';
++str;
break;
case FORMAT_TYPE_INVALID:
if (str < end)
*str = '%';
++str;
break;
case FORMAT_TYPE_NRCHARS: {
void *skip_arg;
WARN_ONCE(1, "Please remove ignored %%n in '%s'\n",
old_fmt);
skip_arg = va_arg(args, void *);
break;
}
default:
switch (spec.type) {
case FORMAT_TYPE_LONG_LONG:
num = va_arg(args, long long);
break;
case FORMAT_TYPE_ULONG:
num = va_arg(args, unsigned long);
break;
case FORMAT_TYPE_LONG:
num = va_arg(args, long);
break;
case FORMAT_TYPE_SIZE_T:
if (spec.flags & SIGN)
num = va_arg(args, ssize_t);
else
num = va_arg(args, size_t);
break;
case FORMAT_TYPE_PTRDIFF:
num = va_arg(args, ptrdiff_t);
break;
case FORMAT_TYPE_UBYTE:
num = (unsigned char) va_arg(args, int);
break;
case FORMAT_TYPE_BYTE:
num = (signed char) va_arg(args, int);
break;
case FORMAT_TYPE_USHORT:
num = (unsigned short) va_arg(args, int);
break;
case FORMAT_TYPE_SHORT:
num = (short) va_arg(args, int);
break;
case FORMAT_TYPE_INT:
num = (int) va_arg(args, int);
break;
default:
num = va_arg(args, unsigned int);
}
str = number(str, end, num, spec);
}
}
if (size > 0) {
if (str < end)
*str = '\0';
else
end[-1] = '\0';
}
return str-buf;
}
EXPORT_SYMBOL(vsnprintf);
## kasprintf.c::kvasprintf() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf() - format_decode()
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
va_copy(aq, ap);
len = vsnprintf(NULL, 0, fmt, aq);
va_end(aq);
* va_end(aq);
#define va_end(ap) (ap = (va_list) NULL)
* va_end에서 한일: - aq: NULL
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
va_copy(aq, ap);
len = vsnprintf(NULL, 0, fmt, aq);
va_end(aq);
p = kmalloc_track_caller(len+1, gfp);
## slab.h::kmalloc_track_caller() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf() - va_copy() - vsnprintf() - format_decode() - va_end() - kmalloc_track_caller()
#define kmalloc_track_caller(size, flags) \
__kmalloc_track_caller(size, flags, _RET_IP_)
void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller)
{
struct kmem_cache *s;
void *ret;
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
return kmalloc_large(size, gfpflags);
s = kmalloc_slab(size, gfpflags);
if (unlikely(ZERO_OR_NULL_PTR(s)))
return s;
ret = slab_alloc(s, gfpflags, caller);
trace_kmalloc(caller, ret, size, s->size, gfpflags);
return ret;
}
## kasprintf.c::kvasprintf() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf() - va_copy() - vsnprintf() - format_decode() - va_end() - kmalloc_track_caller() - kvasprintf()
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
va_copy(aq, ap);
len = vsnprintf(NULL, 0, fmt, aq);
va_end(aq);
p = kmalloc_track_caller(len+1, gfp);
if (!p)
return NULL;
vsnprintf(p, len+1, fmt, ap);
return p;
}
EXPORT_SYMBOL(kvasprintf);
## kobject.c::kobject_set_name_vargs() * call: start_kernel()->vfs_caches_init() - 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 - kobject_create() - kobject_init() - kobject_init_internal() : kobj - kobject_add() - va_start() - kobject_add_vargs() : kobj, fs - kobject_set_name_vargs() - kvasprintf() - va_copy() - vsnprintf() - format_decode() - va_end() - kmalloc_track_caller() - kvasprintf() - ret: kobject_set_name_vargs()
// ARM10C 20160109
// kobj: kmem_cache
int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
va_list vargs)
{
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL
const char *old_name = kobj->name;
// old_name: NULL
char *s;
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL, fmt: "%s"
if (kobj->name && !fmt)
return 0;
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
// kvasprintf(GFP_KERNEL: 0xD0, "%s", "fs"): kmem_cache
kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: kmem_cache
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: kmem_cache
if (!kobj->name)
return -ENOMEM;
// 2016/01/09 종료
* kernel object - .ko로 확장자로 끝나는 파일들. - kernel 2.6 이후 사용. ## log * 1st log
c68141d..7b4f179 master -> origin/master
Updating c68141d..7b4f179
Fast-forward
fs/dcache.c | 276 ++++++++++++++++++++++-----------------------
fs/inode.c | 458 +++++++++++++++++++++++++++++++++++++-------------------------------------
fs/mount.h | 24 ++++
fs/namespace.c | 626 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
fs/super.c | 218 ++++++++++++++++++------------------
fs/sysfs/inode.c | 222 ++++++++++++++++++------------------
fs/sysfs/mount.c | 814 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------
include/linux/err.h | 9 ++
include/linux/fs.h | 1 +
include/linux/kernel.h | 1 +
include/linux/list.h | 2 +
include/linux/lockdep.h | 2 +
include/linux/seqlock.h | 126 +++++++++++++++++++++
include/linux/spinlock.h | 4 +
include/linux/spinlock_types.h | 12 ++
include/uapi/asm-generic/errno-base.h | 1 +
16 files changed, 1872 insertions(+), 924 deletions(-)
* 2nd log
7b4f179..f8705f2 master -> origin/master
Updating 7b4f179..f8705f2
Fast-forward
README.md | 3 +
fs/namespace.c | 425 ++++++++++++++++++++++++++++++++++++++
include/acpi/actypes.h | 5 +-
include/acpi/platform/acenv.h | 14 ++
include/acpi/platform/aclinux.h | 3 +
include/asm-generic/bitsperlong.h | 1 +
include/linux/ctype.h | 13 ++
include/linux/gfp.h | 1 +
include/linux/kobject.h | 2 +
include/linux/kref.h | 2 +
include/linux/list.h | 2 +
include/linux/slab.h | 4 +
lib/ctype.c | 1 +
lib/kasprintf.c | 25 +++
lib/kobject.c | 118 +++++++++++
lib/vsprintf.c | 91 +++++++-
mm/slub.c | 2 +
17 files changed, 708 insertions(+), 4 deletions(-)