linux-kernel模块分配的最大内存 [英] maximum allocated memory by linux-kernel module

查看:321
本文介绍了linux-kernel模块分配的最大内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个模块,其任务是捕获传入的数据包,而不将其发送到用户空间应用程序&对捕获的数据包进行一些修改.然后该模块会将这个数据包发送给NIC.

I want to write a module whose task is to capture the incoming packets without sending them to the user space application & doing some modification on the captured packet. then this module will send this packet for transmission to the NIC.

但是主要问题是我的模块尺寸很大,它也做很多处理.因此,最好在内核模块中进行此处理,否则我们应该传递信息& ;?分组到用户空间进行处理以避免复杂性.

But main problem is that my module is very big in size & it also does a lot of processing. So will it be good to do this processing inside kernel module or should we pass the information & packet to the user space for processing to avoid complexity.

&我这样做只是为了非常快速地进行数据包处理.
因此最大程度是linux内核模块可以分配多少内存.

& i m doing it only for getting packet processing very quick.
so maximum how much memory could be allocated by a linux-kernel module.

推荐答案

在内核空间而不是用户空间中运行时,网络数据包始终会更快.请记住,必须将其复制到用户空间,这是一项昂贵的操作.但是,并不是所有的东西都应该在内核空间中运行,因为这会使系统非常不稳定,因为每个错误都可能导致内核崩溃. 因此,如果要使用内核或用户空间对应用程序进行编程,很大程度上取决于您的规范.

A network packet will always be faster when running in kernel space instead of user-space. Remember, that it has to be copied to user-space, which is an expensive operation. However, not everything should be running in kernel space as this would make the system very unstable, because every bug is a potential kernel crash. So if you want to program your application using kernel or user space heavily depends on your specifications.

相反,要分配的内存量根本没有关系.在Linux模块中使用kmalloc(),您可以分配的内存与系统中实际可用的内存一样多,所以应该没事.

In contrast, the amount of memory to be allocated does not matter at all. Using kmalloc() in the linux module you can allocate as much memory as there is physically available in the system, so you should be fine.

这篇关于linux-kernel模块分配的最大内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆