Linux Kernel module memory application and release

Source: Internet
Author: User
Article Title: Linux kernel module memory application and release. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Applied memory:

Void * kmalloc (size_t size, int flags)

The kmalloc function is similar to the malloc function. It has two parameters. One parameter is size, that is, the size of the memory block applied. This parameter is relatively simple, just like the parameter in malloc. The second parameter is a flag in which priority information can be specified. Linux has the following priorities:

GFP_KERNEL indicates that the memory allocation is called by a process running in kernel mode, that is, when the memory is lower than min_free_pages, the process can be sleep;

GFP_ATOMIC, atomic memory allocation allows the process to continue allocating memory when the actual memory is lower than min_free_pages.

GFP_DMA: this flag must be used together with GFP_KERNEL and GFP_ATOMIC to apply for memory pages for Direct Memory Access.

Release:

Kfree (const void * objp) const void * objp = is a pointer to the memory space to be released.

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.