What is the role of CMA memory allocation technology for TV boxes?
Counting Module developed for self-service banknote deposit module Suzhou Ribao Technology Co. Ltd. , https://www.ribaoeurope.com
What is CMA memory allocation technology
The CMA (Contiguous Memory Allocator) is an intelligent continuous memory allocation technology and is an extension of the Linux Kernel memory management system. The purpose is to solve the problem of running out of memory due to the need to reserve a large amount of continuous memory for video playback (especially for 4K video).
1. Introduction The CMA - Contiguous Memory Allocator is a framework that allows the creation of a platform-independent configuration for continuous memory management. Then, the memory required by the device is allocated according to this configuration.
The main role of this framework is not to allocate memory, but to parse and manage the memory configuration as well as acting as an intermediate component between the device driver and the pluggable distributor. Therefore, it is not dependent on any memory allocation method and allocation strategy.
2. Why do I need it?
In embedded devices, many devices do not support scatter-getter and IO maps, and require continuous memory block operations. Such as equipment: cameras, hardware video decoders, encoders, etc.
These devices often require larger memory buffers (eg, a 2-megapixel HD frame camera that requires more than 6 Mbytes of memory). The kmalloc memory allocation mechanism has no effect on such large memory.
Some embedded devices have some additional requirements for the buffer, such as: in a device with multiple memory banks, it is required to allocate memory only in a specific bank; there are also some buffers to be aligned with memory boundaries.
Recently, embedded devices have been greatly developed (especially in the V4L world), and these drivers have their own memory allocation codes. Most of them are using the bootmem allocation method. The CMA framework attempts to adopt a unified continuous memory allocation mechanism and provide a simple API for these device drivers, and it can be customized and modularized.
The main design goal of CMA is to provide a customizable modular framework that is configurable to suit the needs of individual systems. Configure the specified memory area, and then allocate the memory to the specified device. These memory areas can be shared to multiple device drivers, or they can be assigned exclusively. This is achieved through the following methods:
1) The core of CMA is not to handle memory allocation and free space management. The dedicated allocator is used to handle memory allocation and free memory management. Therefore, if the existing solution does not meet the given system, then a new algorithm can be developed, which can be easily inserted into the CMA framework.
The proposed solution includes an implementation of a best-fit algorithm.
2) The CMA allows the runtime to configure the memory area to be allocated. The memory area is given via the command line, so it can be easily changed without recompiling the kernel.
Each region has its own size, alignment criteria, starting address (physical address) and memory allocation algorithm for the memory region.
This means that there can be multiple mechanisms running at the same time. If multiple devices are running on one platform at the same time and these devices have different memory usage characteristics, the Office can match the best algorithm.
3) When the device requests memory, the device must "introduce itself", that is, attach its own information to inform the CMA. This way the CMA can know who is allocating memory. This allows the system architect to specify which storage area should be used by which mobile device.
Devices can also specify a "class" memory area, which makes the system easier to configure, so that a single device may use memory from different memory areas. For example, a video decoder driver may allocate some shared buffers, then allocate some from the first bank and allocate some from the second bank to get the highest possible memory throughput.
4. Use Scenarios Use a system that uses CMA to see how it is used and configured.
There is a platform that carries hardware video decoders and cameras, each of which may require 20M of memory in the worst case. In this system, these two devices are not used at the same time, and memory is likely to be shared. Use the following two command lines:
The first CMA instruction allocates 20M of memory and the memory allocator is valid; the second indicates that the two drivers named "video" and "camera" allocate memory from the previously defined memory area.
Because the two share the same memory area, the system reserves 20M of memory space compared to each device, allowing the system to save 20M of memory space.
However, with the development and evolution of the system, the video decoder and the video camera may be running on the platform at the same time, so the memory area of a€?a€?20 M cannot satisfy the requirement. Then it can be quickly solved by the command:
From this solution you can also see how the CMA allocates the required private memory pool for each device.
The distribution mechanism can also be replaced in a similar way. In the test, it was found that when the size of the given memory area is 40 M, the fragmentation becomes a problem after the system runs for a while. Therefore, in order to meet the required cache size, a larger cache area needs to be reserved.
But unfortunately, you need to set a new allocation algorithm - Neat Allocation Algorithm (abbreviation na), the two devices have 30M memory requirements:
As can be seen from the above example, when the algorithm provided by the CMA does not meet the requirements, how to configure your own allocation algorithm without modifying the CMA or re-encoding the kernel.
The role of the traditional box memory technology Currently on the market to support 4K ultra high-definition resolution products, the general practice will reserve part of the memory, this part of the reserved memory is usually not used, only used in the playback of 4K ultra high-definition video. However, this will also result in a reduction of normal function memory, which will affect fluency when large tasks are involved.
The role of CMA memory allocation technology Millet Box 1G enhanced version uses optimized CMA intelligent continuous memory allocation technology, usually allocates large blocks of continuous memory reserved for 4K playback to other programs to fully ensure the smoothness of the system. Quickly allocate memory to the video player when playing 4K video and also ensure smooth 4K playback.
The millet box 1G enhanced version uses the CMA memory allocation technology optimized by Xiaomi, making the memory usage of the millet box more efficient, improving the memory management strategy of the Linux kernel, doing well in the millet box product itself, and also developing the Linux technology. Made a great contribution.
Communication with deposit system via RS232
Multiple data check to ensure reliable and safe data exchange
Safe and Reliable platform with different sensors to monitor fraud activity
Complete protocal for integration
Software upgrade by USB or RS232
Counting Module developed for self-service
banknote deposit module
Suzhou Ribao Technology Co. Ltd. , https://www.ribaoeurope.com