My LINUX notes: Memory allocated in the kernel module

Source: Internet
Author: User
My LINUX notes: memory allocation in the kernel module-general Linux technology-Linux programming and kernel information. For details, see below. There are many methods and functions to allocate memory in the kernel module:

1. kmalloc (), which is the most commonly used function. It is fast and physically continuous in the allocated content, but generally, the maximum memory size it can allocate is kb.

2. _ get_free_pages () is used to allocate memory for specified consecutive pages. The property is the same as kmalloc () but more consecutive physical memory can be allocated. Of course, it is the same as kmalloc, the returned value is also the kernel virtual address.

3. vmalloc (), the memory allocated by this function may be physically discontinuous. The memory allocated by this function is not only slightly inefficient but cannot be used for DMA transmission by external devices, it is not recommended to use it in the kernel module. It is recommended only when a large buffer is allocated and used only in the software. Vmalloc () cannot be used in atomic context.
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.