Embodiment
For making object, technical scheme and the advantage of the embodiment of the present invention clearer, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is the present invention's part embodiment, instead of whole embodiment.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
The address space resource allocation process method flow diagram that Fig. 2 provides for the embodiment of the present invention, as shown in Figure 2, the method comprises:
Step 100, the several downlink ports included to each bridge device in system detect;
Whether system, in course of normal operation, detect the downlink port of bridge device, have equipment that hot plug occurs in downlink port to know.
Step 101, know in a downlink port that has equipment to be inserted into a bridge device if detect,, according to the length of the needed address space resource of equipment of inserting, being in the first default address space resource of described bridge device, be one section of idle address space resource of devices allocation of described insertion.
In the time that the equipment of detecting is inserted in a downlink port of bridge device, the equipment that first detects this insertion needs how many address space resources; Then in the first address space resource, be dynamically, its needed address space resource of this devices allocation.This first address space resource is that system is in advance for bridge device is distributed, to be inserted into the shared address space resource sum of the external equipment of this bridge device large than distributing to for its size, will reserve a part of address space resources and use in order to other equipment hot swaps.
The method that the present embodiment provides, by being the reserved certain address space resource of uplink port of all bridge devices in system in advance, while having equipment to insert, can be dynamically the needed address space resource of devices allocation in system course of normal operation.Can carry out dynamic assignment resource according to the required address space of equipment like this, can not affect because of inadequate resource the operation of equipment, strengthen the warm connection function of equipment.For the distribution of the first address space resource, can, referring to following embodiment, certainly be not limited to this.
The address space resource allocation process method flow diagram that Fig. 3 provides for another embodiment of the present invention, as shown in Figure 3, the method comprises:
Step 200, carrying out in the process of system bus topology, the several downlink ports included to each bridge device in system detect, and obtain and are plugged on length statistical information in described several downlink port, the needed address space resource of all devices;
Before the formal startup of each operating system, all to first move bios program, this program major function is to configure hardware environment to make operating system stable operation.The BIOS moving on most computers and server can be first to PCIE bus topology once, makes the topology of operating system become simple.The embodiment of the present invention describes as example system PCIE bus topology taking BIOS.
Fig. 4 is that in embodiment of the present invention PCIE bus topology process, address space resource is distributed schematic diagram, as shown in Figure 4, the PCIE bus topolopy of this system comprises an i.e. SW and the 2nd SW of two bridge devices, and each SW is provided with a uplink port and several downlink ports.For example, " 2 " number uplink port of a SW and this topological structure at the middle and upper levels " 1 " number downlink port of equipment are connected, and should be connected with four downlink ports by " 2 " number uplink port.In the present embodiment, in four downlink ports of a SW, there are three to be connected with external equipment, have a downlink port not connect external equipment, for example " 5 " number downlink port.The topological structure of the 2nd SW repeats no more herein.
Carry out in the process of system PCIE bus topology at BIOS, bios program carries out topology according to the mode of degree of depth traversal to PCIE bus, specifically can be undertaken by mode below: the equipment under a bus of bios program scanning, judge according to the mark that in this equipment, configuration space carries whether this equipment is bridge device, if not bridge device is directly this devices allocation address space resource; If bridge device be that this bridge device is distributed a bus, and continue the equipment under the newly assigned bus of scanning, the rest may be inferred completes the topology of PCIE bus.
Be that bridge device is for example when SW when BIOS finds certain equipment, first to detect the included several downlink ports of this SW, four downlink ports that for example will detect a SW to a SW, obtain the length statistical information that is plugged on the needed address space resource of all devices in these four downlink ports.In the one SW of the present embodiment, BIOS detects that " 3 " number downlink port, " 4 " number downlink port and " 6 " number downlink port are connected with external equipment, and the length that detects the address space resource of knowing the equipment needs that are connected to " 3 " number downlink port is 1M, the length of address space resource that being connected to the equipment of " 4 " number downlink port needs is 1M, and the length that is connected to the address space resource that the equipment of " 6 " number downlink port needs is 2M.The length statistical information that BIOS adds up to obtain the address space resource of the uplink port that at least should distribute to a SW by the length of three needed address space resources of equipment is the length of 4M.BIOS as above operates each SW successively, can get the length statistical information that each SW is corresponding.
Step 201, according to described length statistical information, for the uplink port of corresponding bridge device distributes the first address space resource, and according to all devices length of needed address space resource being separately plugged in described several downlink ports of corresponding bridge device, in described the first address space resource, for described all devices distributes respectively address space resources; The length of described the first address space resource is greater than the length of the corresponding address space resource of described length statistical information.
BIOS gets after the length statistical information that a SW is corresponding by detection, and system will be distributed the first address space resource for the uplink port of corresponding SW.In the present embodiment, in order to realize the hot plug of arbitrary equipment on SW, therefore will will distribute to the resource that separates certain space in the address space resource of this uplink port, the length of the first address space resource is greater than the length of the corresponding address space resource of length statistical information more.In the present embodiment, the length of the first address space resource of distributing to a SW is longer than being plugged on three the needed address space resource size of equipment sums in several downlink ports of a SW, the length of the first address space resource is greater than 4M, taking overabsorption 10M as example, the first address space resource is " 0x00000000-0x00dfffff ", and length is 14M.In the present embodiment, describe as an example of overabsorption 10M example, be certainly not limited to this, can distribute according to demand the space of fair-sized.
The uplink port that is a SW distributes after the first address space resource, in the downlink port due to a SW, has external equipment, therefore will distribute address space resource separately for the downlink port that is plugged with equipment.Allocation scheme can be, according to be plugged in several downlink ports of corresponding bridge device, all devices length of needed address space resource separately, in the first address space resource " 0x00000000-0x00dfffff ", for all devices distributes respectively address space resources.Particularly, because the length of address space resource that is plugged on the equipment of " 3 " number downlink port and needs is 1M, the address space resource that therefore can mark off length and be 1M in the first address space resource is distributed to this " 3 " number downlink port, for example " 0x00000000-0x000fffff ".The like, the address space resource that " 4 " number downlink port is corresponding can be " 0x00100000-0x001fffff ", the address space resource that " 6 " number downlink port is corresponding can be " 0x00200000-0x003fffff ".In the present embodiment, the address space resource of distributing for each downlink port can be to distribute according to the mode increasing progressively continuously as from the foregoing.Hence one can see that, although " 5 " number downlink port of a SW does not have connection device, but be that the uplink port of a SW is while distributing address space resources, reserve i.e. " 0x00400000-0x00dfffff " part of a part of resource, be convenient to the follow-up hot plug that realizes equipment on " 5 " number downlink port.And have above-mentioned known, distributing to the address space resource that a SW is respectively connected with the downlink port of equipment all, can ensure in the equipment of the downlink port of data distributing to the SW within " 0x00000000-0x00dfffff " at the address filtering window of a SW uplink port.
Further, this method embodiment distributes respectively the first corresponding address space resource to two adjacent SW uplink port separately, can be also to distribute according to the mode increasing progressively continuously.For example, the address space resource of distributing to the uplink port of the 2nd SW can be " 0x00e00000-0x01dfffff ", and this length is also than the length that is plugged on the needed address space resource of all devices sum in each downlink port of the 2nd SW and has more 10M.
In the address space resource allocation process method that this enforcement provides, by when the topological PCIE bus being the reserved certain address space resource of uplink port of all bridge devices in system, while having equipment to insert in system course of normal operation, it is dynamically the needed address space resource of devices allocation.Can carry out dynamic assignment resource according to the required address space of equipment like this, can not affect because of inadequate resource the operation of equipment, can realize veritably any hot plug of equipment.
In the above-described embodiments, dynamically for the new needed address space resource of devices allocation of inserting is specifically as follows, if detecting, system knows have new equipment to be inserted in a downlink port in SW, detect the such as 1M of length of the needed address space resource of equipment of this new insertion, and in the first address space resource of distributing to this SW, be new one section of idle address space resource of devices allocation of inserting according to this length.A for example SW searches address space resource for example " 0x00400000-0x004fffff " idle and that equate with Len req 1M in " 0x00000000-0x00dfffff " space resources of self, and distributes to this downlink port.
Certainly, in the time that equipment is extracted from downlink port, the present embodiment method can also reclaim address space resource shared this port, know have while extracting in the downlink port of equipment from SW if the system that is specially detects, the address space resource of distributing to before this equipment can be recovered in the first address space resource.If when for example the equipment in " 3 " number downlink port in a SW is pulled out, the address space resource " 0x00000000-0x000fffff " of distributing to before this equipment can be recovered in " 0x00000000-0x00dfffff " space resources, for other equipment hot swaps.
As seen from Figure 4, in the present embodiment, in the time of Topology Discovery, to judge each equipment, if this equipment is bridge device, be inserted in downlink port the needed address space resource of equipment except distributing, separate the address space resource of certain space more.The mode that the rest may be inferred travels through according to the degree of depth completes the topology of PCIE bus.In the present embodiment, be each SW uplink port overabsorption the address space resource of 10M, like this have equipment insert time, can from this 10M space, distribute according to the demand of equipment.In the time having equipment to extract, the resource of equipment can be reclaimed, for follow-up interventional instrument.
Above-described embodiment is to introduce the inventive method to be applied at BIOS and to carry out in the process of system PCIE bus topology, certainly this method embodiment can also be applied in other environment, for example, in os starting, kernel itself also will carry out once topology to PCIE bus.Linux operating system is the operating system of increasing income, can be to modifying about the part of Topology Discovery in the kernel source code of linux operating system, and the method that uses this method embodiment to provide, can make the hot plug of any PCIE equipment of system support.Amendment linux operating system Topology Discovery code, does not rely on mode that BIOS uses this invention and realizes the Topology Discovery of PCIE bus, by operating system, PCIE bus is carried out once to enumerating again completely.
One of ordinary skill in the art will appreciate that: all or part of step that realizes said method embodiment can complete by the relevant hardware of programmed instruction, aforesaid program can be stored in a computer read/write memory medium, this program, in the time carrying out, is carried out the step that comprises said method embodiment; And aforesaid storage medium comprises: various media that can be program code stored such as ROM, RAM, magnetic disc or CDs.
The address space resource allocation process apparatus structure schematic diagram that Fig. 5 provides for the embodiment of the present invention, as shown in Figure 5, this address space resource allocation process device comprises detection module 11 and the first processing module 12, wherein:
Detection module 11, for detecting the included several downlink ports of each bridge device of system;
The first processing module 12, if for detecting and know a downlink port that has equipment to be inserted into a bridge device by described detection module, according to the length of the needed address space resource of equipment of inserting, being in the first default address space resource of described bridge device, it is one section of idle address space resource of devices allocation of described insertion.
Whether particularly, system is in course of normal operation, and detection module 11 will detect the downlink port of bridge device, have equipment that hot plug occurs in downlink port to know.In the time that the equipment of detecting is inserted in a downlink port of bridge device, the equipment that first detects this insertion needs how many address space resources; Then in the first address space resource, be dynamically, its needed address space resource of this devices allocation by the first processing module 12.This first address space resource is that system is in advance for bridge device is distributed, to be inserted into the shared address space resource sum of the external equipment of this bridge device large than distributing to for its size, will reserve a part of address space resources and use in order to other equipment hot swaps.
The device that the present embodiment provides, by being the reserved certain address space resource of uplink port of all bridge devices in system in advance, while having equipment to insert, can be dynamically the needed address space resource of devices allocation in system course of normal operation.Can carry out dynamic assignment resource according to the required address space of equipment like this, can not affect because of inadequate resource the operation of equipment, strengthen the warm connection function of equipment.
For the distribution of the first address space resource, the second processing module 13 in the address space resource allocation process device that can provide by the present embodiment completes, particularly, the second processing module 13 is carrying out in the process of system bus topology, the several downlink ports included to bridge device detect, and obtain and are plugged on length statistical information in several downlink ports, the needed address space resource of all devices; And according to length statistical information, for the uplink port of bridge device distributes the first address space resource, and according to be plugged in several downlink ports of bridge device, all devices length of needed address space resource separately, in the first address space resource, for all devices distributes respectively address space resources; The length of the first address space resource is greater than the length of the corresponding address space resource of described length statistical information.
Particularly, in the time that address space resource allocation process device carries out PCIE bus topology, the second processing module 13 scans the equipment under bus, judge according to the mark that in this equipment, configuration space carries whether this equipment is bridge device, if not bridge device is directly this devices allocation address space resource; If bridge device be that this bridge device is distributed a bus, and continue the equipment under the newly assigned bus of scanning, know in the several downlink ports that are plugged on bridge device, all devices length of needed address space resource separately.Then the second processing module 13, except the address space resource that distributing equipment needs, separates the address space resources of certain space in addition.The mode that the rest may be inferred travels through according to the degree of depth completes the topology of PCIE bus.
Further in the present embodiment, if the first processing module 12 is also for knowing by detection module 11 while having equipment to extract from bridge device one downlink port, the first processing module 12 is recovered to the address space resource of distributing to before this equipment in the first address space resource, and the hot drawing of finishing equipment goes out.
More than install each functional module in embodiment effect and between cooperation with complete address space resource distribute, can, referring to the treatment scheme providing in above-mentioned each embodiment of the method, repeat no more herein.
Embodiment of the present invention address space resource allocation process device is by the time of Topology Discovery PCIE bus, for the reserved certain address space resource of uplink port of all bridge devices in system, in system course of normal operation, while having equipment to insert, be the needed address space resource of devices allocation dynamically.In the time having equipment to extract, reclaim the address space resource that this equipment has, during for the hot insertion event of later generation.Can carry out Resources allocation according to the required address space of equipment like this, not affect the operation of equipment being subject to inadequate resource, any hot plug of the equipment of realizing that can be real.
The embodiment of the present invention also provides a kind of operating system, comprises the address space resource allocation process device that said apparatus embodiment provides.The method that this operating system the present embodiment provides is by being in advance the reserved certain address space resource of uplink port of all bridge devices in system, while having equipment to insert in system course of normal operation, it can be dynamically the needed address space resource of devices allocation.Can carry out dynamic assignment resource according to the required address space of equipment like this, can not affect because of inadequate resource the operation of equipment, strengthen the warm connection function of equipment.
Finally it should be noted that: above embodiment only, in order to technical scheme of the present invention to be described, is not intended to limit; Although the present invention is had been described in detail with reference to previous embodiment, those of ordinary skill in the art is to be understood that: its technical scheme that still can record aforementioned each embodiment is modified, or part technical characterictic is wherein equal to replacement; And these amendments or replacement do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.