Function report |
Source Code:mm\z3fold.c |
Create Date:2022-07-28 16:30:06 |
Last Modify:2020-03-12 14:18:49 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:z3fold_alloc() - allocates a region of a given size*@pool: z3fold 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
Proto:static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, unsigned long *handle)
Type:int
Parameter:
Type | Parameter | Name |
---|---|---|
struct z3fold_pool * | pool | |
size_t | size | |
gfp_t | gfp | |
unsigned long * | handle |
1093 | struct z3fold_header * zhdr = NULL |
1096 | can_sleep = gfpflags_allow_blocking(gfp) |
1104 | If size > PAGE_SIZE - ZHDR_SIZE_ALIGNED - CHUNK_SIZE Then bud = HEADLESS |
1106 | Else |
1107 | retry : |
1109 | If zhdr Then |
1110 | If first_chunks == 0 Then |
1111 | If middle_chunks != 0 && chunks >= start_middle Then bud = LAST |
1116 | Else if last_chunks == 0 Then bud = LAST |
1118 | Else if middle_chunks == 0 Then bud = MIDDLE |
1120 | Else |
1124 | Else Unlock a z3fold page |
1126 | pr_err("No free chunks in unbuddied\n") |
1127 | WARN_ON(1) |
1128 | Go to retry |
1130 | page = virt_to_page(kaddr) returns a valid pointer if and only if* virt_addr_valid(kaddr) returns true.(zhdr) |
1131 | Go to found |
1136 | page = NULL |
1137 | If can_sleep Then |
1138 | spin_lock( & stale_lock) |
1146 | If zhdr Then |
1148 | spin_unlock( & stale_lock) |
1151 | Else |
1152 | spin_unlock( & stale_lock) |
1155 | If Not page Then page = alloc_page(gfp) |
1162 | If Not zhdr Then |
1163 | __free_page(page) |
1164 | Return -ENOMEM |
1166 | atomic64_inc( & pages_nr) |
1170 | Go to headless |
1172 | If can_sleep Then |
1174 | __SetPageMovable(page, i_mapping) |
1176 | Else |
1177 | If Return true if the page was successfully locked Then |
1178 | __SetPageMovable(page, i_mapping) |
1182 | Lock a z3fold page |
1184 | found : |
1185 | If bud == FIRST Then first_chunks = chunks |
1187 | Else if bud == LAST Then last_chunks = chunks |
1189 | Else |
1190 | middle_chunks = chunks |
1191 | start_middle = first_chunks + ZHDR_CHUNKS |
1195 | headless : |
1198 | If Not list_empty - tests whether a list is empty*@head: the list to test. Then deletes entry from list |
1203 | handle = encode_handle(zhdr, bud) |
1204 | spin_unlock( & lock) |
1205 | If bud != HEADLESS Then Unlock a z3fold page |
1208 | Return 0 |
Name | Describe |
---|---|
z3fold_zpool_malloc |
Source code conversion tool public plug-in interface | X |
---|---|
Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |