Perf the judgment of whether the two maps overlap, and the function map_groups__fixup_overlappings code logic

Source: Internet
Author: User

The topic can be abstracted out of the question is: Two front open after closed interval Rangea and Rangeb, how to determine whether these two intervals overlap. This problem is very important in the kernel, the division of virtual address space needs it, perf in the construction of Map_group also need it, the following directly gives the solution to the problem:

Find out the case that does not overlap, the other cases are overlapping, perf in the Mmap__overlay function is resolved:

int Map__overlap (struct map *l, struct map *r)
{
if (L->start > R->start) {//First swap, let L point to the left, that is, the map with the smaller starting address "gestures with one axis"
struct map *t = l;
L = r;
R = t;
}
if (L->end > R->start)//Then as long as the end address of the map on the left exceeds the start address of the map on the right, it must overlap
return 1;

return 0;
}

Now that the first problem is solved, the second problem is resolved as follows: Map_groups__fixup_overlappings function parsing:

function prototypes: int map_groups__fixup_overlappings (struct map_groups *mg, struct map *map, FILE *FP)
Parameter: MG, store the registered map, use two tree storage;

Map, the map to be inserted, to adjust the map already registered in MG according to the map;

FP, error output ground.

The function name describes the function: based on overlapping information, the existing map in the map_groups is modified. The principle of correction is to catch up. What do you mean? That is, when the map and MG in a map_registered memory domain conflict, the map at a higher priority, mg_registered to make adjustments.

Two areas overlap is nothing more than the following cases, each of which describes how to adjust:

Perf the judgment of whether the two maps overlap, and the function map_groups__fixup_overlappings code logic

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.