| Function report | 
| Source Code: mm\percpu.c | Create Date:2022-07-28 14:27:19 | 
| Last Modify:2022-05-23 13:52:24 | Copyright©Brick | 
| home page | Tree | 
| Annotation kernel can get tool activity | Download SCCT | Chinese | 
Name:pcpu_alloc - the percpu allocator*@size: size of area to allocate in bytes*@align: alignment of area (max PAGE_SIZE)*@reserved: allocate from the reserved chunk if available*@gfp: allocation flags* Allocate percpu area of @size bytes aligned at @align
Proto:static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, gfp_t gfp)
Type:void
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| size_t | size | |
| size_t | align | |
| bool | reserved | |
| gfp_t | gfp | 
| 1591 | is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL | 
| 1593 | warn_limit = 10 | 
| 1607 | If Value for the false possibility is greater at compile time(align < PCPU_MIN_ALLOC_SIZE) Then align = PCPU_MIN_ALLOC_SIZE | 
| 1610 | size = @a is a power of 2 value (size, PCPU_MIN_ALLOC_SIZE) | 
| 1618 | Return NULL | 
| 1621 | If Not is_atomic Then | 
| 1627 | If gfp & __GFP_NOFAIL Then mutex_lock( & pcpu_alloc_mutex) | 
| 1629 | Else if mutex_lock_killable( & pcpu_alloc_mutex) Then Return NULL | 
| 1633 | spin_lock_irqsave( & pcpu_lock, flags) | 
| 1637 | chunk = Optional reserved chunk. This chunk reserves part of the first* chunk and serves it for reserved allocations. When the reserved* region doesn't exist, the following variable is NULL. | 
| 1640 | If off < 0 Then | 
| 1641 | err = "alloc from reserved chunk failed" | 
| 1642 | Go to fail_unlock | 
| 1646 | If off >= 0 Then Go to area_found | 
| 1649 | err = "alloc from reserved chunk failed" | 
| 1650 | Go to fail_unlock | 
| 1653 | restart : | 
| 1655 | When slot < pcpu_nr_slots cycle | 
| 1659 | If off < 0 Then | 
| 1660 | If slot < chunks in slots below this are subject to being sidelined on failed alloc Then pcpu_chunk_move(chunk, 0) | 
| 1662 | Continue | 
| 1666 | If off >= 0 Then Go to area_found | 
| 1672 | spin_unlock_irqrestore( & pcpu_lock, flags) | 
| 1679 | If is_atomic Then | 
| 1685 | chunk = pcpu_create_chunk(pcpu_gfp) | 
| 1686 | If Not chunk Then | 
| 1691 | spin_lock_irqsave( & pcpu_lock, flags) | 
| 1693 | Else | 
| 1694 | spin_lock_irqsave( & pcpu_lock, flags) | 
| 1697 | Go to restart | 
| 1699 | area_found : | 
| 1700 | pcpu_stats_area_alloc(chunk, size) | 
| 1701 | spin_unlock_irqrestore( & pcpu_lock, flags) | 
| 1704 | If Not is_atomic Then | 
| 1707 | page_start = PFN_DOWN(off) | 
| 1712 | WARN_ON( no [de]population allowed ) | 
| 1716 | spin_lock_irqsave( & pcpu_lock, flags) | 
| 1717 | If ret Then | 
| 1719 | err = "failed to populate" | 
| 1720 | Go to fail_unlock | 
| 1723 | spin_unlock_irqrestore( & pcpu_lock, flags) | 
| 1729 | If The number of empty populated pages, protected by pcpu_lock. The* reserved chunk doesn't contribute to the count. < PCPU_EMPTY_POP_PAGES_LOW Then pcpu_schedule_balance_work() | 
| 1733 | for_each_possible_cpu(cpu) | 
| 1737 | kmemleak_alloc_percpu(ptr, size, gfp) | 
| 1739 | trace_percpu_alloc_percpu(reserved, is_atomic, size, align, base address of this chunk , off, ptr) | 
| 1742 | Return ptr | 
| 1744 | fail_unlock : | 
| 1745 | spin_unlock_irqrestore( & pcpu_lock, flags) | 
| 1746 | fail : | 
| 1749 | If Not is_atomic && do_warn && warn_limit Then | 
| 1752 | dump_stack() | 
| 1753 | If Not --warn_limit Then pr_info("limit reached, disable warning\n") | 
| 1756 | If is_atomic Then | 
| 1758 | pcpu_atomic_alloc_failed = true | 
| 1759 | pcpu_schedule_balance_work() | 
| 1760 | Else | 
| 1763 | Return NULL | 
| Name | Describe | 
|---|---|
| __alloc_percpu_gfp | __alloc_percpu_gfp - allocate dynamic percpu area*@size: size of area to allocate in bytes*@align: alignment of area (max PAGE_SIZE)*@gfp: allocation flags* Allocate zero-filled percpu area of @size bytes aligned at @align | 
| __alloc_percpu | allocate one copy of the object for every present | 
| __alloc_reserved_percpu | __alloc_reserved_percpu - allocate reserved percpu area*@size: size of area to allocate in bytes*@align: alignment of area (max PAGE_SIZE)* Allocate zero-filled percpu area of @size bytes aligned at @align* from reserved percpu area if arch has set it up; | 
| 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 |