CN106484632A - The method distributing continuous physical memory in linux system user's space - Google Patents
The method distributing continuous physical memory in linux system user's space Download PDFInfo
- Publication number
- CN106484632A CN106484632A CN201510551977.7A CN201510551977A CN106484632A CN 106484632 A CN106484632 A CN 106484632A CN 201510551977 A CN201510551977 A CN 201510551977A CN 106484632 A CN106484632 A CN 106484632A
- Authority
- CN
- China
- Prior art keywords
- physical memory
- distribution
- space
- mapping
- page
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Abstract
The present invention is a kind of method distributing continuous physical memory in linux system user's space, including initialization step and distribution continuous physical memory step, wherein at least includes the mapping allocation step of 2 user's spaces and physical memory in initialization step.The present invention achieves the buddy algorithm of physical memory distribution in linux system user's space, do not change linux kernel and realize continuous physical memory distribution and manage, the linux system running on supporting paging platform can be realized, highly versatile, and is not need to rely on specific hardware.
Description
Technical field
The present invention relates to control field is paid in network application, particularly to a kind of in the linux system supporting paging
User's space distributes the universal method of continuous physical memory.
Background technology
Linux system is a set of free class Unix operating system using with Free propagation, is one and is based on
The multi-user of POSIX and UNIX, the operating system of multitask, support multithreading and multi -CPU.It can run
Main unix tool software, application program and procotol.It supports 32 and 64 hardware.Linux
Inherit the design philosophy with network as core for the Unix, be the multiple-user network operating system of a stable performance.
Linux system itself will be divided into two parts, and a part is kernel software (kernel), and also referred to as kernel is empty
Between;Another part is common applications, and this part is referred to as user's space (Userspace).User's space
In code operate on relatively low privilege level, can only see allow they use part system resource,
And some specific systemic-functions can not be used, nor direct access kernel space and hardware device, with
And some other specific using limit.
ICP/IP protocol stack (TCP/IP Protocol Stack) is a network communication model, or claims one
Whole network host-host protocol family, is the basic communication framework of the Internet.Two cores of this agreement family
Agreement, including TCP (transmission control protocol) and IP (Internet protocol), passes through earliest in this family
Standard.Due to the structure in the commonly used layering of network communication protocol, when the common work of the agreement of many levels
Storehouse when making, in similar computer science.ICP/IP protocol stack is placed on linux system user's space
(userspace) come to run be a kind of technological trend, some advantages that arise therefrom has a lot, for example:Due to not
Need to change linux kernel source code so whole system can be made more stable, do not result in whole operation system
(Operating System, abbreviation OS's) restarts the service disruption in turn resulting in system external offer.Separately
Outward, run ICP/IP protocol stack in linux system user's space and be also avoided that GPL (General Public
The general public mandate of License, GNU), thus protecting the Software Intellectual Property Rights that company has by oneself.
As above, if ICP/IP protocol stack is placed on the user's space in linux system run, one urgently solves
Problem certainly is:How to realize the packet receiving (transmit packet) of network interface card in user's space and give out a contract for a project
(receive packet).The open scheme of prior art mainly has two kinds:Netmap and DPDK (Intel
Data Plane Development Kit, Intel datum plane development kit).First, Netmap side
The design object of case is the fast-forwarding of L2/L3/L4 layer, is difficult to when bringing the load balancing doing L4/L7 layer
Avoid memory copying, thus the high-performance under big flow cannot be realized, the application ring that do not considered in the present invention
Border;Second, the test result of DPDK proves to want the high-performance obtaining the network operation it is necessary in Linux
The user's space of system carries out DMA (direct memory access, Direct Memory Access) operation to network interface card..
DPDK can be implemented in user's space distribution continuous physical memory using Huge page, but, the side of DPDK
Case is necessarily dependent upon the support of huge page (huge page), and processor must provide for the huge page of 2M or 1G,
Can only realize in part CPU at present, a lot of low side CPU are not support huge page.
Further, distribute continuous physical memory by huge page method in user's space and generally adopt partner
Algorithm.The buddy algorithm of Linux is all of for user's space free page to be divided into 10 block groups, in every group
The size of block is the 2 power side page, and for example, in the 0th group, the size of block is all 20(1 page),
In 1st group, the size of block is to be all 21(2 pages), in the 9th group, the size of block is all 29(512 pages
Face).That is, the size of block is identical in each group, and one chain of this equal amount of piece formation
Table.The objective of buddy system is exactly to meet the request for internal memory of kernel with minimum memory block.
Content of the invention
For overcoming problem present in prior art, the present invention proposes and devises one kind not relying on huge
Page distributes the universal method of continuous physical memory so that any operation on linux system user's space
Linux system on the CPU supporting paging can be realized distributing continuous physical memory in user's space.
For achieving the above object, the present invention is special proposes following steps:One kind is in the distribution of linux system user's space
The method of continuous physical memory, including initialization step and distribution continuous physical memory step, described is initial
Change the mapping allocation step at least including 2 user's spaces and physical memory in step.
Wherein said initialization step includes:
Step 1, apply for internal memory in user's space in units of page, user's space is mapped with physical memory
Distribution;
Step 2, the page space to above-mentioned mapping distribution are labeled, and have marked mapping distribution page by described
Physical memory addresses be added in buddy algorithm;
Step 3, repeat step 1 and 2, until total physical memory addresses of distribution meet demand;
Step 4, find out the continuous block address memory of physical memory from above-mentioned buddy algorithm, user's space with
The continuous block address memory of found out physical memory maps distribution again, generates new mapping and distributes and replace former
Put into buddy system after mapping distribution, then calculate physical memory and the deviant of new mapping distribution preserves
In buddy system.
Described distribution continuous physical memory step includes:
Step 1, obtain from the buddy system that above-mentioned initialization step completes needs continuous physical memory head
Address;
Step 2, the first address of above-mentioned physical memory is worth to the first address of virtual address plus described skew,
Complete and distribute continuous physical memory in user's space.
The present invention achieves the buddy algorithm of physical memory distribution in linux system user's space, does not change
Linux kernel and realize as far as possible continuous physical memory distribution and manage, support paging platform on run
Linux system can be realized, highly versatile, and is not need to rely on specific hardware.
Brief description
Fig. 1 is user's space structural representation in LINUX system of the present invention;
Fig. 2 is the inventive method flow chart;
Fig. 3 is a kind of preferred embodiment flow chart of initialization step of the present invention.
Specific embodiment
In the following description, in order that reader more fully understands that the application proposes many ins and outs.
But, even if it will be understood by those skilled in the art that there is no these ins and outs and based on following
The many variations of each embodiment and modification, are also each claim of the application technical side required for protection
Case.
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing to this
Bright embodiment is described in further detail.
As shown in figure 1, present system includes supporting in the hardware device of paging, LINUX operating system
Core, LINUX system calling interface and user's space, wherein at least include network protocol stack in user's space
(for example:TCP/IP, HTTP etc.), system function storehouse, continuous physical memory distribution page module with
And client layer buddy algorithm module etc..
According to system shown in Figure 1, Fig. 2 for another example, the inventive method comprises the following steps that:
Initialized step:
Step 1, apply for internal memory in user's space in units of page, user's space is mapped with physical memory
Distribution, for example, sets up the mapping distribution page of virtual address and physical address in units of page in user's space;
Step 2, the page space to above-mentioned mapping distribution are labeled, and have marked mapping distribution page by described
Physical memory addresses be added in buddy algorithm;
Step 3, repeat step 1 and 2, until total physical memory addresses of distribution meet demand;
Step 4, find out the continuous block address memory of physical memory from above-mentioned buddy algorithm, user's space with
The continuous block address memory of found out physical memory maps distribution again, generates new mapping and distributes and replace former
Put into buddy system after mapping distribution, then calculate physical memory and the deviant of new mapping distribution preserves
In buddy system.
Described distribution continuous physical memory step includes:
Step 1, obtain from the buddy system that above-mentioned initialization step completes needs continuous physical memory head
Address;
Step 2, the first address of above-mentioned physical memory is worth to the first address of virtual address plus described skew,
Complete and distribute continuous physical memory in user's space.
Fig. 3 is a preferred embodiment of initialization step of the present invention, and the user in linux system of the present invention is empty
Between distribute continuous physical memory initialization step as follows:
Step 1, mmap is called to distribute the mapping distribution page of a 4k from/dev/mem;To described mapping
Distribution page carries out write operation, for example, write 1 to the first character section of this page, so that it is guaranteed that this page is divided
Join;
Step 2, basis/proc/self/memmap mapping distribution obtain the physical memory of described mapping distribution page,
And described physical memory is added in buddy algorithm;In order to prevent swapout, need to call mlock (encryption
Lock) locking protection is carried out to this page;
Step 3, judge to map whether distribution page has met the demand of total physical memory, be such as unsatisfactory for, repeat to walk
Rapid 1-2, until total physical memory of mapping distribution meets demand;
Step 4, the total physical memory such as mapping distribution have met demand, then the buddy algorithm described in from step 3
In find out the continuous memory block of physical memory, and then to described physical memory continuous memory block pass through mmap
Mapping is assigned to new virtual address again, after described new virtual address replacement above-mentioned mapping distribution page again
Pass to buddy system, then calculate physical memory and the deviant of new virtual address is saved in buddy system
In.
It should be noted that each unit mentioned in the present invention each equipment embodiment is all logical block,
Physically, a logical block can be the one of a physical location or a physical location
Part, can also be realized with the combination of multiple physical locations, these logical block physics realization sides of itself
Formula is not most important, and the combination of the function that these logical blocks are realized is only the solution present invention and is carried
The key of the technical problem going out.Additionally, for the innovative part projecting the present invention, the present invention does not introduce
Above-mentioned each equipment embodiment and the list less close with solving technical problem relation proposed by the invention
Unit, but this is not intended that there is not the said equipment embodiment and other relevant implementation unit.
Although by referring to some of the preferred embodiment of the invention, the present invention has been shown and
Description, but it will be understood by those skilled in the art that can in the form and details it be made respectively
Plant and change, without departing from the spirit and scope of the present invention.
Claims (4)
1. a kind of method distributing continuous physical memory in linux system user's space, including initialization step
With distribution continuous physical memory step, it is characterized in that at least including 2 user's skies in described initialization step
Between mapping allocation step with physical memory.
2. according to claim 1 a kind of distribute continuous physical memory in linux system user's space
Method, is characterized in that:
Described initialization step includes:
Step 1, apply for internal memory in user's space in units of page, user's space is reflected with physical memory
Penetrate distribution;
Step 2, the page space to above-mentioned mapping distribution are labeled, and have marked mapping distribution by described
The physical memory addresses of page are added in buddy algorithm;
Step 3, repeat step 1 and 2, until total physical memory addresses of distribution meet demand;
Step 4, find out the continuous block address memory of physical memory, user's space from above-mentioned buddy algorithm
Map distribution again with the continuous block address memory of found out physical memory, generate new mapping and distribute and replace
Put into buddy system after former mapping distribution, then calculate physical memory and the deviant of new mapping distribution is protected
Exist in buddy system.
Described distribution continuous physical memory step includes:
Step 1, obtain the continuous physical memory of needs from the buddy system that above-mentioned initialization step completes
First address;
Step 2, the first address of above-mentioned physical memory is worth to the first address of virtual address plus described skew,
Complete and distribute continuous physical memory in user's space.
3. according to claim 1 a kind of distribute continuous physical memory in linux system user's space
Method, is characterized in that described initialization step is:
Step 1, mmap is called to distribute the mapping distribution page of a 4k from/dev/mem;To described mapping
Distribution page carries out write operation;
Step 2, basis/proc/self/memmap mapping distribution obtain the physical memory of described mapping distribution page,
And this physical memory is added in buddy algorithm;
Step 3, judge to map whether distribution page has met the demand of total physical memory, be such as unsatisfactory for, repeat
Step 1-2, until total physical memory of mapping distribution meets demand;
Step 4, the total physical memory such as mapping distribution have met demand, then the partner described in from step 3 calculates
Find out the continuous memory block of physical memory in method, and then continuous memory block passes through to described physical memory
Mmap maps again and is assigned to new virtual address, and described new virtual address is replaced above-mentioned mapping and distributed page
After be transferred again to buddy system, then calculate physical memory and the deviant of new virtual address be saved in partner
With in system.
4. according to claim 3 a kind of distribute continuous physical memory in linux system user's space
Method, is characterized in that basis/proc/self/memmap mapping distribution obtains in the physics of described mapping distribution page
When depositing, and this physical memory being added in buddy algorithm, encryption lock is called to carry out locking protection to this page.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510551977.7A CN106484632A (en) | 2015-09-01 | 2015-09-01 | The method distributing continuous physical memory in linux system user's space |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510551977.7A CN106484632A (en) | 2015-09-01 | 2015-09-01 | The method distributing continuous physical memory in linux system user's space |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106484632A true CN106484632A (en) | 2017-03-08 |
Family
ID=58237710
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510551977.7A Pending CN106484632A (en) | 2015-09-01 | 2015-09-01 | The method distributing continuous physical memory in linux system user's space |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106484632A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108182117A (en) * | 2018-01-25 | 2018-06-19 | 郑州云海信息技术有限公司 | A kind of memory big page dynamic switching method based on X86 platforms |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101075214A (en) * | 2007-06-28 | 2007-11-21 | 腾讯科技(深圳)有限公司 | Method and system for managing memory |
US20070299970A1 (en) * | 2006-06-19 | 2007-12-27 | Liquid Computing Corporation | Secure handle for intra- and inter-processor communications |
CN101706754A (en) * | 2009-09-08 | 2010-05-12 | 厦门敏讯信息技术股份有限公司 | Method and device for allocating continuous physical memory in embedded system |
CN101739289A (en) * | 2008-11-13 | 2010-06-16 | 闪联信息技术工程中心有限公司 | Method and device for setting display mode in Linux virtual machine |
CN101901159A (en) * | 2010-08-03 | 2010-12-01 | 中兴通讯股份有限公司 | Method and system for loading Linux operating system on multi-core CPU |
CN102663276A (en) * | 2012-03-01 | 2012-09-12 | 上海大亚科技有限公司 | System and method providing uniform interface for user space information abstract, encryption and compression in Linux operation system |
CN103744736A (en) * | 2014-01-09 | 2014-04-23 | 深圳Tcl新技术有限公司 | Method for memory management and Linux terminal |
CN103838634A (en) * | 2014-03-18 | 2014-06-04 | 上海电机学院 | Method and system for dispatching number of virtual machines based on internal storage resource supplying |
-
2015
- 2015-09-01 CN CN201510551977.7A patent/CN106484632A/en active Pending
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070299970A1 (en) * | 2006-06-19 | 2007-12-27 | Liquid Computing Corporation | Secure handle for intra- and inter-processor communications |
CN101075214A (en) * | 2007-06-28 | 2007-11-21 | 腾讯科技(深圳)有限公司 | Method and system for managing memory |
CN101739289A (en) * | 2008-11-13 | 2010-06-16 | 闪联信息技术工程中心有限公司 | Method and device for setting display mode in Linux virtual machine |
CN101706754A (en) * | 2009-09-08 | 2010-05-12 | 厦门敏讯信息技术股份有限公司 | Method and device for allocating continuous physical memory in embedded system |
CN101901159A (en) * | 2010-08-03 | 2010-12-01 | 中兴通讯股份有限公司 | Method and system for loading Linux operating system on multi-core CPU |
CN102663276A (en) * | 2012-03-01 | 2012-09-12 | 上海大亚科技有限公司 | System and method providing uniform interface for user space information abstract, encryption and compression in Linux operation system |
CN103744736A (en) * | 2014-01-09 | 2014-04-23 | 深圳Tcl新技术有限公司 | Method for memory management and Linux terminal |
CN103838634A (en) * | 2014-03-18 | 2014-06-04 | 上海电机学院 | Method and system for dispatching number of virtual machines based on internal storage resource supplying |
Non-Patent Citations (1)
Title |
---|
姜力波: "Linux内存管理分析与研究", 《中国优秀硕士学位论文全文数据库 信息科技辑》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108182117A (en) * | 2018-01-25 | 2018-06-19 | 郑州云海信息技术有限公司 | A kind of memory big page dynamic switching method based on X86 platforms |
CN108182117B (en) * | 2018-01-25 | 2021-08-31 | 郑州云海信息技术有限公司 | Dynamic switching method for large memory pages based on X86 platform |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20210117242A1 (en) | Infrastructure processing unit | |
Vandebogart et al. | Labels and event processes in the Asbestos operating system | |
US11556654B2 (en) | Security schemes for multiple trusted-execution-environments (TEEs) and multiple rich-execution-environments (REEs) | |
CN104915151A (en) | Active sharing memory excessive allocation method in multi-virtual machine system | |
US20210117244A1 (en) | Resource manager access control | |
JP2014530413A (en) | Method and apparatus for providing isolated virtual space | |
TW202223640A (en) | Technologies that provide policy enforcement for resource access | |
CN105069383A (en) | Virtual desktop USB (Universal Serial Bus) storage peripheral management and control method and system | |
CN112817780B (en) | Method and system for realizing safety and high-performance interprocess communication | |
CN113544680B (en) | Program interruption for page import/export | |
Xu et al. | A framework for privacy-aware computing on hybrid clouds with mixed-sensitivity data | |
US11861406B2 (en) | Dynamic microservices allocation mechanism | |
CN104732164A (en) | Device and method both for accelerating SSL (Security Socket Layer) data processing speed | |
Zhang et al. | Design and implementation of task scheduling strategies for massive remote sensing data processing across multiple data centers | |
CN114675962A (en) | Attestation support for elastic cloud computing environments | |
US8316207B2 (en) | Assigning efficiently referenced globally unique identifiers in a multi-core environment | |
CN103220166B (en) | The license management method of server cluster | |
CN106484632A (en) | The method distributing continuous physical memory in linux system user's space | |
Bailey et al. | Trusted virtual containers on demand | |
CN104166581A (en) | Virtualization method for increment manufacturing device | |
EP4198780A1 (en) | Distributed attestation in heterogenous computing clusters | |
CN112084536B (en) | Key storage method and device based on blockchain | |
CN101477647A (en) | Service process exhibition control system | |
Nguyen et al. | Towards a cross-domain MapReduce framework | |
Seelam et al. | Orchestrating deep learning workloads on distributed infrastructure |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170308 |