免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: cskyrain
打印 上一主题 下一主题

[内存管理] 如何在kernel中分配一段nocache的内存 [复制链接]

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
21 [报告]
发表于 2013-04-22 22:54 |只看该作者
回复 20# leil


对!

   

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:53:17
22 [报告]
发表于 2013-04-23 09:24 |只看该作者
embeddedlwp 发表于 2013-04-22 16:26
回复 9# 帅绝人寰



你如何获得pages? 无非是用get_free_pages/alloc_pages之类的API ── 这些API本身就会建立映射的, 对不对?

然后呢, 只不过因为这映射是1:1的,所以你可以拿到物理地址 ── 也就可以ioremap了。


同样的一段RAM,被映射到了2个不同的地方, 你觉得这样……干净吗?

论坛徽章:
0
23 [报告]
发表于 2013-04-23 09:32 |只看该作者
回复 20# leil


麻烦把intel手册中说的贴出来,我也好学习学习!问题是我在别的架构上比如arm/alpha等也用wc属性、也用这个函数来申请呢?


   

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
24 [报告]
发表于 2013-04-23 09:35 |只看该作者
回复 23# uliux

• Uncacheable (UC-) — Has same characteristics as the strong uncacheable (UC)
     memory type, except that this memory type can be overridden by programming
    the MTRRs for the WC memory type. This memory type is available in processor
   families starting from the Pentium III processors and can only be selected through
  the PAT.
• Write Combining (WC) — System memory locations are not cached (as with
     uncacheable memory) and coherency is not enforced by the processor’s bus
      coherency protocol. Speculative reads are allowed. Writes may be delayed and
     combined in the write combining buffer (WC buffer) to reduce memory accesses.
    If the WC buffer is partially filled, the writes may be delayed until the next
   occurrence of a serializing event; such as, an SFENCE or MFENCE instruction,
  CPUID execution, a read or write to uncached memory, an interrupt occurrence,
or a LOCK instruction execution. This type of cache-control is appropriate for
video frame buffers, where the order of writes is unimportant as long as the
writes update memory so they can be seen on the graphics display. See Section
11.3.1, “Buffering of Write Combining Memory Locations,” for more information
   about caching the WC memory type. This memory type is available in the
  Pentium Pro and Pentium II processors by programming the MTRRs; or in
processor families starting from the Pentiu

   

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
25 [报告]
发表于 2013-04-23 10:05 |只看该作者
回复 22# 帅绝人寰

Ok.



   

论坛徽章:
0
26 [报告]
发表于 2013-04-23 10:25 |只看该作者
回复 24# embeddedlwp


ok!不讨论理论了,intel的架构很复杂众所周知。
那请问在intel的环境下,如何在kernel中分配一段nocache的内存?

   

论坛徽章:
0
27 [报告]
发表于 2013-04-23 14:12 |只看该作者
我曾经干过类似的事情。修改e820表,空出一段物理memory来,不让内核自动建立映射关系。而是稍后自己用ioremap方式来建立。
帅绝人寰 发表于 2013-04-23 09:24
你如何获得pages? 无非是用get_free_pages/alloc_pages之类的API ── 这些API本身就会建立映射的, ...

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
28 [报告]
发表于 2013-04-23 14:17 |只看该作者
回复 26# uliux


How about this:

page = alloc_page(XX);
set_pages_uc(page, 1);

@帅绝人寰@leil

   

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
29 [报告]
发表于 2013-04-23 15:35 |只看该作者
回复 22# 帅绝人寰


无非是用get_free_pages/alloc_pages之类的API ── 这些API本身就会建立映射的, 对不对?



Are you sure?



   

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:53:17
30 [报告]
发表于 2013-04-23 16:31 |只看该作者
embeddedlwp 发表于 2013-04-23 15:35
回复 22# 帅绝人寰


不建立映射的话, 你用虚拟地址写一个看看?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP