Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:zs_malloc - Allocate block of given size from pool.*@pool: pool to allocate from*@size: size of block to allocate*@gfp: gfp flags when allocating object* On success, handle to the allocated object is returned,* otherwise 0.

Proto:unsigned long zs_malloc(struct zs_pool *pool, size_t size, gfp_t gfp)

Type:unsigned long

Parameter:

TypeParameterName
struct zs_pool *pool
size_tsize
gfp_tgfp
1466  If Value for the false possibility is greater at compile time(!size || size > ach chunk includes extra space to keep handle ) Then Return 0
1469  handle = cache_alloc_handle(pool, gfp)
1470  If Not handle Then Return 0
1474  size += ZS_HANDLE_SIZE
1475  class = size_class[zsmalloc divides the pool into various size classes where each* class maintains a list of zspages where each zspage is divided* into equal sized chunks. Each allocation falls into one of these* classes depending on its size]
1477  spin_lock( & lock)
1478  zspage = find_get_zspage(class)
1479  If Value is more likely to compile time(zspage) Then
1480  obj = obj_malloc(class, zspage, handle)
1482  Each size class maintains zspages in different fullness groups depending* on the number of live objects they contain. When allocating or freeing* objects, the fullness status of the page can change, say, from ALMOST_FULL
1483  record_obj(handle, obj)
1484  spin_unlock( & lock)
1486  Return handle
1489  spin_unlock( & lock)
1491  zspage = Allocate a zspage for the given size class
1492  If Not zspage Then
1493  cache_free_handle(pool, handle)
1494  Return 0
1497  spin_lock( & lock)
1498  obj = obj_malloc(class, zspage, handle)
1499  newfg = For each size class, zspages are divided into different groups* depending on how "full" they are. This was done so that we could* easily find empty or nearly empty zspages when we try to shrink* the pool (not yet implemented)
1500  Each size class maintains various freelists and zspages are assigned* to one of these freelists based on the number of live objects they* have. This functions inserts the given zspage into the freelist* identified by .
1501  set_zspage_mapping(zspage, index, newfg)
1502  record_obj(handle, obj)
1503  atomic_long_add( Number of PAGE_SIZE sized pages to combine to form a 'zspage' , & pages_allocated)
1505  ype can be of enum type zs_stat_type or fullness_group
1508  SetZsPageMovable(pool, zspage)
1509  spin_unlock( & lock)
1511  Return handle
Caller
NameDescribe
zs_zpool_malloc