分配大的(32mb)连续区域 [英] allocate large (32mb) contiguous region

查看:110
本文介绍了分配大的(32mb)连续区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行时是否可以从内核代码中分配大的(即32mb)物理上连续的内存区域(即不使用bootmem)?从我的实验来看,无论我使用什么GFP标志,似乎都不可能成功获得超过4mb的块.根据我阅读的文档,GFP_NOFAIL应该使kmalloc等待所需的时间,以释放请求的数量,但是据我所知,只要您请求的数量超过可用数量,它就会无限期地挂起请求-它似乎没有积极地尝试释放内存来满足请求(即kswapd似乎没有在运行).有什么方法可以告诉内核为释放请求的分配而积极地开始交换东西?

Is it at all possible to allocate large (i.e. 32mb) physically contiguous memory regions from kernel code at runtime (i.e. not using bootmem)? From my experiments, it seems like it's not possible to get anything more than a 4mb chunk successfully, no matter what GFP flags I use. According to the documentation I've read, GFP_NOFAIL is supposed to make the kmalloc just wait as long as is necessary to free the requested amount, but from what I can tell it just makes the request hang indefinitely if you request more than is availble - it doesn't seem to be actively trying to free memory to fulfil the request (i.e. kswapd doesn't seem to be running). Is there some way to tell the kernel to aggressively start swapping stuff out in order to free the requested allocation?

所以我从Eugene的响应中看到,不可能从单个kmalloc中获得32mb的区域....但是有没有可能以一种更hackus的方式完成它?就像识别最大的可用连续区域,然后手动迁移/交换数据在其任一侧一样?

So I see from Eugene's response that it's not going to be possible to get a 32mb region from a single kmalloc.... but is there any possibility of getting it done in more of a hackish kind of way? Like identifying the largest available contiguous region, then manually migrating/swapping away data on either side of it?

或者类似这样的东西:

1) Grab a bunch of 4mb chunks until you're out of memory.
2) Check them all to see if any of them happen to be contiguous, if so,
   combine them.
3) kfree the rest
4) goto 1)

如果有足够的时间运行,可能行得通吗?

Might that work, if given enough time to run?

推荐答案

您可能想看看连续内存分配器补丁.从 LWN文章判断,这些补丁正是您所需要的.

You might want to take a look at the Contiguous Memory Allocator patches. Judgging from the LWN article, these patches are exactly what you need.

这篇关于分配大的(32mb)连续区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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