[知其然不知其所以然-41] resource allocation in Linux
来源:互联网 发布:dnd战士优化 编辑:程序博客网 时间:2024/06/10 12:28
Linux uses resource tree to manage the io and memory resources for different device
drivers. Resources are manipulated in the tree structure, every resource has one parent
and several brothers, AKA siblings. Each time when driver wants to allocate a new resource
from this resource tree, the new resource will be compared from top down, try to find
an existing parent resource tree node which is the superset of the new set, if yes, then check the children
of this parent to find the first overlap child, then set this child as the new parent, and so on.
until there is no overlap of the new resource under the parent P, we link the new resource under the
P, and returns OK.
That is to say, only the conflict resource is the super set of new resource, or vice versa, conflict
resource is the subset of the new resource, everything is OK, the only failure case
is when the overlapping does not satisfy the condition that the new resource partially overlaps with
P, then it failed to allocate new resource.
According to kernel/resource.c, the core functions here are actually __request_resource and __insert_resource,
the formal is the base of resource management, which was written by Linus many years ago.
So the formal just check if the given new resource is conflict with any existing resources allocated
under the resource tree, if there is, return the first conflict resource otherwise return NULL, For the latter,
__insert_resource is based on __request_resource, it tries to leverage __request_resource recursively
to find the suitable position to insert the new resource. If new resource is a subset of the P, then loop until
find a hole under P, and done with it. If the P is not a superset of new resource, then check if they
are partially overlapped, if it is , then failed and return. If not, then P must be a subset of new resource, then
new resource should take charge of all P's children, and P become the child of new resource , and also all
P's brothers(siblings) should be the brother of P now.
For example, you can refer to /proc/iomem for a more vivid:
8b800000-dfffffff : PCI Bus 0000:00 8b800000-8b81ffff : pnp 00:08 90000000-9fffffff : 0000:00:02.0 a0000000-a0ffffff : 0000:00:02.0 a1000000-a10fffff : PCI Bus 0000:02 a1000000-a10007ff : 0000:02:00.0 a1001000-a1001fff : 0000:02:00.0 a1001000-a1001fff : mmc0pnp 00:08 , 0000:00:02.0 and PCI Bus 0000:02 are siblings, and mmc0 is the child of 0000:02:00.0.
- [知其然不知其所以然-41] resource allocation in Linux
- [知其然不知其所以然-20] pci resource allocation
- Resource Allocation in Project Management
- NFV放置问题(Resource Allocation in NFV)
- hdu 3288 Resource Allocation
- Resource Allocation and Cross Layer Control in Wireless Networks (Foundations and Trends in Networki
- 知其然不知其所以然!
- [知其然不知其所以然-10] linux dmi table matching
- Applicable Resource Allocation Is Initialization(RAII)
- Spark动态资源分配-Dynamic Resource Allocation
- Spark动态资源分配-Dynamic Resource Allocation
- 动态资源分配(Dynamic Resource Allocation)
- Dominant Resource Fairness: Fair Allocation of Multiple Resource Types
- Memory Allocation in C++/C
- Sequence Number Allocation in PeopleSoft
- Thinking in C++ ---- Memory Allocation
- [知其然不知其所以然-8] linux cpufreq的sysfs文件详细解释
- An Efficient Resource Allocation Scheme for Cross- Cloud Federation
- LeetCode --Shortest Palindrome
- Android 中CircleImageView自定义View(圆形头像)
- POJ 3279 Fliptile
- I2C总线协议详解
- myeclipse显示行数
- [知其然不知其所以然-41] resource allocation in Linux
- apt-get upgrade升级后docker客户端和服务器版本不一致问题解决方式。
- IsNullOrEmpty()
- Python下ORM的一个设计举例
- LeetCode -- Integer Break
- MongoDB的安装和简单使用
- ubuntu如何完全卸载Java
- xcode运行的时候总是显示反汇编
- linux shell&ln&软件包管理&编程工具