函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\zsmalloc.c Create Date:2022-07-27 18:03:18
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:zs_create_pool - Creates an allocation pool to work from.*@name: pool name to be created* This function must be called before anything when using* the zsmalloc allocator.* On success, a pointer to the newly created pool is returned,* otherwise NULL.

函数原型:struct zs_pool *zs_create_pool(const char *name)

返回类型:struct zs_pool

参数:

类型参数名称
const char *name
2405  struct size_class * prev_class = NULL
2407  pool等于分配内存并置零
2408  如果非pool则返回:NULL
2411  init_deferred_free(pool)
2413  name等于kstrdup - allocate space for and copy an existing string*@s: the string to duplicate*@gfp: the GFP mask used in the kmalloc() call when allocating memory* Return: newly allocated copy of @s or %NULL in case of error
2414  如果非name则转到:err
2421  如果create_cache(pool)则转到:err
2428 i大于等于0循环
2433  fullness等于0
2435  size等于ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN iOn systems with 4K page size, this gives 255 size classes! There is a* trader-off here:* - Large number of size classes is potentially wasteful as free page are* spread across these classes* - Small number of size classes causes large internal
2436  如果size大于ach chunk includes extra space to keep handle size等于ach chunk includes extra space to keep handle
2438  pages_per_zspage等于We have to decide on how many pages to link together* to form a zspage for each size class. This is important* to reduce wastage due to unusable space left at end of* each zspage which is given as:* wastage = Zp % class_size* usage = Zp - wastage
2439  objs_per_zspage等于pages_per_zspagePAGE_SIZEsize
2447  如果pages_per_zspage不等于1且objs_per_zspage不等于1且非huge_class_size
2449  huge_class_size等于size
2459  huge_class_size减等于ZS_HANDLE_SIZE减1
2471  如果prev_class
2473  size_class[i]等于prev_class
2474  继续下一循环
2478  class等于分配内存并置零
2479  如果非class则转到:err
2482  * Size of objects stored in this class. Must be multiple * of ZS_ALIGN.等于size
2483  index等于i
2484  Number of PAGE_SIZE sized pages to combine to form a 'zspage' 等于pages_per_zspage
2485  objs_per_zspage等于objs_per_zspage
2486  spin_lock_init( & lock)
2487  size_class[i]等于class
2488 fullness小于NR_ZS_FULLNESS循环初始化链表头
2492  prev_class等于class
2496  zs_pool_stat_create(pool, name)
2498  如果zs_register_migration(pool)则转到:err
2507  zs_register_shrinker(pool)
2509  返回:pool
2511  err :
2512  zs_destroy_pool(pool)
2513  返回:NULL
调用者
名称描述
zs_zpool_createzpool driver