CPC G06F 9/5016 (2013.01) [G06F 9/544 (2013.01); G06F 12/023 (2013.01); G06F 12/0292 (2013.01); G06F 2212/1016 (2013.01)] | 20 Claims |
1. A method for managing a shared memory, comprising:
setting one core of a system to be a master core, and setting remaining cores to be slave cores; applying, by the master core, to the system for a threshold quantity of idle hugepage blocks, mapping all of the idle hugepage blocks to a virtual address space of the master core, and sorting the hugepage blocks in an ascending order of physical address size of the hugepage blocks;
dividing, according to whether the physical addresses are continuous, the hugepage blocks sorted in the ascending order into segments, and determining whether segments satisfying a memory demand of a subsystem exist among all of the segments;
in response to determining that segments satisfying the memory demand of the subsystem exist among all of the segments, sorting the segments satisfying the memory demand of the subsystem in a descending order of lengths, and re-mapping the segments sorted to obtain several segments having both continuous intra-segment virtual addresses and continuous intra-segment physical addresses;
in response to determining that a segment satisfying a memory demand of the system exists among the several segments having both continuous intra-segment virtual addresses and continuous intra-segment physical addresses, releasing hugepage blocks other than the segment satisfying the memory demand of the system; and
applying for a control plane shared memory, storing a virtual address of a data plane shared memory into a relevant data pointer of the control plane shared memory, setting a master-slave synchronization mark for initialization process, and starting up initialization of the slave cores based on the synchronization mark.
|