Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:obj_malloc

Proto:static unsigned long obj_malloc(struct size_class *class, struct zspage *zspage, unsigned long handle)

Type:unsigned long

Parameter:

TypeParameterName
struct size_class *class
struct zspage *zspage
unsigned longhandle
1418  handle |= Head in allocated object should have OBJ_ALLOCATED_TAG* to identify the object was allocated or not.* It's okay to add the status bit in the least bit because* header keeps handle which is 4byte-aligned address so we* have room for two bit at least.
1419  obj = get_freeobj(zspage)
1421  offset = obj * * Size of objects stored in this class. Must be multiple * of ZS_ALIGN.
1422  nr_page = offset >> PAGE_SHIFT determines the page size
1423  m_offset = offset & ~PAGE_MASK
1424  m_page = get_first_page(zspage)
1426  When i < nr_page cycle m_page = get_next_page(m_page)
1429  vaddr = kmap_atomic(m_page)
1430  link = vaddr + m_offset / size of link
1431  set_freeobj(zspage, Free object index;* It's valid for non-allocated object >> OBJ_TAG_BITS)
1432  If Value is more likely to compile time(!PageHugeObject(m_page)) Then Handle of allocated object. = handle
1435  Else Our offset within mapping. = handle
1439  Prevent people trying to call kunmap_atomic() as if it were kunmap()* kunmap_atomic() should get the return value of kmap_atomic, not the page.(vaddr)
1440  mod_zspage_inuse(zspage, 1)
1441  ype can be of enum type zs_stat_type or fullness_group
1443  obj = location_to_obj - get obj value encoded from (, )*@page: page object resides in zspage*@obj_idx: object index
1445  Return obj
Caller
NameDescribe
zs_malloczs_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.
migrate_zspage