Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

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

Proto:struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, bool no_warn)

Type:struct page

Parameter:

TypeParameterName
struct cma *cma
size_tcount
unsigned intalign
boolno_warn
419  pfn = -1
420  start = 0
423  struct page * page = NULL
424  ret = -ENOMEM
426  If Not cma || Not count Then Return NULL
429  pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void * )cma, count, align)
432  If Not count Then Return 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  If bitmap_count > bitmap_maxno Then Return NULL
443  cycle
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  If bitmap_no >= bitmap_maxno Then
450  Break
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_pfn + (bitmap_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  If ret == 0 Then
466  page = pfn_to_page(pfn)
467  Break
470  cma_clear_bitmap(cma, pfn, count)
471  If ret != -EBUSY Then Break
474  pr_debug("%s(): memory range at %p is busy, retrying\n", __func__, pfn_to_page(pfn))
477  start = bitmap_no + mask + 1
480  trace_cma_alloc(pfn, page, count, align)
487  If page Then
488  When i < count cycle page_kasan_tag_reset(page + i)
492  If ret && Not no_warn Then
493  pr_err("%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  Return page
Caller
NameDescribe
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).