函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\cma.c Create Date:2022-07-27 18:07:21
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:ma_alloc() - allocate pages from contiguous area*@cma: Contiguous memory region for which the allocation is performed

函数原型:struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, bool no_warn)

返回类型:struct page

参数:

类型参数名称
struct cma *cma
size_tcount
unsigned intalign
boolno_warn
419  pfn等于负1
420  start等于0
423  struct page * page = NULL
424  ret等于负ENOMEM
426  如果非cma或非count则返回:NULL
429  pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void * )cma, count, align)
432  如果非count则返回:NULL
435  mask等于cma_bitmap_aligned_mask(cma, align)
436  offset等于Find the offset of the base PFN from the specified align_order.* The value returned is represented in order_per_bits.
437  bitmap_maxno等于cma_bitmap_maxno(cma)
438  bitmap_count等于cma_bitmap_pages_to_bits(cma, count)
440  如果bitmap_count大于bitmap_maxno则返回:NULL
443  循环
444  mutex_lock( & lock)
445  bitmap_no等于map_find_next_zero_area_off - find a contiguous aligned zero area*@map: The address to base the search on*@size: The bitmap size in bits*@start: The bitnumber to start searching at*@nr: The number of zeroed bits we're looking for*@align_mask: Alignment
448  如果bitmap_no大于等于bitmap_maxno
450  退出
452  bitmap_set(bitmap, bitmap_no, bitmap_count)
458  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
460  pfn等于base_pfnbitmap_no左移 Order of pages represented by one bit 位的值
461  mutex_lock( & cma_mutex)
462  ret等于alloc_contig_range(pfn, pfn + count, MIGRATE_CMA, GFP_KERNEL | (no_warn ? DOC: Action modifiers* Action modifiers* ~~~~~~~~~~~~~~~~* %__GFP_NOWARN suppresses allocation failure reports.* %__GFP_COMP address compound page metadata.* %__GFP_ZERO returns a zeroed page on success. : 0))
464  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
465  如果ret恒等于0则
466  page等于pfn_to_page(pfn)
467  退出
470  cma_clear_bitmap(cma, pfn, count)
471  如果ret不等于负EBUSY退出
474  pr_debug("%s(): memory range at %p is busy, retrying\n", __func__, pfn_to_page(pfn))
477  start等于bitmap_nomask加1
480  trace_cma_alloc(pfn, page, count, align)
487  如果page
488 i小于count循环page_kasan_tag_reset(page + i)
492  如果ret且非no_warn
493  打印错误信息("%s: alloc failed, req-size: %zu pages, ret: %d\n", __func__, count, ret)
495  cma_debug_show_areas(cma)
498  pr_debug("%s(): returned %p\n", __func__, page)
499  返回:page
调用者
名称描述
dma_alloc_contiguousdma_alloc_contiguous() - allocate contiguous pages*@dev: Pointer to device for which the allocation is performed
cma_alloc_mem
dma_alloc_from_contiguousdma_alloc_from_contiguous() - allocate pages from contiguous area*@dev: Pointer to device for which the allocation is performed.*@count: Requested number of pages.*@align: Requested alignment of pages (in PAGE_SIZE order).