Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\zsmalloc.c Create Date:2022-07-28 16:28:23
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name: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.

Proto:struct zs_pool *zs_create_pool(const char *name)

Type:struct zs_pool

Parameter:

TypeParameterName
const char *name
2405  struct size_class * prev_class = NULL
2407  pool = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
2408  If Not pool Then Return 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  If Not name Then Go to err
2421  If create_cache(pool) Then Go to err
2428  When i >= 0 cycle
2433  fullness = 0
2435  size = ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN + i * On 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  If size > ach chunk includes extra space to keep handle Then 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_zspage * PAGE_SIZE / size
2447  If pages_per_zspage != 1 && objs_per_zspage != 1 && Not huge_class_size Then
2471  If prev_class Then
2473  size_class[i] = prev_class
2474  Continue
2478  class = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
2479  If Not class Then Go to 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  Process spin lock initialization( & lock)
2487  size_class[i] = class
2488  When fullness < NR_ZS_FULLNESS cycle Initialization list head
2492  prev_class = class
2496  zs_pool_stat_create(pool, name)
2498  If zs_register_migration(pool) Then Go to err
2507  zs_register_shrinker(pool)
2509  Return pool
2511  err :
2512  zs_destroy_pool(pool)
2513  Return NULL
Caller
NameDescribe
zs_zpool_createzpool driver