Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\percpu.c Create Date:2022-07-28 14:26:40
Last Modify:2022-05-23 13:52:24 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:pcpu_alloc_first_chunk - creates chunks that serve the first chunk*@tmp_addr: the start of the region served*@map_size: size of the region served* This is responsible for creating the chunks that serve the first chunk

Proto:static struct pcpu_chunk *__init pcpu_alloc_first_chunk(unsigned long tmp_addr, int map_size)

Type:struct pcpu_chunk

Parameter:

TypeParameterName
unsigned longtmp_addr
intmap_size
1317  aligned_addr = tmp_addr & PAGE_MASK
1319  start_offset = tmp_addr - aligned_addr
1326  lcm_align = Lowest common multiple
1327  region_size = @a is a power of 2 value (start_offset + map_size, lcm_align)
1330  alloc_size = sizeof(structpcpu_chunk) + BITS_TO_LONGS(region_size >> PAGE_SHIFT determines the page size )
1332  chunk = memblock_alloc(alloc_size, SMP_CACHE_BYTES)
1333  If Not chunk Then panic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
1337  Initialization list head
1339  base address of this chunk = aligned_addr
1340  the overlap with the previous region to have a page aligned base_addr = start_offset
1341  additional area required to have the region end page aligned = region_size - the overlap with the previous region to have a page aligned base_addr - map_size
1343  # of pages served by this chunk = region_size >> PAGE_SHIFT determines the page size
1344  region_bits = pcpu_chunk_map_bits - helper to convert nr_pages to size of bitmap*@chunk: chunk of interest* This conversion is from the number of physical pages that the chunk* serves to the number of bits in the bitmap.
1346  alloc_size = BITS_TO_LONGS(region_bits) * size of allocation map [0]
1347  allocation map = memblock_alloc(alloc_size, SMP_CACHE_BYTES)
1348  If Not allocation map Then panic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
1352  alloc_size = BITS_TO_LONGS(region_bits + 1) * size of boundary map [0]
1354  boundary map = memblock_alloc(alloc_size, SMP_CACHE_BYTES)
1355  If Not boundary map Then panic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
1359  alloc_size = pcpu_chunk_nr_blocks - converts nr_pages to # of md_blocks*@chunk: chunk of interest* This conversion is from the number of physical pages that the chunk* serves to the number of bitmap blocks used. * size of metadata blocks [0]
1360  metadata blocks = memblock_alloc(alloc_size, SMP_CACHE_BYTES)
1361  If Not metadata blocks Then panic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
1365  pcpu_init_md_blocks(chunk)
1368  no [de]population allowed = true
1369  bitmap_fill( populated bitmap , # of pages served by this chunk )
1370  # of populated pages = # of pages served by this chunk
1371  # of empty populated pages = # of pages served by this chunk
1373  free bytes in the chunk = map_size
1375  If the overlap with the previous region to have a page aligned base_addr Then
1377  offset_bits = the overlap with the previous region to have a page aligned base_addr / PCPU_MIN_ALLOC_SIZE
1378  bitmap_set( allocation map , 0, offset_bits)
1379  Atomically set a bit in memory
1380  Atomically set a bit in memory
1382  lock position of first free = offset_bits
1384  pcpu_block_update_hint_alloc - update hint on allocation path*@chunk: chunk of interest*@bit_off: chunk offset*@bits: size of request* Updates metadata for the allocation path. The metadata only has to be
1387  If additional area required to have the region end page aligned Then
1389  offset_bits = additional area required to have the region end page aligned / PCPU_MIN_ALLOC_SIZE
1390  bitmap_set( allocation map , pcpu_chunk_map_bits - helper to convert nr_pages to size of bitmap*@chunk: chunk of interest* This conversion is from the number of physical pages that the chunk* serves to the number of bits in the bitmap. - offset_bits, offset_bits)
1393  Atomically set a bit in memory
1395  Atomically set a bit in memory
1397  pcpu_block_update_hint_alloc - update hint on allocation path*@chunk: chunk of interest*@bit_off: chunk offset*@bits: size of request* Updates metadata for the allocation path. The metadata only has to be
1401  Return chunk
Caller
NameDescribe
pcpu_setup_first_chunkpcpu_setup_first_chunk - initialize the first percpu chunk*@ai: pcpu_alloc_info describing how to percpu area is shaped*@base_addr: mapped address* Initialize the first percpu chunk which contains the kernel static* percpu area