Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:zbud_alloc() - allocates a region of a given size*@pool: zbud pool from which to allocate*@size: size in bytes of the desired allocation*@gfp: gfp flags used if the pool needs to grow*@handle: handle of the new allocation* This function will attempt to

Proto:int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, unsigned long *handle)

Type:int

Parameter:

TypeParameterName
struct zbud_pool *pool
size_tsize
gfp_tgfp
unsigned long *handle
358  struct zbud_header * zhdr = NULL
362  If Not size || gfp & __GFP_HIGHMEM Then Return -EINVAL
364  If size > PAGE_SIZE - ZHDR_SIZE_ALIGNED - CHUNK_SIZE Then Return -ENOSPC
366  chunks = Converts an allocation size in bytes to size in zbud chunks
367  spin_lock( & lock)
370  zhdr = NULL
372  If Not list_empty - tests whether a list is empty*@head: the list to test. Then
373  zhdr = list_first_entry - get the first element from a list*@ptr: the list head to take the element from.*@type: the type of the struct this is embedded in.*@member: the name of the list_head within the struct.* Note, that list is expected to be not empty.( & unbuddied[i], structzbud_header, buddy)
375  deletes entry from list
376  If first_chunks == 0 Then bud = FIRST
378  Else bud = LAST
380  Go to found
385  spin_unlock( & lock)
386  page = alloc_page(gfp)
387  If Not page Then Return -ENOMEM
389  spin_lock( & lock)
390  pages_nr++
391  zhdr = Initializes the zbud header of a newly allocated zbud page
392  bud = FIRST
394  found :
395  If bud == FIRST Then first_chunks = chunks
397  Else last_chunks = chunks
400  If first_chunks == 0 || last_chunks == 0 Then
402  freechunks = Returns the number of free chunks in a zbud page
403  list_add - add a new entry*@new: new entry to be added*@head: list head to add it after* Insert a new entry after the specified head.* This is good for implementing stacks.
404  Else
406  list_add - add a new entry*@new: new entry to be added*@head: list head to add it after* Insert a new entry after the specified head.* This is good for implementing stacks.
410  If Not list_empty - tests whether a list is empty*@head: the list to test. Then deletes entry from list
412  list_add - add a new entry*@new: new entry to be added*@head: list head to add it after* Insert a new entry after the specified head.* This is good for implementing stacks.
414  handle = Encodes the handle of a particular buddy within a zbud page* Pool lock should be held as this function accesses first|last_chunks
415  spin_unlock( & lock)
417  Return 0
Caller
NameDescribe
zbud_zpool_malloc